Commit 9f427ee5 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'lm-replace-debounced-underscores' into 'master'

Replace underscore debounce and throttle with lodash version

See merge request gitlab-org/gitlab!29624
parents 48973120 0f2e7347
import $ from 'jquery'; import $ from 'jquery';
import { debounce } from 'lodash';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import _ from 'underscore';
import { GlBreakpointInstance as bp, breakpoints } from '@gitlab/ui/dist/utils'; import { GlBreakpointInstance as bp, breakpoints } from '@gitlab/ui/dist/utils';
import { parseBoolean } from '~/lib/utils/common_utils'; import { parseBoolean } from '~/lib/utils/common_utils';
...@@ -43,7 +43,7 @@ export default class ContextualSidebar { ...@@ -43,7 +43,7 @@ export default class ContextualSidebar {
$(document).trigger('content.resize'); $(document).trigger('content.resize');
}); });
$(window).on('resize', () => _.debounce(this.render(), 100)); $(window).on('resize', debounce(() => this.render(), 100));
} }
// See documentation: https://design.gitlab.com/regions/navigation#contextual-navigation // See documentation: https://design.gitlab.com/regions/navigation#contextual-navigation
......
/* eslint-disable no-new */ /* eslint-disable no-new */
import _ from 'underscore'; import { debounce } from 'lodash';
import axios from './lib/utils/axios_utils'; import axios from './lib/utils/axios_utils';
import Flash from './flash'; import Flash from './flash';
import DropLab from './droplab/drop_lab'; import DropLab from './droplab/drop_lab';
...@@ -55,7 +55,7 @@ export default class CreateMergeRequestDropdown { ...@@ -55,7 +55,7 @@ export default class CreateMergeRequestDropdown {
this.isCreatingMergeRequest = false; this.isCreatingMergeRequest = false;
this.isGettingRef = false; this.isGettingRef = false;
this.mergeRequestCreated = false; this.mergeRequestCreated = false;
this.refDebounce = _.debounce((value, target) => this.getRef(value, target), 500); this.refDebounce = debounce((value, target) => this.getRef(value, target), 500);
this.refIsValid = true; this.refIsValid = true;
this.refsPath = this.wrapperEl.dataset.refsPath; this.refsPath = this.wrapperEl.dataset.refsPath;
this.suggestedRef = this.refInput.value; this.suggestedRef = this.refInput.value;
......
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import { debounce } from 'lodash';
import axios from './lib/utils/axios_utils'; import axios from './lib/utils/axios_utils';
/** /**
...@@ -29,7 +29,7 @@ export default class FilterableList { ...@@ -29,7 +29,7 @@ export default class FilterableList {
initSearch() { initSearch() {
// Wrap to prevent passing event arguments to .filterResults; // Wrap to prevent passing event arguments to .filterResults;
this.debounceFilter = _.debounce(this.onFilterInput.bind(this), 500); this.debounceFilter = debounce(this.onFilterInput.bind(this), 500);
this.unbindEvents(); this.unbindEvents();
this.bindEvents(); this.bindEvents();
......
import _ from 'underscore'; import { debounce, throttle } from 'lodash';
export const placeholderImage = export const placeholderImage =
'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='; 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
...@@ -82,7 +82,7 @@ export default class LazyLoader { ...@@ -82,7 +82,7 @@ export default class LazyLoader {
} }
startIntersectionObserver = () => { startIntersectionObserver = () => {
this.throttledElementsInView = _.throttle(() => this.checkElementsInView(), 300); this.throttledElementsInView = throttle(() => this.checkElementsInView(), 300);
this.intersectionObserver = new IntersectionObserver(this.onIntersection, { this.intersectionObserver = new IntersectionObserver(this.onIntersection, {
rootMargin: `${SCROLL_THRESHOLD}px 0px`, rootMargin: `${SCROLL_THRESHOLD}px 0px`,
thresholds: 0.1, thresholds: 0.1,
...@@ -102,8 +102,8 @@ export default class LazyLoader { ...@@ -102,8 +102,8 @@ export default class LazyLoader {
}; };
startLegacyObserver() { startLegacyObserver() {
this.throttledScrollCheck = _.throttle(() => this.scrollCheck(), 300); this.throttledScrollCheck = throttle(() => this.scrollCheck(), 300);
this.debouncedElementsInView = _.debounce(() => this.checkElementsInView(), 300); this.debouncedElementsInView = debounce(() => this.checkElementsInView(), 300);
window.addEventListener('scroll', this.throttledScrollCheck); window.addEventListener('scroll', this.throttledScrollCheck);
window.addEventListener('resize', this.debouncedElementsInView); window.addEventListener('resize', this.debouncedElementsInView);
} }
......
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