summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/lib
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-10-20 18:56:43 +0100
committerPhil Hughes <me@iamphill.com>2017-10-23 10:38:00 +0100
commit016e750308b6e927b53d8c050b3f3bb60e9ca4aa (patch)
treea684a912f0daa16def53441acd374962f51cf4af /app/assets/javascripts/lib
parent5295f23b4bf1b13c9395c1871edce0095cb852cc (diff)
downloadgitlab-ce-016e750308b6e927b53d8c050b3f3bb60e9ca4aa.tar.gz
Fix performance of sticky.js
Closes #39332
Diffstat (limited to 'app/assets/javascripts/lib')
-rw-r--r--app/assets/javascripts/lib/utils/sticky.js8
1 files changed, 2 insertions, 6 deletions
diff --git a/app/assets/javascripts/lib/utils/sticky.js b/app/assets/javascripts/lib/utils/sticky.js
index 64db42701ce..098afcfa1b4 100644
--- a/app/assets/javascripts/lib/utils/sticky.js
+++ b/app/assets/javascripts/lib/utils/sticky.js
@@ -28,14 +28,10 @@ export const isSticky = (el, scrollY, stickyTop, insertPlaceholder) => {
}
};
-export default (el, insertPlaceholder = true) => {
+export default (el, stickyTop, insertPlaceholder = true) => {
if (!el) return;
- const computedStyle = window.getComputedStyle(el);
-
- if (!/sticky/.test(computedStyle.position)) return;
-
- const stickyTop = parseInt(computedStyle.top, 10);
+ if (typeof CSS === 'undefined' || !(CSS.supports('(position: -webkit-sticky) or (position: sticky)'))) return;
document.addEventListener('scroll', () => isSticky(el, window.scrollY, stickyTop, insertPlaceholder), {
passive: true,