|
|
@ -332,10 +332,9 @@ class Shuffle extends TinyEmitter {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* When new elements are added to the shuffle container, update the array of
|
|
|
|
* Combine the current items array with a new one and sort it by DOM order.
|
|
|
|
* items because that is the order `_layout` calls them.
|
|
|
|
|
|
|
|
* @param {ShuffleItem[]} items Items to track.
|
|
|
|
* @param {ShuffleItem[]} items Items to track.
|
|
|
|
* @return {Shuffle[]}
|
|
|
|
* @return {ShuffleItem[]}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
_mergeNewItems(items) {
|
|
|
|
_mergeNewItems(items) {
|
|
|
|
const children = Array.from(this.element.children);
|
|
|
|
const children = Array.from(this.element.children);
|
|
|
@ -855,24 +854,36 @@ class Shuffle extends TinyEmitter {
|
|
|
|
|
|
|
|
|
|
|
|
// Determine which items will go with the current filter.
|
|
|
|
// Determine which items will go with the current filter.
|
|
|
|
this._resetCols();
|
|
|
|
this._resetCols();
|
|
|
|
const newItemSet = this._filter(this.lastFilter, items);
|
|
|
|
|
|
|
|
const willBeVisible = this._mergeNewItems(newItemSet.visible);
|
|
|
|
const allItems = this._mergeNewItems(items);
|
|
|
|
const sortedVisibleItems = sorter(willBeVisible, this.lastSort);
|
|
|
|
const sortedItems = sorter(allItems, this.lastSort);
|
|
|
|
|
|
|
|
const allSortedItemsSet = this._filter(this.lastFilter, sortedItems);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isNewItem = item => items.includes(item);
|
|
|
|
|
|
|
|
const applyHiddenState = (item) => {
|
|
|
|
|
|
|
|
item.scale = ShuffleItem.Scale.HIDDEN;
|
|
|
|
|
|
|
|
item.isHidden = true;
|
|
|
|
|
|
|
|
item.applyCss(ShuffleItem.Css.HIDDEN.before);
|
|
|
|
|
|
|
|
item.applyCss(ShuffleItem.Css.HIDDEN.after);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Layout all items again so that new items get positions.
|
|
|
|
// Layout all items again so that new items get positions.
|
|
|
|
// Synchonously apply positions.
|
|
|
|
// Synchonously apply positions.
|
|
|
|
const itemPositions = this._getNextPositions(sortedVisibleItems);
|
|
|
|
const itemPositions = this._getNextPositions(allSortedItemsSet.visible);
|
|
|
|
sortedVisibleItems.forEach((item, i) => {
|
|
|
|
allSortedItemsSet.visible.forEach((item, i) => {
|
|
|
|
if (newItemSet.visible.includes(item)) {
|
|
|
|
if (isNewItem(item)) {
|
|
|
|
item.point = itemPositions[i];
|
|
|
|
item.point = itemPositions[i];
|
|
|
|
item.scale = ShuffleItem.Scale.HIDDEN;
|
|
|
|
applyHiddenState(item);
|
|
|
|
item.isHidden = true;
|
|
|
|
|
|
|
|
item.applyCss(ShuffleItem.Css.HIDDEN.before);
|
|
|
|
|
|
|
|
item.applyCss(ShuffleItem.Css.HIDDEN.after);
|
|
|
|
|
|
|
|
item.applyCss(this.getStylesForTransition(item, {}));
|
|
|
|
item.applyCss(this.getStylesForTransition(item, {}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
allSortedItemsSet.hidden.forEach((item) => {
|
|
|
|
|
|
|
|
if (isNewItem(item)) {
|
|
|
|
|
|
|
|
applyHiddenState(item);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Cause layout so that the styles above are applied.
|
|
|
|
// Cause layout so that the styles above are applied.
|
|
|
|
this.element.offsetWidth; // eslint-disable-line no-unused-expressions
|
|
|
|
this.element.offsetWidth; // eslint-disable-line no-unused-expressions
|
|
|
|
|
|
|
|
|
|
|
|