Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_observeSelectedValues() {
this._debounceSelect = Debouncer.debounce(
this._debounceSelect, // initially undefined
microTask,
() => {
this.log && console.log('brush selection', this.selectedValues);
this.dispatchEvent(new CustomEvent('multi-select', {
detail: {
isRange: this.isRange,
selection: this.selectedValues
},
bubbles: true,
composed: true
}));
});
}
debounceDraw() {
this._debounceDraw = Debouncer.debounce(
this._debounceDraw, // initially undefined
timeOut.after(10),
() => {
this.draw(this._shaped);
// this._isDrawn = true;
});
}
_itemChanged(item, visible) {
if (visible) {
this._itemChangeDebouncer = Debouncer.debounce(this._itemChangeDebouncer,
microTask, () => {
// The item description contains escaped HTML (e.g. "<br>"), so we need to
// unescape it ("<br>") and set it as innerHTML.
let text = item ? item.description : '';
this.$.desc.innerHTML = this._unescapeText(text);
// Reset the select menus.
this.$.quantitySelect.value = '1';
this.$.sizeSelect.value = 'M';
this.dispatchEvent(new CustomEvent('change-section', {
bubbles: true, composed: true, detail: {
category: item ? item.category : '',
title: item ? item.title : '',
description: item ? item.description.substring(0, 100) : '',
image: item ? this.baseURI + item.image : ''
_updateContent() {
this.__renderDebouncer = Debouncer.debounce(
this.__renderDebouncer, idlePeriod,
() => {
this._clearContent();
this._render();
},
);
// enqueuing is needed for testing, as it allows content to be stamped on flush
enqueueDebouncer(this.__renderDebouncer);
}
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();
}
}
);
}
_layout(e) {
if (e && e.type && e.composedPath().find((el) => el.id === 'reparent' || el.id === 'dropdownButton')) {
return; // skip events from within reparented actions
}
this.__layoutDebouncer = Debouncer.debounce(this.__layoutDebouncer, microTask, () => {
let els = this._getDropdownElements();
/**
* XXX: We're using this.contentWidth instead of this.scrollWidth because it takes too much time to be
* updated on polyfilled browsers (Firex and Edge), leading to an empty menu if there's a single element
* that doesn't fit on the menu.
*/
while (els.length && this.contentWidth <= this.clientWidth) {
this._moveToMenu(els.shift());
}
if (!els.length) {
this.$.dropdownButton.hidden = true;
}
// let's move any element in the menu to the "dropdown" slot if it doesn't fit
els = this._getMenuElements();
while (els.length && this.contentWidth + this.$.dropdownButton.offsetWidth > this.clientWidth) {
this._moveToDropdown(els.pop());
_debounce: function(name, cb, asyncModule) {
if (IS_V2) {
this._debouncers = this._debouncers || {};
this._debouncers[name] = Debouncer.debounce(
this._debouncers[name], asyncModule, cb.bind(this));
enqueueDebouncer(this._debouncers[name]);
} else {
addDebouncer(this.debounce(name, cb));
}
},
applyPackery() {
this._applyPackeryDebounce = Debouncer.debounce(
this._applyPackeryDebounce,
timeOut.after(10), () => {
if (this._packeryInitialized) {
this._packery.layout();
}
}
);
}
_debounce: function(name, cb, asyncModule) {
this._debouncers = this._debouncers || {};
this._debouncers[name] =
Debouncer.debounce(this._debouncers[name], asyncModule, cb.bind(this));
enqueueDebouncer(this._debouncers[name]);
},