Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
399e1e83
Commit
399e1e83
authored
Jun 01, 2018
by
Paul Slaughter
Committed by
Clement Ho
Jun 01, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update position sticky polyfill
parent
eeb73247
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
3 additions
and
128 deletions
+3
-128
app/assets/javascripts/init_changes_dropdown.js
app/assets/javascripts/init_changes_dropdown.js
+3
-3
app/assets/javascripts/job.js
app/assets/javascripts/job.js
+0
-7
app/assets/javascripts/lib/utils/sticky.js
app/assets/javascripts/lib/utils/sticky.js
+0
-39
spec/javascripts/lib/utils/sticky_spec.js
spec/javascripts/lib/utils/sticky_spec.js
+0
-79
No files found.
app/assets/javascripts/init_changes_dropdown.js
View file @
399e1e83
import
$
from
'
jquery
'
;
import
stickyMonitor
from
'
./lib/utils/sticky
'
;
import
StickyFill
from
'
stickyfilljs
'
;
export
default
(
stickyTop
)
=>
{
stickyMonitor
(
document
.
querySelector
(
'
.js-diff-files-changed
'
),
stickyTop
);
export
default
()
=>
{
StickyFill
.
add
(
document
.
querySelector
(
'
.js-diff-files-changed
'
)
);
$
(
'
.js-diff-stats-dropdown
'
).
glDropdown
({
filterable
:
true
,
...
...
app/assets/javascripts/job.js
View file @
399e1e83
...
...
@@ -80,13 +80,6 @@ export default class Job {
}
initAffixTopArea
()
{
/**
If the browser does not support position sticky, it returns the position as static.
If the browser does support sticky, then we allow the browser to handle it, if not
then we use a polyfill
*/
if
(
this
.
$topBar
.
css
(
'
position
'
)
!==
'
static
'
)
return
;
StickyFill
.
add
(
this
.
$topBar
);
}
...
...
app/assets/javascripts/lib/utils/sticky.js
deleted
100644 → 0
View file @
eeb73247
export
const
createPlaceholder
=
()
=>
{
const
placeholder
=
document
.
createElement
(
'
div
'
);
placeholder
.
classList
.
add
(
'
sticky-placeholder
'
);
return
placeholder
;
};
export
const
isSticky
=
(
el
,
scrollY
,
stickyTop
,
insertPlaceholder
)
=>
{
const
top
=
Math
.
floor
(
el
.
offsetTop
-
scrollY
);
if
(
top
<=
stickyTop
&&
!
el
.
classList
.
contains
(
'
is-stuck
'
))
{
const
placeholder
=
insertPlaceholder
?
createPlaceholder
()
:
null
;
const
heightBefore
=
el
.
offsetHeight
;
el
.
classList
.
add
(
'
is-stuck
'
);
if
(
insertPlaceholder
)
{
el
.
parentNode
.
insertBefore
(
placeholder
,
el
.
nextElementSibling
);
placeholder
.
style
.
height
=
`
${
heightBefore
-
el
.
offsetHeight
}
px`
;
}
}
else
if
(
top
>
stickyTop
&&
el
.
classList
.
contains
(
'
is-stuck
'
))
{
el
.
classList
.
remove
(
'
is-stuck
'
);
if
(
insertPlaceholder
&&
el
.
nextElementSibling
&&
el
.
nextElementSibling
.
classList
.
contains
(
'
sticky-placeholder
'
))
{
el
.
nextElementSibling
.
remove
();
}
}
};
export
default
(
el
,
stickyTop
,
insertPlaceholder
=
true
)
=>
{
if
(
!
el
)
return
;
if
(
typeof
CSS
===
'
undefined
'
||
!
(
CSS
.
supports
(
'
(position: -webkit-sticky) or (position: sticky)
'
)))
return
;
document
.
addEventListener
(
'
scroll
'
,
()
=>
isSticky
(
el
,
window
.
scrollY
,
stickyTop
,
insertPlaceholder
),
{
passive
:
true
,
});
};
spec/javascripts/lib/utils/sticky_spec.js
deleted
100644 → 0
View file @
eeb73247
import
{
isSticky
}
from
'
~/lib/utils/sticky
'
;
describe
(
'
sticky
'
,
()
=>
{
let
el
;
beforeEach
(()
=>
{
document
.
body
.
innerHTML
+=
`
<div class="parent">
<div id="js-sticky"></div>
</div>
`
;
el
=
document
.
getElementById
(
'
js-sticky
'
);
});
afterEach
(()
=>
{
el
.
parentNode
.
remove
();
});
describe
(
'
when stuck
'
,
()
=>
{
it
(
'
does not remove is-stuck class
'
,
()
=>
{
isSticky
(
el
,
0
,
el
.
offsetTop
);
isSticky
(
el
,
0
,
el
.
offsetTop
);
expect
(
el
.
classList
.
contains
(
'
is-stuck
'
),
).
toBeTruthy
();
});
it
(
'
adds is-stuck class
'
,
()
=>
{
isSticky
(
el
,
0
,
el
.
offsetTop
);
expect
(
el
.
classList
.
contains
(
'
is-stuck
'
),
).
toBeTruthy
();
});
it
(
'
inserts placeholder element
'
,
()
=>
{
isSticky
(
el
,
0
,
el
.
offsetTop
,
true
);
expect
(
document
.
querySelector
(
'
.sticky-placeholder
'
),
).
not
.
toBeNull
();
});
});
describe
(
'
when not stuck
'
,
()
=>
{
it
(
'
removes is-stuck class
'
,
()
=>
{
spyOn
(
el
.
classList
,
'
remove
'
).
and
.
callThrough
();
isSticky
(
el
,
0
,
el
.
offsetTop
);
isSticky
(
el
,
0
,
0
);
expect
(
el
.
classList
.
remove
,
).
toHaveBeenCalledWith
(
'
is-stuck
'
);
expect
(
el
.
classList
.
contains
(
'
is-stuck
'
),
).
toBeFalsy
();
});
it
(
'
does not add is-stuck class
'
,
()
=>
{
isSticky
(
el
,
0
,
0
);
expect
(
el
.
classList
.
contains
(
'
is-stuck
'
),
).
toBeFalsy
();
});
it
(
'
removes placeholder
'
,
()
=>
{
isSticky
(
el
,
0
,
el
.
offsetTop
,
true
);
isSticky
(
el
,
0
,
0
,
true
);
expect
(
document
.
querySelector
(
'
.sticky-placeholder
'
),
).
toBeNull
();
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment