Commit 016e7503 authored by Phil Hughes's avatar Phil Hughes

Fix performance of sticky.js

Closes #39332
parent 5295f23b
import stickyMonitor from './lib/utils/sticky'; import stickyMonitor from './lib/utils/sticky';
export default () => { export default () => {
stickyMonitor(document.querySelector('.js-diff-files-changed')); stickyMonitor(document.querySelector('.js-diff-files-changed'), 76);
$('.js-diff-stats-dropdown').glDropdown({ $('.js-diff-stats-dropdown').glDropdown({
filterable: true, filterable: true,
......
...@@ -28,14 +28,10 @@ export const isSticky = (el, scrollY, stickyTop, insertPlaceholder) => { ...@@ -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; if (!el) return;
const computedStyle = window.getComputedStyle(el); if (typeof CSS === 'undefined' || !(CSS.supports('(position: -webkit-sticky) or (position: sticky)'))) return;
if (!/sticky/.test(computedStyle.position)) return;
const stickyTop = parseInt(computedStyle.top, 10);
document.addEventListener('scroll', () => isSticky(el, window.scrollY, stickyTop, insertPlaceholder), { document.addEventListener('scroll', () => isSticky(el, window.scrollY, stickyTop, insertPlaceholder), {
passive: true, passive: true,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment