summaryrefslogtreecommitdiff
path: root/app
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
parent5295f23b4bf1b13c9395c1871edce0095cb852cc (diff)
downloadgitlab-ce-016e750308b6e927b53d8c050b3f3bb60e9ca4aa.tar.gz
Fix performance of sticky.js
Closes #39332
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/init_changes_dropdown.js2
-rw-r--r--app/assets/javascripts/lib/utils/sticky.js8
2 files changed, 3 insertions, 7 deletions
diff --git a/app/assets/javascripts/init_changes_dropdown.js b/app/assets/javascripts/init_changes_dropdown.js
index f785ed29e6c..e41f374b2e5 100644
--- a/app/assets/javascripts/init_changes_dropdown.js
+++ b/app/assets/javascripts/init_changes_dropdown.js
@@ -1,7 +1,7 @@
import stickyMonitor from './lib/utils/sticky';
export default () => {
- stickyMonitor(document.querySelector('.js-diff-files-changed'));
+ stickyMonitor(document.querySelector('.js-diff-files-changed'), 76);
$('.js-diff-stats-dropdown').glDropdown({
filterable: true,
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,