Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
debounceDraw() {
this.log && console.info('debounce', this)
this._debounceDraw = Debouncer.debounce(
this._debounceDraw, // initially undefined
timeOut.after(10),
() => {
this.log && console.info('debounced', this)
const isDrawn = this.draw();
this._isDrawn = !!isDrawn;
this.dispatchEvent(new CustomEvent('multi-drawn', {detail: {}, bubbles: true, composed: true}));
});
}
shiftPackery() {
if (!this.usePackery) {
return;
}
// Called when anything in #panels receives a click or tap event.
// There's probably a lot of room to optimize this and not call
// this routine for every single click,
// but this was just the easiest way to ensure that mutations
// caused by clicks are caught, because those mutations might
// have changed the vertical size of the panel.
this._shiftPackeryDebounce = Debouncer.debounce(
this._shiftPackeryDebounce,
timeOut.after(100), () => {
if (this._packeryInitialized) {
// See http://packery.metafizzy.co/methods.html#shiftlayout for more details
this._packery.shiftLayout();
}
}
);
}
_autoFetch() {
// Reset the page if the query changes
if (
this.$.nxResource.params &&
this.query &&
this.query.length === 0 &&
this.query !== this.$.nxResource.params.query
) {
this.page = 1;
}
if (this.auto && (this.query || this.provider)) {
// debounce in case of multiple param changes
this._debouncer = Debouncer.debounce(this._debouncer, timeOut.after(this.autoDelay), () => this.fetch());
}
}
_routeChanged(route) {
if (this.usePackery) {
// This is a hack to fix packery when the viewport size is changed
// when the workspace is not visible.
if (route.path === this.parentNode.route) {
this._fixPackeryDebounce = Debouncer.debounce(
this._fixPackeryDebounce,
timeOut.after(10),
this._fixPackery.bind(this)
);
}
}
}
_autoFetch() {
if (this.auto) {
// debounce in case of multiple param changes
this._debouncer = Debouncer.debounce(this._debouncer, timeOut.after(this.autoDelay), () => this.fetch());
}
}
}
_copyLink(e) {
const shareButton = e.currentTarget;
const link = shareButton.previousElementSibling;
// Select Link
link.$.paperInput.$.nativeInput.select();
if (!window.document.execCommand('copy')) {
return;
}
shareButton._debouncer = Debouncer.debounce(shareButton._debouncer, timeOut.after(2000), () => {
// Unselect Link
link.$.paperInput.$.nativeInput.setSelectionRange(0, 0);
link.$.paperInput.blur();
shareButton.set('icon', 'link');
shareButton.classList.remove('selected');
});
shareButton.set('icon', 'check');
shareButton.classList.add('selected');
this.fire('notify', { message: this.i18n('shareButton.operation.copied'), duration: 2000 });
}
}
this._panelMutationObserver = new MutationObserver(() => {
this._handleMutationDebounce = Debouncer.debounce(
this._handleMutationDebounce,
timeOut.after(150),
this._debouncedMutationHandler.bind(this)
);
});
redraw() {
if (this._chartWrapper == null || this._data == null) return;
this._chartWrapper.setDataTable(this._data);
this._chartWrapper.setOptions(this.options || {});
this._setDrawn(false);
this._redrawDebouncer = Debouncer.debounce(this._redrawDebouncer, timeOut.after(5), () => {
this._chartWrapper.draw();
});
}
applyPackery() {
this._applyPackeryDebounce = Debouncer.debounce(
this._applyPackeryDebounce,
timeOut.after(10), () => {
if (this._packeryInitialized) {
this._packery.layout();
}
}
);
}
_scrollChanged() {
this._debouncer = Debouncer.debounce(
this._debouncer, timeOut.after(this.scrollThrottle > 0 ? this.scrollThrottle : 1),
() => this._fetchRange(this.$.list.firstVisibleIndex, this.$.list.lastVisibleIndex),
);
},