Rebuild with new rollup deps.

pull/220/head
Glen Cheney 6 years ago
parent 381eaadd2b
commit 29ee0fb6c9

261
dist/shuffle.js vendored

@ -4,12 +4,12 @@
(global.Shuffle = factory());
}(this, (function () { 'use strict';
function E () {
function E () {
// Keep this empty so it's easier to inherit from
// (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
}
}
E.prototype = {
E.prototype = {
on: function (name, callback, ctx) {
var e = this.e || (this.e = {});
@ -27,7 +27,6 @@ E.prototype = {
self.off(name, listener);
callback.apply(ctx, arguments);
}
listener._ = callback;
return this.on(name, listener, ctx);
},
@ -67,21 +66,21 @@ E.prototype = {
return this;
}
};
};
var tinyEmitter = E;
var tinyEmitter = E;
var proto = typeof Element !== 'undefined' ? Element.prototype : {};
var vendor = proto.matches
var proto = typeof Element !== 'undefined' ? Element.prototype : {};
var vendor = proto.matches
|| proto.matchesSelector
|| proto.webkitMatchesSelector
|| proto.mozMatchesSelector
|| proto.msMatchesSelector
|| proto.oMatchesSelector;
var matchesSelector = match;
var matchesSelector = match;
/**
/**
* Match `el` to `selector`.
*
* @param {Element} el
@ -90,7 +89,7 @@ var matchesSelector = match;
* @api public
*/
function match(el, selector) {
function match(el, selector) {
if (!el || el.nodeType !== 1) return false;
if (vendor) return vendor.call(el, selector);
var nodes = el.parentNode.querySelectorAll(selector);
@ -98,11 +97,11 @@ function match(el, selector) {
if (nodes[i] == el) return true;
}
return false;
}
}
var throttleit = throttle;
var throttleit = throttle;
/**
/**
* Returns a new function that, when invoked, invokes `func` at most once per `wait` milliseconds.
*
* @param {Function} func Function to wrap.
@ -110,7 +109,7 @@ var throttleit = throttle;
* @return {Function} A new function that wraps the `func` function passed in.
*/
function throttle (func, wait) {
function throttle (func, wait) {
var ctx, args, rtn, timeoutID; // caching
var last = 0;
@ -131,9 +130,9 @@ function throttle (func, wait) {
ctx = null;
args = null;
}
}
}
var arrayParallel = function parallel(fns, context, callback) {
var arrayParallel = function parallel(fns, context, callback) {
if (!callback) {
if (typeof context === 'function') {
callback = context;
@ -170,26 +169,26 @@ var arrayParallel = function parallel(fns, context, callback) {
if (!--pending) callback(null, results);
}
}
};
};
function noop() {}
function noop() {}
/**
/**
* Always returns a numeric value, given a value. Logic from jQuery's `isNumeric`.
* @param {*} value Possibly numeric value.
* @return {number} `value` or zero if `value` isn't numeric.
*/
function getNumber(value) {
function getNumber(value) {
return parseFloat(value) || 0;
}
}
var classCallCheck = function (instance, Constructor) {
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
};
var createClass = function () {
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
@ -205,17 +204,9 @@ var createClass = function () {
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
}();
var inherits = function (subClass, superClass) {
var inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
@ -229,27 +220,17 @@ var inherits = function (subClass, superClass) {
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
};
var possibleConstructorReturn = function (self, call) {
var possibleConstructorReturn = function (self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
};
var Point = function () {
var Point = function () {
/**
* Represents a coordinate pair.
* @param {number} [x=0] X.
@ -277,9 +258,9 @@ var Point = function () {
}
}]);
return Point;
}();
}();
var Rect = function () {
var Rect = function () {
/**
* Class for representing rectangular regions.
* https://github.com/google/closure-library/blob/master/closure/goog/math/rect.js
@ -323,18 +304,18 @@ var Rect = function () {
}
}]);
return Rect;
}();
}();
var Classes = {
var Classes = {
BASE: 'shuffle',
SHUFFLE_ITEM: 'shuffle-item',
VISIBLE: 'shuffle-item--visible',
HIDDEN: 'shuffle-item--hidden'
};
};
var id = 0;
var id = 0;
var ShuffleItem = function () {
var ShuffleItem = function () {
function ShuffleItem(element) {
classCallCheck(this, ShuffleItem);
@ -417,9 +398,9 @@ var ShuffleItem = function () {
}
}]);
return ShuffleItem;
}();
}();
ShuffleItem.Css = {
ShuffleItem.Css = {
INITIAL: {
position: 'absolute',
top: 0,
@ -445,26 +426,26 @@ ShuffleItem.Css = {
transitionDelay: ''
}
}
};
};
ShuffleItem.Scale = {
ShuffleItem.Scale = {
VISIBLE: 1,
HIDDEN: 0.001
};
};
var element = document.body || document.documentElement;
var e = document.createElement('div');
e.style.cssText = 'width:10px;padding:2px;box-sizing:border-box;';
element.appendChild(e);
var element = document.body || document.documentElement;
var e = document.createElement('div');
e.style.cssText = 'width:10px;padding:2px;box-sizing:border-box;';
element.appendChild(e);
var _window$getComputedSt = window.getComputedStyle(e, null);
var width = _window$getComputedSt.width;
var _window$getComputedSt = window.getComputedStyle(e, null),
width = _window$getComputedSt.width;
var ret = width === '10px';
var ret = width === '10px';
element.removeChild(e);
element.removeChild(e);
/**
/**
* Retrieve the computed style for an element, parsed as a float.
* @param {Element} element Element to get style for.
* @param {string} style Style property.
@ -474,7 +455,7 @@ element.removeChild(e);
* will return 'auto' when the element doesn't have margins instead of
* the computed style.
*/
function getNumberStyle(element, style) {
function getNumberStyle(element, style) {
var styles = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : window.getComputedStyle(element, null);
var value = getNumber(styles[style]);
@ -487,16 +468,16 @@ function getNumberStyle(element, style) {
}
return value;
}
}
/**
/**
* Fisher-Yates shuffle.
* http://stackoverflow.com/a/962890/373422
* https://bost.ocks.org/mike/shuffle/
* @param {Array} array Array to shuffle.
* @return {Array} Randomly sorted array.
*/
function randomize(array) {
function randomize(array) {
var n = array.length;
while (n) {
@ -508,9 +489,9 @@ function randomize(array) {
}
return array;
}
}
var defaults$1 = {
var defaults$1 = {
// Use array.reverse() to reverse the results
reverse: false,
@ -526,10 +507,10 @@ var defaults$1 = {
// Determines which property of each item in the array is passed to the
// sorting method.
key: 'element'
};
};
// You can return `undefined` from the `by` function to revert to DOM order.
function sorter(arr, options) {
// You can return `undefined` from the `by` function to revert to DOM order.
function sorter(arr, options) {
var opts = Object.assign({}, defaults$1, options);
var original = Array.from(arr);
var revert = false;
@ -584,18 +565,18 @@ function sorter(arr, options) {
}
return arr;
}
}
var transitions = {};
var eventName = 'transitionend';
var count = 0;
var transitions = {};
var eventName = 'transitionend';
var count = 0;
function uniqueId() {
function uniqueId() {
count += 1;
return eventName + count;
}
}
function cancelTransitionEnd(id) {
function cancelTransitionEnd(id) {
if (transitions[id]) {
transitions[id].element.removeEventListener(eventName, transitions[id].listener);
transitions[id] = null;
@ -603,9 +584,9 @@ function cancelTransitionEnd(id) {
}
return false;
}
}
function onTransitionEnd(element, callback) {
function onTransitionEnd(element, callback) {
var id = uniqueId();
var listener = function listener(evt) {
if (evt.currentTarget === evt.target) {
@ -619,17 +600,17 @@ function onTransitionEnd(element, callback) {
transitions[id] = { element: element, listener: listener };
return id;
}
}
function arrayMax(array) {
function arrayMax(array) {
return Math.max.apply(Math, array); // eslint-disable-line prefer-spread
}
}
function arrayMin(array) {
function arrayMin(array) {
return Math.min.apply(Math, array); // eslint-disable-line prefer-spread
}
}
/**
/**
* Determine the number of columns an items spans.
* @param {number} itemWidth Width of the item.
* @param {number} columnWidth Width of the column (includes gutter).
@ -637,7 +618,7 @@ function arrayMin(array) {
* @param {number} threshold A buffer value for the size of the column to fit.
* @return {number}
*/
function getColumnSpan(itemWidth, columnWidth, columns, threshold) {
function getColumnSpan(itemWidth, columnWidth, columns, threshold) {
var columnSpan = itemWidth / columnWidth;
// If the difference between the rounded column span number and the
@ -650,15 +631,15 @@ function getColumnSpan(itemWidth, columnWidth, columns, threshold) {
// Ensure the column span is not more than the amount of columns in the whole layout.
return Math.min(Math.ceil(columnSpan), columns);
}
}
/**
/**
* Retrieves the column set to use for placement.
* @param {number} columnSpan The number of columns this current item spans.
* @param {number} columns The total columns in the grid.
* @return {Array.<number>} An array of numbers represeting the column set.
*/
function getAvailablePositions(positions, columnSpan, columns) {
function getAvailablePositions(positions, columnSpan, columns) {
// The item spans only one column.
if (columnSpan === 1) {
return positions;
@ -695,9 +676,9 @@ function getAvailablePositions(positions, columnSpan, columns) {
}
return available;
}
}
/**
/**
* Find index of short column, the first from the left where this item will go.
*
* @param {Array.<number>} positions The array to search for the smallest number.
@ -705,7 +686,7 @@ function getAvailablePositions(positions, columnSpan, columns) {
* is a percentage of the width.
* @return {number} Index of the short column.
*/
function getShortColumn(positions, buffer) {
function getShortColumn(positions, buffer) {
var minPosition = arrayMin(positions);
for (var i = 0, len = positions.length; i < len; i++) {
if (positions[i] >= minPosition - buffer && positions[i] <= minPosition + buffer) {
@ -714,9 +695,9 @@ function getShortColumn(positions, buffer) {
}
return 0;
}
}
/**
/**
* Determine the location of the next item, based on its size.
* @param {Object} itemSize Object with width and height.
* @param {Array.<number>} positions Positions of the other current items.
@ -726,7 +707,7 @@ function getShortColumn(positions, buffer) {
* @param {number} buffer Vertical buffer for the height of items.
* @return {Point}
*/
function getItemPosition(_ref) {
function getItemPosition(_ref) {
var itemSize = _ref.itemSize,
positions = _ref.positions,
gridSize = _ref.gridSize,
@ -750,9 +731,9 @@ function getItemPosition(_ref) {
}
return point;
}
}
/**
/**
* This method attempts to center items. This method could potentially be slow
* with a large number of items because it must place items, then check every
* previous item to ensure there is no overlap.
@ -760,7 +741,7 @@ function getItemPosition(_ref) {
* @param {number} containerWidth Width of the containing element.
* @return {Array.<Point>}
*/
function getCenteredPositions(itemRects, containerWidth) {
function getCenteredPositions(itemRects, containerWidth) {
var rowMap = {};
// Populate rows by their offset because items could jump between rows like:
@ -849,28 +830,28 @@ function getCenteredPositions(itemRects, containerWidth) {
}).map(function (itemRect) {
return new Point(itemRect.left, itemRect.top);
});
}
}
/**
/**
* Hyphenates a javascript style string to a css one. For example:
* MozBoxSizing -> -moz-box-sizing.
* @param {string} str The string to hyphenate.
* @return {string} The hyphenated string.
*/
function hyphenate(str) {
function hyphenate(str) {
return str.replace(/([A-Z])/g, function (str, m1) {
return "-" + m1.toLowerCase();
});
}
}
function arrayUnique(x) {
function arrayUnique(x) {
return Array.from(new Set(x));
}
}
// Used for unique instance variables
var id$1 = 0;
// Used for unique instance variables
var id$1 = 0;
var Shuffle = function (_TinyEmitter) {
var Shuffle = function (_TinyEmitter) {
inherits(Shuffle, _TinyEmitter);
/**
@ -2165,30 +2146,30 @@ var Shuffle = function (_TinyEmitter) {
}
}]);
return Shuffle;
}(tinyEmitter);
}(tinyEmitter);
Shuffle.ShuffleItem = ShuffleItem;
Shuffle.ShuffleItem = ShuffleItem;
Shuffle.ALL_ITEMS = 'all';
Shuffle.FILTER_ATTRIBUTE_KEY = 'groups';
Shuffle.ALL_ITEMS = 'all';
Shuffle.FILTER_ATTRIBUTE_KEY = 'groups';
/** @enum {string} */
Shuffle.EventType = {
/** @enum {string} */
Shuffle.EventType = {
LAYOUT: 'shuffle:layout',
REMOVED: 'shuffle:removed'
};
};
/** @enum {string} */
Shuffle.Classes = Classes;
/** @enum {string} */
Shuffle.Classes = Classes;
/** @enum {string} */
Shuffle.FilterMode = {
/** @enum {string} */
Shuffle.FilterMode = {
ANY: 'any',
ALL: 'all'
};
};
// Overrideable options
Shuffle.options = {
// Overrideable options
Shuffle.options = {
// Initial filter group.
group: Shuffle.ALL_ITEMS,
@ -2256,19 +2237,19 @@ Shuffle.options = {
// Whether to round pixel values used in translate(x, y). This usually avoids
// blurriness.
roundTransforms: true
};
};
Shuffle.Point = Point;
Shuffle.Rect = Rect;
Shuffle.Point = Point;
Shuffle.Rect = Rect;
// Expose for testing. Hack at your own risk.
Shuffle.__sorter = sorter;
Shuffle.__getColumnSpan = getColumnSpan;
Shuffle.__getAvailablePositions = getAvailablePositions;
Shuffle.__getShortColumn = getShortColumn;
Shuffle.__getCenteredPositions = getCenteredPositions;
// Expose for testing. Hack at your own risk.
Shuffle.__sorter = sorter;
Shuffle.__getColumnSpan = getColumnSpan;
Shuffle.__getAvailablePositions = getAvailablePositions;
Shuffle.__getShortColumn = getShortColumn;
Shuffle.__getCenteredPositions = getCenteredPositions;
return Shuffle;
return Shuffle;
})));
//# sourceMappingURL=shuffle.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

261
docs/dist/shuffle.js vendored

@ -4,12 +4,12 @@
(global.Shuffle = factory());
}(this, (function () { 'use strict';
function E () {
function E () {
// Keep this empty so it's easier to inherit from
// (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
}
}
E.prototype = {
E.prototype = {
on: function (name, callback, ctx) {
var e = this.e || (this.e = {});
@ -27,7 +27,6 @@ E.prototype = {
self.off(name, listener);
callback.apply(ctx, arguments);
}
listener._ = callback;
return this.on(name, listener, ctx);
},
@ -67,21 +66,21 @@ E.prototype = {
return this;
}
};
};
var tinyEmitter = E;
var tinyEmitter = E;
var proto = typeof Element !== 'undefined' ? Element.prototype : {};
var vendor = proto.matches
var proto = typeof Element !== 'undefined' ? Element.prototype : {};
var vendor = proto.matches
|| proto.matchesSelector
|| proto.webkitMatchesSelector
|| proto.mozMatchesSelector
|| proto.msMatchesSelector
|| proto.oMatchesSelector;
var matchesSelector = match;
var matchesSelector = match;
/**
/**
* Match `el` to `selector`.
*
* @param {Element} el
@ -90,7 +89,7 @@ var matchesSelector = match;
* @api public
*/
function match(el, selector) {
function match(el, selector) {
if (!el || el.nodeType !== 1) return false;
if (vendor) return vendor.call(el, selector);
var nodes = el.parentNode.querySelectorAll(selector);
@ -98,11 +97,11 @@ function match(el, selector) {
if (nodes[i] == el) return true;
}
return false;
}
}
var throttleit = throttle;
var throttleit = throttle;
/**
/**
* Returns a new function that, when invoked, invokes `func` at most once per `wait` milliseconds.
*
* @param {Function} func Function to wrap.
@ -110,7 +109,7 @@ var throttleit = throttle;
* @return {Function} A new function that wraps the `func` function passed in.
*/
function throttle (func, wait) {
function throttle (func, wait) {
var ctx, args, rtn, timeoutID; // caching
var last = 0;
@ -131,9 +130,9 @@ function throttle (func, wait) {
ctx = null;
args = null;
}
}
}
var arrayParallel = function parallel(fns, context, callback) {
var arrayParallel = function parallel(fns, context, callback) {
if (!callback) {
if (typeof context === 'function') {
callback = context;
@ -170,26 +169,26 @@ var arrayParallel = function parallel(fns, context, callback) {
if (!--pending) callback(null, results);
}
}
};
};
function noop() {}
function noop() {}
/**
/**
* Always returns a numeric value, given a value. Logic from jQuery's `isNumeric`.
* @param {*} value Possibly numeric value.
* @return {number} `value` or zero if `value` isn't numeric.
*/
function getNumber(value) {
function getNumber(value) {
return parseFloat(value) || 0;
}
}
var classCallCheck = function (instance, Constructor) {
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
};
var createClass = function () {
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
@ -205,17 +204,9 @@ var createClass = function () {
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
}();
var inherits = function (subClass, superClass) {
var inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
@ -229,27 +220,17 @@ var inherits = function (subClass, superClass) {
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
};
var possibleConstructorReturn = function (self, call) {
var possibleConstructorReturn = function (self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
};
var Point = function () {
var Point = function () {
/**
* Represents a coordinate pair.
* @param {number} [x=0] X.
@ -277,9 +258,9 @@ var Point = function () {
}
}]);
return Point;
}();
}();
var Rect = function () {
var Rect = function () {
/**
* Class for representing rectangular regions.
* https://github.com/google/closure-library/blob/master/closure/goog/math/rect.js
@ -323,18 +304,18 @@ var Rect = function () {
}
}]);
return Rect;
}();
}();
var Classes = {
var Classes = {
BASE: 'shuffle',
SHUFFLE_ITEM: 'shuffle-item',
VISIBLE: 'shuffle-item--visible',
HIDDEN: 'shuffle-item--hidden'
};
};
var id = 0;
var id = 0;
var ShuffleItem = function () {
var ShuffleItem = function () {
function ShuffleItem(element) {
classCallCheck(this, ShuffleItem);
@ -417,9 +398,9 @@ var ShuffleItem = function () {
}
}]);
return ShuffleItem;
}();
}();
ShuffleItem.Css = {
ShuffleItem.Css = {
INITIAL: {
position: 'absolute',
top: 0,
@ -445,26 +426,26 @@ ShuffleItem.Css = {
transitionDelay: ''
}
}
};
};
ShuffleItem.Scale = {
ShuffleItem.Scale = {
VISIBLE: 1,
HIDDEN: 0.001
};
};
var element = document.body || document.documentElement;
var e = document.createElement('div');
e.style.cssText = 'width:10px;padding:2px;box-sizing:border-box;';
element.appendChild(e);
var element = document.body || document.documentElement;
var e = document.createElement('div');
e.style.cssText = 'width:10px;padding:2px;box-sizing:border-box;';
element.appendChild(e);
var _window$getComputedSt = window.getComputedStyle(e, null);
var width = _window$getComputedSt.width;
var _window$getComputedSt = window.getComputedStyle(e, null),
width = _window$getComputedSt.width;
var ret = width === '10px';
var ret = width === '10px';
element.removeChild(e);
element.removeChild(e);
/**
/**
* Retrieve the computed style for an element, parsed as a float.
* @param {Element} element Element to get style for.
* @param {string} style Style property.
@ -474,7 +455,7 @@ element.removeChild(e);
* will return 'auto' when the element doesn't have margins instead of
* the computed style.
*/
function getNumberStyle(element, style) {
function getNumberStyle(element, style) {
var styles = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : window.getComputedStyle(element, null);
var value = getNumber(styles[style]);
@ -487,16 +468,16 @@ function getNumberStyle(element, style) {
}
return value;
}
}
/**
/**
* Fisher-Yates shuffle.
* http://stackoverflow.com/a/962890/373422
* https://bost.ocks.org/mike/shuffle/
* @param {Array} array Array to shuffle.
* @return {Array} Randomly sorted array.
*/
function randomize(array) {
function randomize(array) {
var n = array.length;
while (n) {
@ -508,9 +489,9 @@ function randomize(array) {
}
return array;
}
}
var defaults$1 = {
var defaults$1 = {
// Use array.reverse() to reverse the results
reverse: false,
@ -526,10 +507,10 @@ var defaults$1 = {
// Determines which property of each item in the array is passed to the
// sorting method.
key: 'element'
};
};
// You can return `undefined` from the `by` function to revert to DOM order.
function sorter(arr, options) {
// You can return `undefined` from the `by` function to revert to DOM order.
function sorter(arr, options) {
var opts = Object.assign({}, defaults$1, options);
var original = Array.from(arr);
var revert = false;
@ -584,18 +565,18 @@ function sorter(arr, options) {
}
return arr;
}
}
var transitions = {};
var eventName = 'transitionend';
var count = 0;
var transitions = {};
var eventName = 'transitionend';
var count = 0;
function uniqueId() {
function uniqueId() {
count += 1;
return eventName + count;
}
}
function cancelTransitionEnd(id) {
function cancelTransitionEnd(id) {
if (transitions[id]) {
transitions[id].element.removeEventListener(eventName, transitions[id].listener);
transitions[id] = null;
@ -603,9 +584,9 @@ function cancelTransitionEnd(id) {
}
return false;
}
}
function onTransitionEnd(element, callback) {
function onTransitionEnd(element, callback) {
var id = uniqueId();
var listener = function listener(evt) {
if (evt.currentTarget === evt.target) {
@ -619,17 +600,17 @@ function onTransitionEnd(element, callback) {
transitions[id] = { element: element, listener: listener };
return id;
}
}
function arrayMax(array) {
function arrayMax(array) {
return Math.max.apply(Math, array); // eslint-disable-line prefer-spread
}
}
function arrayMin(array) {
function arrayMin(array) {
return Math.min.apply(Math, array); // eslint-disable-line prefer-spread
}
}
/**
/**
* Determine the number of columns an items spans.
* @param {number} itemWidth Width of the item.
* @param {number} columnWidth Width of the column (includes gutter).
@ -637,7 +618,7 @@ function arrayMin(array) {
* @param {number} threshold A buffer value for the size of the column to fit.
* @return {number}
*/
function getColumnSpan(itemWidth, columnWidth, columns, threshold) {
function getColumnSpan(itemWidth, columnWidth, columns, threshold) {
var columnSpan = itemWidth / columnWidth;
// If the difference between the rounded column span number and the
@ -650,15 +631,15 @@ function getColumnSpan(itemWidth, columnWidth, columns, threshold) {
// Ensure the column span is not more than the amount of columns in the whole layout.
return Math.min(Math.ceil(columnSpan), columns);
}
}
/**
/**
* Retrieves the column set to use for placement.
* @param {number} columnSpan The number of columns this current item spans.
* @param {number} columns The total columns in the grid.
* @return {Array.<number>} An array of numbers represeting the column set.
*/
function getAvailablePositions(positions, columnSpan, columns) {
function getAvailablePositions(positions, columnSpan, columns) {
// The item spans only one column.
if (columnSpan === 1) {
return positions;
@ -695,9 +676,9 @@ function getAvailablePositions(positions, columnSpan, columns) {
}
return available;
}
}
/**
/**
* Find index of short column, the first from the left where this item will go.
*
* @param {Array.<number>} positions The array to search for the smallest number.
@ -705,7 +686,7 @@ function getAvailablePositions(positions, columnSpan, columns) {
* is a percentage of the width.
* @return {number} Index of the short column.
*/
function getShortColumn(positions, buffer) {
function getShortColumn(positions, buffer) {
var minPosition = arrayMin(positions);
for (var i = 0, len = positions.length; i < len; i++) {
if (positions[i] >= minPosition - buffer && positions[i] <= minPosition + buffer) {
@ -714,9 +695,9 @@ function getShortColumn(positions, buffer) {
}
return 0;
}
}
/**
/**
* Determine the location of the next item, based on its size.
* @param {Object} itemSize Object with width and height.
* @param {Array.<number>} positions Positions of the other current items.
@ -726,7 +707,7 @@ function getShortColumn(positions, buffer) {
* @param {number} buffer Vertical buffer for the height of items.
* @return {Point}
*/
function getItemPosition(_ref) {
function getItemPosition(_ref) {
var itemSize = _ref.itemSize,
positions = _ref.positions,
gridSize = _ref.gridSize,
@ -750,9 +731,9 @@ function getItemPosition(_ref) {
}
return point;
}
}
/**
/**
* This method attempts to center items. This method could potentially be slow
* with a large number of items because it must place items, then check every
* previous item to ensure there is no overlap.
@ -760,7 +741,7 @@ function getItemPosition(_ref) {
* @param {number} containerWidth Width of the containing element.
* @return {Array.<Point>}
*/
function getCenteredPositions(itemRects, containerWidth) {
function getCenteredPositions(itemRects, containerWidth) {
var rowMap = {};
// Populate rows by their offset because items could jump between rows like:
@ -849,28 +830,28 @@ function getCenteredPositions(itemRects, containerWidth) {
}).map(function (itemRect) {
return new Point(itemRect.left, itemRect.top);
});
}
}
/**
/**
* Hyphenates a javascript style string to a css one. For example:
* MozBoxSizing -> -moz-box-sizing.
* @param {string} str The string to hyphenate.
* @return {string} The hyphenated string.
*/
function hyphenate(str) {
function hyphenate(str) {
return str.replace(/([A-Z])/g, function (str, m1) {
return "-" + m1.toLowerCase();
});
}
}
function arrayUnique(x) {
function arrayUnique(x) {
return Array.from(new Set(x));
}
}
// Used for unique instance variables
var id$1 = 0;
// Used for unique instance variables
var id$1 = 0;
var Shuffle = function (_TinyEmitter) {
var Shuffle = function (_TinyEmitter) {
inherits(Shuffle, _TinyEmitter);
/**
@ -2165,30 +2146,30 @@ var Shuffle = function (_TinyEmitter) {
}
}]);
return Shuffle;
}(tinyEmitter);
}(tinyEmitter);
Shuffle.ShuffleItem = ShuffleItem;
Shuffle.ShuffleItem = ShuffleItem;
Shuffle.ALL_ITEMS = 'all';
Shuffle.FILTER_ATTRIBUTE_KEY = 'groups';
Shuffle.ALL_ITEMS = 'all';
Shuffle.FILTER_ATTRIBUTE_KEY = 'groups';
/** @enum {string} */
Shuffle.EventType = {
/** @enum {string} */
Shuffle.EventType = {
LAYOUT: 'shuffle:layout',
REMOVED: 'shuffle:removed'
};
};
/** @enum {string} */
Shuffle.Classes = Classes;
/** @enum {string} */
Shuffle.Classes = Classes;
/** @enum {string} */
Shuffle.FilterMode = {
/** @enum {string} */
Shuffle.FilterMode = {
ANY: 'any',
ALL: 'all'
};
};
// Overrideable options
Shuffle.options = {
// Overrideable options
Shuffle.options = {
// Initial filter group.
group: Shuffle.ALL_ITEMS,
@ -2256,19 +2237,19 @@ Shuffle.options = {
// Whether to round pixel values used in translate(x, y). This usually avoids
// blurriness.
roundTransforms: true
};
};
Shuffle.Point = Point;
Shuffle.Rect = Rect;
Shuffle.Point = Point;
Shuffle.Rect = Rect;
// Expose for testing. Hack at your own risk.
Shuffle.__sorter = sorter;
Shuffle.__getColumnSpan = getColumnSpan;
Shuffle.__getAvailablePositions = getAvailablePositions;
Shuffle.__getShortColumn = getShortColumn;
Shuffle.__getCenteredPositions = getCenteredPositions;
// Expose for testing. Hack at your own risk.
Shuffle.__sorter = sorter;
Shuffle.__getColumnSpan = getColumnSpan;
Shuffle.__getAvailablePositions = getAvailablePositions;
Shuffle.__getShortColumn = getShortColumn;
Shuffle.__getCenteredPositions = getCenteredPositions;
return Shuffle;
return Shuffle;
})));
//# sourceMappingURL=shuffle.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -70,6 +70,6 @@
"rollup-plugin-commonjs": "^9.1.0",
"rollup-plugin-node-resolve": "^3.0.2",
"rollup-plugin-uglify": "^3.0.0",
"sinon": "^5.0.0"
"sinon": "^4.4.0"
}
}

Loading…
Cancel
Save