From a56ccb3cd50615e3e8baebd1f260a860a2d0813f Mon Sep 17 00:00:00 2001 From: Glen Cheney Date: Sun, 9 Apr 2017 22:44:54 -0700 Subject: [PATCH] Replace webpack with rollup (#138) --- .babelrc | 3 +- css/style.css | 8 - dist/shuffle.js | 3427 +++++++++++++++++------------------- dist/shuffle.js.map | 2 +- dist/shuffle.min.js | 4 +- dist/shuffle.min.js.map | 2 +- gulp/config.js | 61 +- gulp/tasks/compile.js | 31 - gulp/tasks/scripts.js | 11 + gulp/tasks/set-watching.js | 4 +- gulp/tasks/test.js | 2 - gulpfile.js | 2 +- package.json | 14 +- src/array-max.js | 3 + src/array-min.js | 3 + src/computed-size.js | 1 - src/get-number-style.js | 2 - src/get-number.js | 2 - src/index.js | 1 - src/layout.js | 10 +- src/on-transition-end.js | 2 - src/point.js | 2 - src/shuffle.js | 7 +- src/sorter.js | 2 - webpack.config.js | 29 - webpack.config.min.js | 41 - 26 files changed, 1682 insertions(+), 1994 deletions(-) delete mode 100644 gulp/tasks/compile.js create mode 100644 gulp/tasks/scripts.js create mode 100644 src/array-max.js create mode 100644 src/array-min.js delete mode 100644 src/index.js delete mode 100644 webpack.config.js delete mode 100644 webpack.config.min.js diff --git a/.babelrc b/.babelrc index 9897749..38aa47a 100644 --- a/.babelrc +++ b/.babelrc @@ -1,5 +1,6 @@ { "presets": [ ["es2015", { "modules": false }] - ] + ], + "plugins": ["external-helpers"] } diff --git a/css/style.css b/css/style.css index 71ac92f..3409408 100644 --- a/css/style.css +++ b/css/style.css @@ -1148,10 +1148,6 @@ input.faq-search { color: #95A5A6; -webkit-transition: .15s; transition: .15s; } - input.faq-search::-moz-placeholder { - color: #95A5A6; - -webkit-transition: .15s; - transition: .15s; } input.faq-search:-ms-input-placeholder { color: #95A5A6; -webkit-transition: .15s; @@ -1166,8 +1162,6 @@ input.faq-search { border-color: #5D6D77; } input.faq-search:hover::-webkit-input-placeholder { color: #5D6D77; } - input.faq-search:hover::-moz-placeholder { - color: #5D6D77; } input.faq-search:hover:-ms-input-placeholder { color: #5D6D77; } input.faq-search:hover::placeholder { @@ -1178,8 +1172,6 @@ input.faq-search { border-color: #27AE60; } input.faq-search:focus::-webkit-input-placeholder { color: #27AE60; } - input.faq-search:focus::-moz-placeholder { - color: #27AE60; } input.faq-search:focus:-ms-input-placeholder { color: #27AE60; } input.faq-search:focus::placeholder { diff --git a/dist/shuffle.js b/dist/shuffle.js index a630152..e42db75 100644 --- a/dist/shuffle.js +++ b/dist/shuffle.js @@ -1,160 +1,170 @@ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(); - else if(typeof define === 'function' && define.amd) - define([], factory); - else if(typeof exports === 'object') - exports["shuffle"] = factory(); - else - root["shuffle"] = factory(); -})(this, function() { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) -/******/ return installedModules[moduleId].exports; -/******/ -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // identity function for calling harmony imports with the correct context -/******/ __webpack_require__.i = function(value) { return value; }; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { -/******/ configurable: false, -/******/ enumerable: true, -/******/ get: getter -/******/ }); -/******/ } -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 17); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__get_number__ = __webpack_require__(2); +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global.shuffle = factory()); +}(this, (function () { 'use strict'; +// Polyfill for creating CustomEvents on IE9/10/11 +// code pulled from: +// https://github.com/d4tocchini/customevent-polyfill +// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent#Polyfill +try { + var ce = new window.CustomEvent('test'); + ce.preventDefault(); + if (ce.defaultPrevented !== true) { + // IE has problems with .preventDefault() on custom events + // http://stackoverflow.com/questions/23349191 + throw new Error('Could not prevent default'); + } +} catch(e) { + var CustomEvent$1 = function(event, params) { + var evt, origPrevent; + params = params || { + bubbles: false, + cancelable: false, + detail: undefined + }; -/** - * Represents a coordinate pair. - * @param {number} [x=0] X. - * @param {number} [y=0] Y. - */ -var Point = function Point(x, y) { - this.x = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__get_number__["a" /* default */])(x); - this.y = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__get_number__["a" /* default */])(y); -}; + evt = document.createEvent("CustomEvent"); + evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); + origPrevent = evt.preventDefault; + evt.preventDefault = function () { + origPrevent.call(this); + try { + Object.defineProperty(this, 'defaultPrevented', { + get: function () { + return true; + } + }); + } catch(e) { + this.defaultPrevented = true; + } + }; + return evt; + }; + + CustomEvent$1.prototype = window.Event.prototype; + window.CustomEvent = CustomEvent$1; // expose definition to window +} + +var proto = Element.prototype; +var vendor = proto.matches + || proto.matchesSelector + || proto.webkitMatchesSelector + || proto.mozMatchesSelector + || proto.msMatchesSelector + || proto.oMatchesSelector; + +var index = match; /** - * Whether two points are equal. - * @param {Point} a Point A. - * @param {Point} b Point B. - * @return {boolean} + * Match `el` to `selector`. + * + * @param {Element} el + * @param {String} selector + * @return {Boolean} + * @api public */ -Point.equals = function (a, b) { - return a.x === b.x && a.y === b.y; -}; -/* harmony default export */ __webpack_exports__["a"] = Point; +function match(el, selector) { + if (vendor) return vendor.call(el, selector); + var nodes = el.parentNode.querySelectorAll(selector); + for (var i = 0; i < nodes.length; i++) { + if (nodes[i] == el) return true; + } + return false; +} -/***/ }), -/* 1 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; -"use strict"; -/* harmony default export */ __webpack_exports__["a"] = { - BASE: 'shuffle', - SHUFFLE_ITEM: 'shuffle-item', - VISIBLE: 'shuffle-item--visible', - HIDDEN: 'shuffle-item--hidden' -}; -/***/ }), -/* 2 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { -"use strict"; -/* harmony export (immutable) */ __webpack_exports__["a"] = getNumber; -/** - * 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 createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; +} -function getNumber(value) { - return parseFloat(value) || 0; +var index$1 = createCommonjsModule(function (module) { +'use strict'; + +// there's 3 implementations written in increasing order of efficiency + +// 1 - no Set type is defined +function uniqNoSet(arr) { + var ret = []; + + for (var i = 0; i < arr.length; i++) { + if (ret.indexOf(arr[i]) === -1) { + ret.push(arr[i]); + } + } + + return ret; +} + +// 2 - a simple Set type is defined +function uniqSet(arr) { + var seen = new Set(); + return arr.filter(function (el) { + if (!seen.has(el)) { + seen.add(el); + return true; + } + + return false; + }); +} + +// 3 - a standard Set type is defined and it has a forEach method +function uniqSetWithForEach(arr) { + var ret = []; + + (new Set(arr)).forEach(function (el) { + ret.push(el); + }); + + return ret; +} + +// V8 currently has a broken implementation +// https://github.com/joyent/node/issues/8449 +function doesForEachActuallyWork() { + var ret = false; + + (new Set([true])).forEach(function (el) { + ret = el; + }); + + return ret === true; } -/***/ }), -/* 3 */ -/***/ (function(module, exports) { +if ('Set' in commonjsGlobal) { + if (typeof Set.prototype.forEach === 'function' && doesForEachActuallyWork()) { + module.exports = uniqSetWithForEach; + } else { + module.exports = uniqSet; + } +} else { + module.exports = uniqNoSet; +} +}); -module.exports = extend +var immutable = extend; var hasOwnProperty = Object.prototype.hasOwnProperty; function extend() { - var target = {} + var target = {}; for (var i = 0; i < arguments.length; i++) { - var source = arguments[i] + var source = arguments[i]; for (var key in source) { if (hasOwnProperty.call(source, key)) { - target[key] = source[key] + target[key] = source[key]; } } } @@ -162,2078 +172,1813 @@ function extend() { return target } +var index$2 = throttle; -/***/ }), -/* 4 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_custom_event_polyfill__ = __webpack_require__(13); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_custom_event_polyfill___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_custom_event_polyfill__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_matches_selector__ = __webpack_require__(14); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_matches_selector___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_matches_selector__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_array_uniq__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_array_uniq___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_array_uniq__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_xtend__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_xtend___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_xtend__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_throttleit__ = __webpack_require__(15); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_throttleit___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_throttleit__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_array_parallel__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_array_parallel___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_5_array_parallel__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__point__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__shuffle_item__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__classes__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__get_number_style__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__sorter__ = __webpack_require__(12); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__on_transition_end__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__layout__ = __webpack_require__(9); - - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +/** + * Returns a new function that, when invoked, invokes `func` at most once per `wait` milliseconds. + * + * @param {Function} func Function to wrap. + * @param {Number} wait Number of milliseconds that must elapse between `func` invocations. + * @return {Function} A new function that wraps the `func` function passed in. + */ -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function throttle (func, wait) { + var ctx, args, rtn, timeoutID; // caching + var last = 0; + return function throttled () { + ctx = this; + args = arguments; + var delta = new Date() - last; + if (!timeoutID) + if (delta >= wait) call(); + else timeoutID = setTimeout(call, wait - delta); + return rtn; + }; + function call () { + timeoutID = 0; + last = +new Date(); + rtn = func.apply(ctx, args); + ctx = null; + args = null; + } +} +var index$3 = function parallel(fns, context, callback) { + if (!callback) { + if (typeof context === 'function') { + callback = context; + context = null; + } else { + callback = noop; + } + } + var pending = fns && fns.length; + if (!pending) return callback(null, []); + var finished = false; + var results = new Array(pending); + fns.forEach(context ? function (fn, i) { + fn.call(context, maybeDone(i)); + } : function (fn, i) { + fn(maybeDone(i)); + }); + function maybeDone(i) { + return function (err, result) { + if (finished) return; + if (err) { + callback(err, results); + finished = true; + return + } + results[i] = result; + if (!--pending) callback(null, results); + } + } +}; +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) { + return parseFloat(value) || 0; +} +/** + * Represents a coordinate pair. + * @param {number} [x=0] X. + * @param {number} [y=0] Y. + */ +var Point = function Point(x, y) { + this.x = getNumber(x); + this.y = getNumber(y); +}; +/** + * Whether two points are equal. + * @param {Point} a Point A. + * @param {Point} b Point B. + * @return {boolean} + */ +Point.equals = function (a, b) { + return a.x === b.x && a.y === b.y; +}; -function toArray(arrayLike) { - return Array.prototype.slice.call(arrayLike); -} +var Classes = { + BASE: 'shuffle', + SHUFFLE_ITEM: 'shuffle-item', + VISIBLE: 'shuffle-item--visible', + HIDDEN: 'shuffle-item--hidden' +}; -function arrayMax(array) { - return Math.max.apply(Math, array); -} +var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +}; -function arrayIncludes(array, obj) { - if (arguments.length === 2) { - return arrayIncludes(array)(obj); +var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } } - return function (obj) { - return array.indexOf(obj) > -1; + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; }; -} - -// Used for unique instance variables -var id = 0; - -var Shuffle = function () { +}(); - /** - * Categorize, sort, and filter a responsive grid of items. - * - * @param {Element} element An element which is the parent container for the grid items. - * @param {Object} [options=Shuffle.options] Options object. - * @constructor - */ - function Shuffle(element) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; +var id$1 = 0; - _classCallCheck(this, Shuffle); +var ShuffleItem = function () { + function ShuffleItem(element) { + classCallCheck(this, ShuffleItem); - this.options = __WEBPACK_IMPORTED_MODULE_3_xtend___default()(Shuffle.options, options); + this.id = id$1++; + this.element = element; + this.isVisible = true; + } - this.useSizer = false; - this.lastSort = {}; - this.group = this.lastFilter = Shuffle.ALL_ITEMS; - this.isEnabled = true; - this.isDestroyed = false; - this.isInitialized = false; - this._transitions = []; - this.isTransitioning = false; - this._queue = []; + createClass(ShuffleItem, [{ + key: 'show', + value: function show() { + this.isVisible = true; + this.element.classList.remove(Classes.HIDDEN); + this.element.classList.add(Classes.VISIBLE); + } + }, { + key: 'hide', + value: function hide() { + this.isVisible = false; + this.element.classList.remove(Classes.VISIBLE); + this.element.classList.add(Classes.HIDDEN); + } + }, { + key: 'init', + value: function init() { + this.addClasses([Classes.SHUFFLE_ITEM, Classes.VISIBLE]); + this.applyCss(ShuffleItem.Css.INITIAL); + this.scale = ShuffleItem.Scale.VISIBLE; + this.point = new Point(); + } + }, { + key: 'addClasses', + value: function addClasses(classes) { + var _this = this; - element = this._getElementOption(element); + classes.forEach(function (className) { + _this.element.classList.add(className); + }); + } + }, { + key: 'removeClasses', + value: function removeClasses(classes) { + var _this2 = this; - if (!element) { - throw new TypeError('Shuffle needs to be initialized with an element.'); + classes.forEach(function (className) { + _this2.element.classList.remove(className); + }); + } + }, { + key: 'applyCss', + value: function applyCss(obj) { + for (var key in obj) { + this.element.style[key] = obj[key]; + } } + }, { + key: 'dispose', + value: function dispose() { + this.removeClasses([Classes.HIDDEN, Classes.VISIBLE, Classes.SHUFFLE_ITEM]); - this.element = element; - this.id = 'shuffle_' + id++; + this.element.removeAttribute('style'); + this.element = null; + } + }]); + return ShuffleItem; +}(); - this._init(); - this.isInitialized = true; +ShuffleItem.Css = { + INITIAL: { + position: 'absolute', + top: 0, + left: 0, + visibility: 'visible', + 'will-change': 'transform' + }, + VISIBLE: { + before: { + opacity: 1, + visibility: 'visible' + }, + after: {} + }, + HIDDEN: { + before: { + opacity: 0 + }, + after: { + visibility: 'hidden' + } } +}; - _createClass(Shuffle, [{ - key: '_init', - value: function _init() { - this.items = this._getItems(); +ShuffleItem.Scale = { + VISIBLE: 1, + HIDDEN: 0.001 +}; - this.options.sizer = this._getElementOption(this.options.sizer); +var element = document.body || document.documentElement; +var e$1 = document.createElement('div'); +e$1.style.cssText = 'width:10px;padding:2px;box-sizing:border-box;'; +element.appendChild(e$1); - if (this.options.sizer) { - this.useSizer = true; - } +var width = window.getComputedStyle(e$1, null).width; +var ret = width === '10px'; - // Add class and invalidate styles - this.element.classList.add(Shuffle.Classes.BASE); +element.removeChild(e$1); - // Set initial css for each item - this._initItems(); +/** + * Retrieve the computed style for an element, parsed as a float. + * @param {Element} element Element to get style for. + * @param {string} style Style property. + * @param {CSSStyleDeclaration} [styles] Optionally include clean styles to + * use instead of asking for them again. + * @return {number} The parsed computed value or zero if that fails because IE + * will return 'auto' when the element doesn't have margins instead of + * the computed style. + */ +function getNumberStyle(element, style) { + var styles = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : window.getComputedStyle(element, null); - // Bind resize events - this._onResize = this._getResizeFunction(); - window.addEventListener('resize', this._onResize); + var value = getNumber(styles[style]); - // Get container css all in one request. Causes reflow - var containerCss = window.getComputedStyle(this.element, null); - var containerWidth = Shuffle.getSize(this.element).width; + // Support IE<=11 and W3C spec. + if (!ret && style === 'width') { + value += getNumber(styles.paddingLeft) + getNumber(styles.paddingRight) + getNumber(styles.borderLeftWidth) + getNumber(styles.borderRightWidth); + } else if (!ret && style === 'height') { + value += getNumber(styles.paddingTop) + getNumber(styles.paddingBottom) + getNumber(styles.borderTopWidth) + getNumber(styles.borderBottomWidth); + } - // Add styles to the container if it doesn't have them. - this._validateStyles(containerCss); + return value; +} - // We already got the container's width above, no need to cause another - // reflow getting it again... Calculate the number of columns there will be - this._setColumns(containerWidth); +// http://stackoverflow.com/a/962890/373422 +function randomize(array) { + var tmp; + var current; + var top = array.length; - // Kick off! - this.filter(this.options.group, this.options.initialSort); + if (!top) { + return array; + } - // The shuffle items haven't had transitions set on them yet so the user - // doesn't see the first layout. Set them now that the first layout is done. - // First, however, a synchronous layout must be caused for the previous - // styles to be applied without transitions. - this.element.offsetWidth; // jshint ignore: line - this._setTransitions(); - this.element.style.transition = 'height ' + this.options.speed + 'ms ' + this.options.easing; - } + while (--top) { + current = Math.floor(Math.random() * (top + 1)); + tmp = array[current]; + array[current] = array[top]; + array[top] = tmp; + } - /** - * Returns a throttled and proxied function for the resize handler. - * @return {Function} - * @private - */ + return array; +} - }, { - key: '_getResizeFunction', - value: function _getResizeFunction() { - var resizeFunction = this._handleResize.bind(this); - return this.options.throttle ? this.options.throttle(resizeFunction, this.options.throttleTime) : resizeFunction; - } +var defaults$1 = { + // Use array.reverse() to reverse the results + reverse: false, - /** - * Retrieve an element from an option. - * @param {string|jQuery|Element} option The option to check. - * @return {?Element} The plain element or null. - * @private - */ + // Sorting function + by: null, - }, { - key: '_getElementOption', - value: function _getElementOption(option) { - // If column width is a string, treat is as a selector and search for the - // sizer element within the outermost container - if (typeof option === 'string') { - return this.element.querySelector(option); + // If true, this will skip the sorting and return a randomized order in the array + randomize: false, - // Check for an element - } else if (option && option.nodeType && option.nodeType === 1) { - return option; + // Determines which property of each item in the array is passed to the + // sorting method. + key: 'element' +}; - // Check for jQuery object - } else if (option && option.jquery) { - return option[0]; - } +// You can return `undefined` from the `by` function to revert to DOM order. +function sorter(arr, options) { + var opts = immutable(defaults$1, options); + var original = [].slice.call(arr); + var revert = false; - return null; - } + if (!arr.length) { + return []; + } - /** - * Ensures the shuffle container has the css styles it needs applied to it. - * @param {Object} styles Key value pairs for position and overflow. - * @private - */ + if (opts.randomize) { + return randomize(arr); + } - }, { - key: '_validateStyles', - value: function _validateStyles(styles) { - // Position cannot be static. - if (styles.position === 'static') { - this.element.style.position = 'relative'; - } + // Sort the elements by the opts.by function. + // If we don't have opts.by, default to DOM order + if (typeof opts.by === 'function') { + arr.sort(function (a, b) { - // Overflow has to be hidden. - if (styles.overflow !== 'hidden') { - this.element.style.overflow = 'hidden'; + // Exit early if we already know we want to revert + if (revert) { + return 0; } - } - - /** - * Filter the elements by a category. - * @param {string} [category] Category to filter by. If it's given, the last - * category will be used to filter the items. - * @param {Array} [collection] Optionally filter a collection. Defaults to - * all the items. - * @return {!{visible: Array, hidden: Array}} - * @private - */ - }, { - key: '_filter', - value: function _filter() { - var category = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.lastFilter; - var collection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.items; + var valA = opts.by(a[opts.key]); + var valB = opts.by(b[opts.key]); - var set = this._getFilteredSets(category, collection); + // If both values are undefined, use the DOM order + if (valA === undefined && valB === undefined) { + revert = true; + return 0; + } - // Individually add/remove hidden/visible classes - this._toggleFilterClasses(set); - - // Save the last filter in case elements are appended. - this.lastFilter = category; - - // This is saved mainly because providing a filter function (like searching) - // will overwrite the `lastFilter` property every time its called. - if (typeof category === 'string') { - this.group = category; + if (valA < valB || valA === 'sortFirst' || valB === 'sortLast') { + return -1; } - return set; - } - - /** - * Returns an object containing the visible and hidden elements. - * @param {string|Function} category Category or function to filter by. - * @param {Array.} items A collection of items to filter. - * @return {!{visible: Array, hidden: Array}} - * @private - */ - - }, { - key: '_getFilteredSets', - value: function _getFilteredSets(category, items) { - var _this = this; - - var visible = []; - var hidden = []; - - // category === 'all', add visible class to everything - if (category === Shuffle.ALL_ITEMS) { - visible = items; - - // Loop through each item and use provided function to determine - // whether to hide it or not. - } else { - items.forEach(function (item) { - if (_this._doesPassFilter(category, item.element)) { - visible.push(item); - } else { - hidden.push(item); - } - }); + if (valA > valB || valA === 'sortLast' || valB === 'sortFirst') { + return 1; } - return { - visible: visible, - hidden: hidden - }; - } - - /** - * Test an item to see if it passes a category. - * @param {string|Function} category Category or function to filter by. - * @param {Element} element An element to test. - * @return {boolean} Whether it passes the category/filter. - * @private - */ - - }, { - key: '_doesPassFilter', - value: function _doesPassFilter(category, element) { - - if (typeof category === 'function') { - return category.call(element, element, this); - - // Check each element's data-groups attribute against the given category. - } else { - var attr = element.getAttribute('data-' + Shuffle.FILTER_ATTRIBUTE_KEY); - var keys = this.options.delimeter ? attr.split(this.options.delimeter) : JSON.parse(attr); + return 0; + }); + } - if (Array.isArray(category)) { - return category.some(arrayIncludes(keys)); - } + // Revert to the original array if necessary + if (revert) { + return original; + } - return arrayIncludes(keys, category); - } - } + if (opts.reverse) { + arr.reverse(); + } - /** - * Toggles the visible and hidden class names. - * @param {{visible, hidden}} Object with visible and hidden arrays. - * @private - */ + return arr; +} - }, { - key: '_toggleFilterClasses', - value: function _toggleFilterClasses(_ref) { - var visible = _ref.visible, - hidden = _ref.hidden; +var transitions = {}; +var eventName = 'transitionend'; +var count = 0; - visible.forEach(function (item) { - item.show(); - }); +function uniqueId() { + return eventName + count++; +} - hidden.forEach(function (item) { - item.hide(); - }); +function onTransitionEnd(element, callback) { + var id = uniqueId(); + var listener = function listener(evt) { + if (evt.currentTarget === evt.target) { + cancelTransitionEnd(id); + callback(evt); } + }; - /** - * Set the initial css for each item - * @param {Array.} [items] Optionally specifiy at set to initialize. - * @private - */ + element.addEventListener(eventName, listener); - }, { - key: '_initItems', - value: function _initItems() { - var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.items; + transitions[id] = { element: element, listener: listener }; - items.forEach(function (item) { - item.init(); - }); - } + return id; +} - /** - * Remove element reference and styles. - * @private - */ +function cancelTransitionEnd(id) { + if (transitions[id]) { + transitions[id].element.removeEventListener(eventName, transitions[id].listener); + transitions[id] = null; + return true; + } - }, { - key: '_disposeItems', - value: function _disposeItems() { - var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.items; + return false; +} - items.forEach(function (item) { - item.dispose(); - }); - } +function arrayMax(array) { + return Math.max.apply(Math, array); +} - /** - * Updates the visible item count. - * @private - */ +function arrayMin(array) { + return Math.min.apply(Math, array); +} - }, { - key: '_updateItemCount', - value: function _updateItemCount() { - this.visibleItems = this._getFilteredItems().length; - } +/** + * Determine the location of the next item, based on its size. + * @param {Object} itemSize Object with width and height. + * @param {Array.} positions Positions of the other current items. + * @param {number} gridSize The column width or row height. + * @param {number} total The total number of columns or rows. + * @param {number} threshold Buffer value for the column to fit. + * @param {number} buffer Vertical buffer for the height of items. + * @return {Point} + */ +function getItemPosition(_ref) { + var itemSize = _ref.itemSize, + positions = _ref.positions, + gridSize = _ref.gridSize, + total = _ref.total, + threshold = _ref.threshold, + buffer = _ref.buffer; - /** - * Sets css transform transition on a group of elements. This is not executed - * at the same time as `item.init` so that transitions don't occur upon - * initialization of Shuffle. - * @param {Array.} items Shuffle items to set transitions on. - * @private - */ + var span = getColumnSpan(itemSize.width, gridSize, total, threshold); + var setY = getAvailablePositions(positions, span, total); + var shortColumnIndex = getShortColumn(setY, buffer); - }, { - key: '_setTransitions', - value: function _setTransitions() { - var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.items; + // Position the item + var point = new Point(Math.round(gridSize * shortColumnIndex), Math.round(setY[shortColumnIndex])); - var speed = this.options.speed; - var easing = this.options.easing; + // Update the columns array with the new values for each column. + // e.g. before the update the columns could be [250, 0, 0, 0] for an item + // which spans 2 columns. After it would be [250, itemHeight, itemHeight, 0]. + var setHeight = setY[shortColumnIndex] + itemSize.height; + for (var i = 0; i < span; i++) { + positions[shortColumnIndex + i] = setHeight; + } - var str; - if (this.options.useTransforms) { - str = 'transform ' + speed + 'ms ' + easing + ', opacity ' + speed + 'ms ' + easing; - } else { - str = 'top ' + speed + 'ms ' + easing + ', left ' + speed + 'ms ' + easing + ', opacity ' + speed + 'ms ' + easing; - } + return point; +} - items.forEach(function (item) { - item.element.style.transition = str; - }); - } - }, { - key: '_getItems', - value: function _getItems() { - var _this2 = this; +/** + * Determine the number of columns an items spans. + * @param {number} itemWidth Width of the item. + * @param {number} columnWidth Width of the column (includes gutter). + * @param {number} columns Total number of columns + * @param {number} threshold A buffer value for the size of the column to fit. + * @return {number} + */ +function getColumnSpan(itemWidth, columnWidth, columns, threshold) { + var columnSpan = itemWidth / columnWidth; - return toArray(this.element.children).filter(function (el) { - return __WEBPACK_IMPORTED_MODULE_1_matches_selector___default()(el, _this2.options.itemSelector); - }).map(function (el) { - return new __WEBPACK_IMPORTED_MODULE_7__shuffle_item__["a" /* default */](el); - }); - } + // If the difference between the rounded column span number and the + // calculated column span number is really small, round the number to + // make it fit. + if (Math.abs(Math.round(columnSpan) - columnSpan) < threshold) { + // e.g. columnSpan = 4.0089945390298745 + columnSpan = Math.round(columnSpan); + } - /** - * When new elements are added to the shuffle container, update the array of - * items because that is the order `_layout` calls them. - */ + // Ensure the column span is not more than the amount of columns in the whole layout. + return Math.min(Math.ceil(columnSpan), columns); +} - }, { - key: '_updateItemsOrder', - value: function _updateItemsOrder() { - var children = this.element.children; - this.items = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_10__sorter__["a" /* default */])(this.items, { - by: function by(element) { - return Array.prototype.indexOf.call(children, element); - } - }); - } - }, { - key: '_getFilteredItems', - value: function _getFilteredItems() { - return this.items.filter(function (item) { - return item.isVisible; - }); - } - }, { - key: '_getConcealedItems', - value: function _getConcealedItems() { - return this.items.filter(function (item) { - return !item.isVisible; - }); - } - - /** - * Returns the column size, based on column width and sizer options. - * @param {number} containerWidth Size of the parent container. - * @param {number} gutterSize Size of the gutters. - * @return {number} - * @private - */ - - }, { - key: '_getColumnSize', - value: function _getColumnSize(containerWidth, gutterSize) { - var size; - - // If the columnWidth property is a function, then the grid is fluid - if (typeof this.options.columnWidth === 'function') { - size = this.options.columnWidth(containerWidth); - - // columnWidth option isn't a function, are they using a sizing element? - } else if (this.useSizer) { - size = Shuffle.getSize(this.options.sizer).width; - - // if not, how about the explicitly set option? - } else if (this.options.columnWidth) { - size = this.options.columnWidth; - - // or use the size of the first item - } else if (this.items.length > 0) { - size = Shuffle.getSize(this.items[0].element, true).width; - - // if there's no items, use size of container - } else { - size = containerWidth; - } - - // Don't let them set a column width of zero. - if (size === 0) { - size = containerWidth; - } - - return size + gutterSize; - } - - /** - * Returns the gutter size, based on gutter width and sizer options. - * @param {number} containerWidth Size of the parent container. - * @return {number} - * @private - */ - - }, { - key: '_getGutterSize', - value: function _getGutterSize(containerWidth) { - var size; - if (typeof this.options.gutterWidth === 'function') { - size = this.options.gutterWidth(containerWidth); - } else if (this.useSizer) { - size = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_9__get_number_style__["a" /* default */])(this.options.sizer, 'marginLeft'); - } else { - size = this.options.gutterWidth; - } - - return size; - } - - /** - * Calculate the number of columns to be used. Gets css if using sizer element. - * @param {number} [containerWidth] Optionally specify a container width if - * it's already available. - */ - - }, { - key: '_setColumns', - value: function _setColumns() { - var containerWidth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Shuffle.getSize(this.element).width; - - var gutter = this._getGutterSize(containerWidth); - var columnWidth = this._getColumnSize(containerWidth, gutter); - var calculatedColumns = (containerWidth + gutter) / columnWidth; - - // Widths given from getStyles are not precise enough... - if (Math.abs(Math.round(calculatedColumns) - calculatedColumns) < this.options.columnThreshold) { - // e.g. calculatedColumns = 11.998876 - calculatedColumns = Math.round(calculatedColumns); - } - - this.cols = Math.max(Math.floor(calculatedColumns), 1); - this.containerWidth = containerWidth; - this.colWidth = columnWidth; - } - - /** - * Adjust the height of the grid - */ - - }, { - key: '_setContainerSize', - value: function _setContainerSize() { - this.element.style.height = this._getContainerSize() + 'px'; - } - - /** - * Based on the column heights, it returns the biggest one. - * @return {number} - * @private - */ - - }, { - key: '_getContainerSize', - value: function _getContainerSize() { - return arrayMax(this.positions); - } - - /** - * Get the clamped stagger amount. - * @param {number} index Index of the item to be staggered. - * @return {number} - */ - - }, { - key: '_getStaggerAmount', - value: function _getStaggerAmount(index) { - return Math.min(index * this.options.staggerAmount, this.options.staggerAmountMax); - } - - /** - * @return {boolean} Whether the event was prevented or not. - */ - - }, { - key: '_dispatch', - value: function _dispatch(name) { - var details = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - - if (this.isDestroyed) { - return; - } - - details.shuffle = this; - return !this.element.dispatchEvent(new CustomEvent(name, { - bubbles: true, - cancelable: false, - detail: details - })); - } - - /** - * Zeros out the y columns array, which is used to determine item placement. - * @private - */ - - }, { - key: '_resetCols', - value: function _resetCols() { - var i = this.cols; - this.positions = []; - while (i--) { - this.positions.push(0); - } - } - - /** - * Loops through each item that should be shown and calculates the x, y position. - * @param {Array.} items Array of items that will be shown/layed - * out in order in their array. - */ - - }, { - key: '_layout', - value: function _layout(items) { - var _this3 = this; - - var count = 0; - items.forEach(function (item) { - var currPos = item.point; - var currScale = item.scale; - var itemSize = Shuffle.getSize(item.element, true); - var pos = _this3._getItemPosition(itemSize); - - function callback() { - item.element.style.transitionDelay = ''; - item.applyCss(__WEBPACK_IMPORTED_MODULE_7__shuffle_item__["a" /* default */].Css.VISIBLE.after); - } - - // If the item will not change its position, do not add it to the render - // queue. Transitions don't fire when setting a property to the same value. - if (__WEBPACK_IMPORTED_MODULE_6__point__["a" /* default */].equals(currPos, pos) && currScale === __WEBPACK_IMPORTED_MODULE_7__shuffle_item__["a" /* default */].Scale.VISIBLE) { - item.applyCss(__WEBPACK_IMPORTED_MODULE_7__shuffle_item__["a" /* default */].Css.VISIBLE.before); - callback(); - return; - } - - item.point = pos; - item.scale = __WEBPACK_IMPORTED_MODULE_7__shuffle_item__["a" /* default */].Scale.VISIBLE; - - // Use xtend here to clone the object so that the `before` object isn't - // modified when the transition delay is added. - var styles = __WEBPACK_IMPORTED_MODULE_3_xtend___default()(__WEBPACK_IMPORTED_MODULE_7__shuffle_item__["a" /* default */].Css.VISIBLE.before); - styles.transitionDelay = _this3._getStaggerAmount(count) + 'ms'; - - _this3._queue.push({ - item: item, - styles: styles, - callback: callback - }); - - count++; - }); - } - - /** - * Determine the location of the next item, based on its size. - * @param {{width: number, height: number}} itemSize Object with width and height. - * @return {Point} - * @private - */ - - }, { - key: '_getItemPosition', - value: function _getItemPosition(itemSize) { - return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_12__layout__["a" /* getItemPosition */])({ - itemSize: itemSize, - positions: this.positions, - gridSize: this.colWidth, - total: this.cols, - threshold: this.options.columnThreshold, - buffer: this.options.buffer - }); - } - - /** - * Hides the elements that don't match our filter. - * @param {Array.} collection Collection to shrink. - * @private - */ - - }, { - key: '_shrink', - value: function _shrink() { - var _this4 = this; - - var collection = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._getConcealedItems(); - - var count = 0; - collection.forEach(function (item) { - function callback() { - item.applyCss(__WEBPACK_IMPORTED_MODULE_7__shuffle_item__["a" /* default */].Css.HIDDEN.after); - } - - // Continuing would add a transitionend event listener to the element, but - // that listener would not execute because the transform and opacity would - // stay the same. - // The callback is executed here because it is not guaranteed to be called - // after the transitionend event because the transitionend could be - // canceled if another animation starts. - if (item.scale === __WEBPACK_IMPORTED_MODULE_7__shuffle_item__["a" /* default */].Scale.HIDDEN) { - item.applyCss(__WEBPACK_IMPORTED_MODULE_7__shuffle_item__["a" /* default */].Css.HIDDEN.before); - callback(); - return; - } - - item.scale = __WEBPACK_IMPORTED_MODULE_7__shuffle_item__["a" /* default */].Scale.HIDDEN; - - var styles = __WEBPACK_IMPORTED_MODULE_3_xtend___default()(__WEBPACK_IMPORTED_MODULE_7__shuffle_item__["a" /* default */].Css.HIDDEN.before); - styles.transitionDelay = _this4._getStaggerAmount(count) + 'ms'; - - _this4._queue.push({ - item: item, - styles: styles, - callback: callback - }); - - count++; - }); - } - - /** - * Resize handler. - * @private - */ - - }, { - key: '_handleResize', - value: function _handleResize() { - // If shuffle is disabled, destroyed, don't do anything - if (!this.isEnabled || this.isDestroyed) { - return; - } - - // Will need to check height in the future if it's layed out horizontaly - var containerWidth = Shuffle.getSize(this.element).width; - - // containerWidth hasn't changed, don't do anything - if (containerWidth === this.containerWidth) { - return; - } - - this.update(); - } - - /** - * Returns styles which will be applied to the an item for a transition. - * @param {Object} obj Transition options. - * @return {!Object} Transforms for transitions, left/top for animate. - * @private - */ - - }, { - key: '_getStylesForTransition', - value: function _getStylesForTransition(_ref2) { - var item = _ref2.item, - styles = _ref2.styles; - - if (!styles.transitionDelay) { - styles.transitionDelay = '0ms'; - } - - var x = item.point.x; - var y = item.point.y; - - if (this.options.useTransforms) { - styles.transform = 'translate(' + x + 'px, ' + y + 'px) scale(' + item.scale + ')'; - } else { - styles.left = x + 'px'; - styles.top = y + 'px'; - } - - return styles; - } - - /** - * Listen for the transition end on an element and execute the itemCallback - * when it finishes. - * @param {Element} element Element to listen on. - * @param {Function} itemCallback Callback for the item. - * @param {Function} done Callback to notify `parallel` that this one is done. - */ - - }, { - key: '_whenTransitionDone', - value: function _whenTransitionDone(element, itemCallback, done) { - var id = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_11__on_transition_end__["a" /* onTransitionEnd */])(element, function (evt) { - itemCallback(); - done(null, evt); - }); - - this._transitions.push(id); - } - - /** - * Return a function which will set CSS styles and call the `done` function - * when (if) the transition finishes. - * @param {Object} opts Transition object. - * @return {Function} A function to be called with a `done` function. - */ - - }, { - key: '_getTransitionFunction', - value: function _getTransitionFunction(opts) { - var _this5 = this; - - return function (done) { - opts.item.applyCss(_this5._getStylesForTransition(opts)); - _this5._whenTransitionDone(opts.item.element, opts.callback, done); - }; - } - - /** - * Execute the styles gathered in the style queue. This applies styles to elements, - * triggering transitions. - * @private - */ - - }, { - key: '_processQueue', - value: function _processQueue() { - if (this.isTransitioning) { - this._cancelMovement(); - } - - var hasSpeed = this.options.speed > 0; - var hasQueue = this._queue.length > 0; - - if (hasQueue && hasSpeed && this.isInitialized) { - this._startTransitions(this._queue); - } else if (hasQueue) { - this._styleImmediately(this._queue); - this._dispatchLayout(); - - // A call to layout happened, but none of the newly visible items will - // change position or the transition duration is zero, which will not trigger - // the transitionend event. - } else { - this._dispatchLayout(); - } - - // Remove everything in the style queue - this._queue.length = 0; - } - - /** - * Wait for each transition to finish, the emit the layout event. - * @param {Array.} transitions Array of transition objects. - */ - - }, { - key: '_startTransitions', - value: function _startTransitions(transitions) { - var _this6 = this; - - // Set flag that shuffle is currently in motion. - this.isTransitioning = true; +/** + * 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.} An array of numbers represeting the column set. + */ +function getAvailablePositions(positions, columnSpan, columns) { + // The item spans only one column. + if (columnSpan === 1) { + return positions; + } - // Create an array of functions to be called. - var callbacks = transitions.map(function (obj) { - return _this6._getTransitionFunction(obj); - }); + // The item spans more than one column, figure out how many different + // places it could fit horizontally. + // The group count is the number of places within the positions this block + // could fit, ignoring the current positions of items. + // Imagine a 2 column brick as the second item in a 4 column grid with + // 10px height each. Find the places it would fit: + // [20, 10, 10, 0] + // | | | + // * * * + // + // Then take the places which fit and get the bigger of the two: + // max([20, 10]), max([10, 10]), max([10, 0]) = [20, 10, 0] + // + // Next, find the first smallest number (the short column). + // [20, 10, 0] + // | + // * + // + // And that's where it should be placed! + // + // Another example where the second column's item extends past the first: + // [10, 20, 10, 0] => [20, 20, 10] => 10 + var available = []; - __WEBPACK_IMPORTED_MODULE_5_array_parallel___default()(callbacks, this._movementFinished.bind(this)); - } - }, { - key: '_cancelMovement', - value: function _cancelMovement() { - // Remove the transition end event for each listener. - this._transitions.forEach(__WEBPACK_IMPORTED_MODULE_11__on_transition_end__["b" /* cancelTransitionEnd */]); + // For how many possible positions for this item there are. + for (var i = 0; i <= columns - columnSpan; i++) { + // Find the bigger value for each place it could fit. + available.push(arrayMax(positions.slice(i, i + columnSpan))); + } - // Reset the array. - this._transitions.length = 0; + return available; +} - // Show it's no longer active. - this.isTransitioning = false; +/** + * Find index of short column, the first from the left where this item will go. + * + * @param {Array.} positions The array to search for the smallest number. + * @param {number} buffer Optional buffer which is very useful when the height + * is a percentage of the width. + * @return {number} Index of the short column. + */ +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) { + return i; } + } - /** - * Apply styles without a transition. - * @param {Array.} objects Array of transition objects. - * @private - */ + return 0; +} - }, { - key: '_styleImmediately', - value: function _styleImmediately(objects) { - var _this7 = this; +function toArray$$1(arrayLike) { + return Array.prototype.slice.call(arrayLike); +} - if (objects.length) { - var elements = objects.map(function (obj) { - return obj.item.element; - }); +function arrayIncludes(array, obj) { + if (arguments.length === 2) { + return arrayIncludes(array)(obj); + } - Shuffle._skipTransitions(elements, function () { - objects.forEach(function (obj) { - obj.item.applyCss(_this7._getStylesForTransition(obj)); - obj.callback(); - }); - }); - } - } - }, { - key: '_movementFinished', - value: function _movementFinished() { - this._transitions.length = 0; - this.isTransitioning = false; - this._dispatchLayout(); - } - }, { - key: '_dispatchLayout', - value: function _dispatchLayout() { - this._dispatch(Shuffle.EventType.LAYOUT); - } + return function (obj) { + return array.indexOf(obj) > -1; + }; +} - /** - * The magic. This is what makes the plugin 'shuffle' - * @param {string|Function|Array.} [category] Category to filter by. - * Can be a function, string, or array of strings. - * @param {Object} [sortObj] A sort object which can sort the visible set - */ +// Used for unique instance variables +var id = 0; - }, { - key: 'filter', - value: function filter(category, sortObj) { - if (!this.isEnabled) { - return; - } +var Shuffle = function () { - if (!category || category && category.length === 0) { - category = Shuffle.ALL_ITEMS; - } + /** + * Categorize, sort, and filter a responsive grid of items. + * + * @param {Element} element An element which is the parent container for the grid items. + * @param {Object} [options=Shuffle.options] Options object. + * @constructor + */ + function Shuffle(element) { + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + classCallCheck(this, Shuffle); - this._filter(category); + this.options = immutable(Shuffle.options, options); - // Shrink each hidden item - this._shrink(); + this.useSizer = false; + this.lastSort = {}; + this.group = this.lastFilter = Shuffle.ALL_ITEMS; + this.isEnabled = true; + this.isDestroyed = false; + this.isInitialized = false; + this._transitions = []; + this.isTransitioning = false; + this._queue = []; - // How many visible elements? - this._updateItemCount(); + element = this._getElementOption(element); - // Update transforms on visible elements so they will animate to their new positions. - this.sort(sortObj); + if (!element) { + throw new TypeError('Shuffle needs to be initialized with an element.'); } - /** - * Gets the visible elements, sorts them, and passes them to layout. - * @param {Object} opts the options object for the sorted plugin - */ - - }, { - key: 'sort', - value: function sort() { - var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.lastSort; - - if (!this.isEnabled) { - return; - } + this.element = element; + this.id = 'shuffle_' + id++; - this._resetCols(); + this._init(); + this.isInitialized = true; + } - var items = this._getFilteredItems(); - items = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_10__sorter__["a" /* default */])(items, opts); + createClass(Shuffle, [{ + key: '_init', + value: function _init() { + this.items = this._getItems(); - this._layout(items); + this.options.sizer = this._getElementOption(this.options.sizer); - // `_layout` always happens after `_shrink`, so it's safe to process the style - // queue here with styles from the shrink method. - this._processQueue(); + if (this.options.sizer) { + this.useSizer = true; + } - // Adjust the height of the container. - this._setContainerSize(); + // Add class and invalidate styles + this.element.classList.add(Shuffle.Classes.BASE); - this.lastSort = opts; - } + // Set initial css for each item + this._initItems(); - /** - * Reposition everything. - * @param {boolean} isOnlyLayout If true, column and gutter widths won't be - * recalculated. - */ + // Bind resize events + this._onResize = this._getResizeFunction(); + window.addEventListener('resize', this._onResize); - }, { - key: 'update', - value: function update(isOnlyLayout) { - if (this.isEnabled) { + // Get container css all in one request. Causes reflow + var containerCss = window.getComputedStyle(this.element, null); + var containerWidth = Shuffle.getSize(this.element).width; - if (!isOnlyLayout) { - // Get updated colCount - this._setColumns(); - } + // Add styles to the container if it doesn't have them. + this._validateStyles(containerCss); - // Layout items - this.sort(); - } - } + // We already got the container's width above, no need to cause another + // reflow getting it again... Calculate the number of columns there will be + this._setColumns(containerWidth); - /** - * Use this instead of `update()` if you don't need the columns and gutters updated - * Maybe an image inside `shuffle` loaded (and now has a height), which means calculations - * could be off. - */ + // Kick off! + this.filter(this.options.group, this.options.initialSort); - }, { - key: 'layout', - value: function layout() { - this.update(true); + // The shuffle items haven't had transitions set on them yet so the user + // doesn't see the first layout. Set them now that the first layout is done. + // First, however, a synchronous layout must be caused for the previous + // styles to be applied without transitions. + this.element.offsetWidth; // jshint ignore: line + this._setTransitions(); + this.element.style.transition = 'height ' + this.options.speed + 'ms ' + this.options.easing; } /** - * New items have been appended to shuffle. Mix them in with the current - * filter or sort status. - * @param {Array.} newItems Collection of new items. + * Returns a throttled and proxied function for the resize handler. + * @return {Function} + * @private */ }, { - key: 'add', - value: function add(newItems) { - newItems = __WEBPACK_IMPORTED_MODULE_2_array_uniq___default()(newItems).map(function (el) { - return new __WEBPACK_IMPORTED_MODULE_7__shuffle_item__["a" /* default */](el); - }); - - // Add classes and set initial positions. - this._initItems(newItems); - - // Add transition to each item. - this._setTransitions(newItems); - - // Update the list of items. - this.items = this.items.concat(newItems); - this._updateItemsOrder(); - this.filter(this.lastFilter); + key: '_getResizeFunction', + value: function _getResizeFunction() { + var resizeFunction = this._handleResize.bind(this); + return this.options.throttle ? this.options.throttle(resizeFunction, this.options.throttleTime) : resizeFunction; } /** - * Disables shuffle from updating dimensions and layout on resize + * Retrieve an element from an option. + * @param {string|jQuery|Element} option The option to check. + * @return {?Element} The plain element or null. + * @private */ }, { - key: 'disable', - value: function disable() { - this.isEnabled = false; + key: '_getElementOption', + value: function _getElementOption(option) { + // If column width is a string, treat is as a selector and search for the + // sizer element within the outermost container + if (typeof option === 'string') { + return this.element.querySelector(option); + + // Check for an element + } else if (option && option.nodeType && option.nodeType === 1) { + return option; + + // Check for jQuery object + } else if (option && option.jquery) { + return option[0]; + } + + return null; } /** - * Enables shuffle again - * @param {boolean} [isUpdateLayout=true] if undefined, shuffle will update columns and gutters + * Ensures the shuffle container has the css styles it needs applied to it. + * @param {Object} styles Key value pairs for position and overflow. + * @private */ }, { - key: 'enable', - value: function enable(isUpdateLayout) { - this.isEnabled = true; - if (isUpdateLayout !== false) { - this.update(); + key: '_validateStyles', + value: function _validateStyles(styles) { + // Position cannot be static. + if (styles.position === 'static') { + this.element.style.position = 'relative'; + } + + // Overflow has to be hidden. + if (styles.overflow !== 'hidden') { + this.element.style.overflow = 'hidden'; } } /** - * Remove 1 or more shuffle items - * @param {Array.} collection An array containing one or more - * elements in shuffle - * @return {Shuffle} The shuffle object + * Filter the elements by a category. + * @param {string} [category] Category to filter by. If it's given, the last + * category will be used to filter the items. + * @param {Array} [collection] Optionally filter a collection. Defaults to + * all the items. + * @return {!{visible: Array, hidden: Array}} + * @private */ }, { - key: 'remove', - value: function remove(collection) { - var _this8 = this; - - if (!collection.length) { - return; - } + key: '_filter', + value: function _filter() { + var category = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.lastFilter; + var collection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.items; - collection = __WEBPACK_IMPORTED_MODULE_2_array_uniq___default()(collection); + var set$$1 = this._getFilteredSets(category, collection); - var oldItems = collection.map(function (element) { - return _this8.getItemByElement(element); - }).filter(function (item) { - return !!item; - }); + // Individually add/remove hidden/visible classes + this._toggleFilterClasses(set$$1); - var handleLayout = function handleLayout() { - _this8.element.removeEventListener(Shuffle.EventType.LAYOUT, handleLayout); - _this8._disposeItems(oldItems); + // Save the last filter in case elements are appended. + this.lastFilter = category; - // Remove the collection in the callback - collection.forEach(function (element) { - element.parentNode.removeChild(element); - }); + // This is saved mainly because providing a filter function (like searching) + // will overwrite the `lastFilter` property every time its called. + if (typeof category === 'string') { + this.group = category; + } - _this8._dispatch(Shuffle.EventType.REMOVED, { collection: collection }); + return set$$1; + } - // Let it get garbage collected - collection = null; - oldItems = null; - }; + /** + * Returns an object containing the visible and hidden elements. + * @param {string|Function} category Category or function to filter by. + * @param {Array.} items A collection of items to filter. + * @return {!{visible: Array, hidden: Array}} + * @private + */ - // Hide collection first. - this._toggleFilterClasses({ - visible: [], - hidden: oldItems - }); + }, { + key: '_getFilteredSets', + value: function _getFilteredSets(category, items) { + var _this = this; - this._shrink(oldItems); + var visible = []; + var hidden = []; - this.sort(); + // category === 'all', add visible class to everything + if (category === Shuffle.ALL_ITEMS) { + visible = items; - // Update the list of items here because `remove` could be called again - // with an item that is in the process of being removed. - this.items = this.items.filter(function (item) { - return !arrayIncludes(oldItems, item); - }); - this._updateItemCount(); + // Loop through each item and use provided function to determine + // whether to hide it or not. + } else { + items.forEach(function (item) { + if (_this._doesPassFilter(category, item.element)) { + visible.push(item); + } else { + hidden.push(item); + } + }); + } - this.element.addEventListener(Shuffle.EventType.LAYOUT, handleLayout); + return { + visible: visible, + hidden: hidden + }; } /** - * Retrieve a shuffle item by its element. - * @param {Element} element Element to look for. - * @return {?ShuffleItem} A shuffle item or null if it's not found. + * Test an item to see if it passes a category. + * @param {string|Function} category Category or function to filter by. + * @param {Element} element An element to test. + * @return {boolean} Whether it passes the category/filter. + * @private */ }, { - key: 'getItemByElement', - value: function getItemByElement(element) { - for (var i = this.items.length - 1; i >= 0; i--) { - if (this.items[i].element === element) { - return this.items[i]; + key: '_doesPassFilter', + value: function _doesPassFilter(category, element) { + + if (typeof category === 'function') { + return category.call(element, element, this); + + // Check each element's data-groups attribute against the given category. + } else { + var attr = element.getAttribute('data-' + Shuffle.FILTER_ATTRIBUTE_KEY); + var keys = this.options.delimeter ? attr.split(this.options.delimeter) : JSON.parse(attr); + + if (Array.isArray(category)) { + return category.some(arrayIncludes(keys)); } - } - return null; + return arrayIncludes(keys, category); + } } /** - * Destroys shuffle, removes events, styles, and classes + * Toggles the visible and hidden class names. + * @param {{visible, hidden}} Object with visible and hidden arrays. + * @private */ }, { - key: 'destroy', - value: function destroy() { - this._cancelMovement(); - window.removeEventListener('resize', this._onResize); + key: '_toggleFilterClasses', + value: function _toggleFilterClasses(_ref) { + var visible = _ref.visible, + hidden = _ref.hidden; - // Reset container styles - this.element.classList.remove('shuffle'); - this.element.removeAttribute('style'); + visible.forEach(function (item) { + item.show(); + }); - // Reset individual item styles - this._disposeItems(); + hidden.forEach(function (item) { + item.hide(); + }); + } - // Null DOM references - this.items = null; - this.options.sizer = null; - this.element = null; - this._transitions = null; + /** + * Set the initial css for each item + * @param {Array.} [items] Optionally specifiy at set to initialize. + * @private + */ - // Set a flag so if a debounced resize has been triggered, - // it can first check if it is actually isDestroyed and not doing anything - this.isDestroyed = true; + }, { + key: '_initItems', + value: function _initItems() { + var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.items; + + items.forEach(function (item) { + item.init(); + }); } /** - * Returns the outer width of an element, optionally including its margins. - * - * There are a few different methods for getting the width of an element, none of - * which work perfectly for all Shuffle's use cases. - * - * 1. getBoundingClientRect() `left` and `right` properties. - * - Accounts for transform scaled elements, making it useless for Shuffle - * elements which have shrunk. - * 2. The `offsetWidth` property. - * - This value stays the same regardless of the elements transform property, - * however, it does not return subpixel values. - * 3. getComputedStyle() - * - This works great Chrome, Firefox, Safari, but IE<=11 does not include - * padding and border when box-sizing: border-box is set, requiring a feature - * test and extra work to add the padding back for IE and other browsers which - * follow the W3C spec here. - * - * @param {Element} element The element. - * @param {boolean} [includeMargins] Whether to include margins. Default is false. - * @return {{width: number, height: number}} The width and height. + * Remove element reference and styles. + * @private */ - }], [{ - key: 'getSize', - value: function getSize(element, includeMargins) { - // Store the styles so that they can be used by others without asking for it again. - var styles = window.getComputedStyle(element, null); - var width = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_9__get_number_style__["a" /* default */])(element, 'width', styles); - var height = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_9__get_number_style__["a" /* default */])(element, 'height', styles); - - if (includeMargins) { - var marginLeft = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_9__get_number_style__["a" /* default */])(element, 'marginLeft', styles); - var marginRight = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_9__get_number_style__["a" /* default */])(element, 'marginRight', styles); - var marginTop = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_9__get_number_style__["a" /* default */])(element, 'marginTop', styles); - var marginBottom = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_9__get_number_style__["a" /* default */])(element, 'marginBottom', styles); - width += marginLeft + marginRight; - height += marginTop + marginBottom; - } + }, { + key: '_disposeItems', + value: function _disposeItems() { + var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.items; - return { - width: width, - height: height - }; + items.forEach(function (item) { + item.dispose(); + }); } /** - * Change a property or execute a function which will not have a transition - * @param {Array.} elements DOM elements that won't be transitioned. - * @param {Function} callback A function which will be called while transition - * is set to 0ms. + * Updates the visible item count. * @private */ }, { - key: '_skipTransitions', - value: function _skipTransitions(elements, callback) { - var zero = '0ms'; + key: '_updateItemCount', + value: function _updateItemCount() { + this.visibleItems = this._getFilteredItems().length; + } - // Save current duration and delay. - var data = elements.map(function (element) { - var style = element.style; - var duration = style.transitionDuration; - var delay = style.transitionDelay; + /** + * Sets css transform transition on a group of elements. This is not executed + * at the same time as `item.init` so that transitions don't occur upon + * initialization of Shuffle. + * @param {Array.} items Shuffle items to set transitions on. + * @private + */ - // Set the duration to zero so it happens immediately - style.transitionDuration = zero; - style.transitionDelay = zero; + }, { + key: '_setTransitions', + value: function _setTransitions() { + var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.items; - return { - duration: duration, - delay: delay - }; - }); + var speed = this.options.speed; + var easing = this.options.easing; - callback(); + var str; + if (this.options.useTransforms) { + str = 'transform ' + speed + 'ms ' + easing + ', opacity ' + speed + 'ms ' + easing; + } else { + str = 'top ' + speed + 'ms ' + easing + ', left ' + speed + 'ms ' + easing + ', opacity ' + speed + 'ms ' + easing; + } - // Cause reflow. - elements[0].offsetWidth; // jshint ignore:line + items.forEach(function (item) { + item.element.style.transition = str; + }); + } + }, { + key: '_getItems', + value: function _getItems() { + var _this2 = this; - // Put the duration back - elements.forEach(function (element, i) { - element.style.transitionDuration = data[i].duration; - element.style.transitionDelay = data[i].delay; + return toArray$$1(this.element.children).filter(function (el) { + return index(el, _this2.options.itemSelector); + }).map(function (el) { + return new ShuffleItem(el); }); } - }]); - return Shuffle; -}(); + /** + * When new elements are added to the shuffle container, update the array of + * items because that is the order `_layout` calls them. + */ -Shuffle.ShuffleItem = __WEBPACK_IMPORTED_MODULE_7__shuffle_item__["a" /* default */]; + }, { + key: '_updateItemsOrder', + value: function _updateItemsOrder() { + var children = this.element.children; + this.items = sorter(this.items, { + by: function by(element) { + return Array.prototype.indexOf.call(children, element); + } + }); + } + }, { + key: '_getFilteredItems', + value: function _getFilteredItems() { + return this.items.filter(function (item) { + return item.isVisible; + }); + } + }, { + key: '_getConcealedItems', + value: function _getConcealedItems() { + return this.items.filter(function (item) { + return !item.isVisible; + }); + } -Shuffle.ALL_ITEMS = 'all'; -Shuffle.FILTER_ATTRIBUTE_KEY = 'groups'; + /** + * Returns the column size, based on column width and sizer options. + * @param {number} containerWidth Size of the parent container. + * @param {number} gutterSize Size of the gutters. + * @return {number} + * @private + */ -/** - * @enum {string} - */ -Shuffle.EventType = { - LAYOUT: 'shuffle:layout', - REMOVED: 'shuffle:removed' -}; + }, { + key: '_getColumnSize', + value: function _getColumnSize(containerWidth, gutterSize) { + var size; -/** @enum {string} */ -Shuffle.Classes = __WEBPACK_IMPORTED_MODULE_8__classes__["a" /* default */]; + // If the columnWidth property is a function, then the grid is fluid + if (typeof this.options.columnWidth === 'function') { + size = this.options.columnWidth(containerWidth); -// Overrideable options -Shuffle.options = { - // Initial filter group. - group: Shuffle.ALL_ITEMS, + // columnWidth option isn't a function, are they using a sizing element? + } else if (this.useSizer) { + size = Shuffle.getSize(this.options.sizer).width; - // Transition/animation speed (milliseconds). - speed: 250, + // if not, how about the explicitly set option? + } else if (this.options.columnWidth) { + size = this.options.columnWidth; - // CSS easing function to use. - easing: 'ease', + // or use the size of the first item + } else if (this.items.length > 0) { + size = Shuffle.getSize(this.items[0].element, true).width; - // e.g. '.picture-item'. - itemSelector: '*', + // if there's no items, use size of container + } else { + size = containerWidth; + } - // Element or selector string. Use an element to determine the size of columns - // and gutters. - sizer: null, + // Don't let them set a column width of zero. + if (size === 0) { + size = containerWidth; + } - // A static number or function that tells the plugin how wide the gutters - // between columns are (in pixels). - gutterWidth: 0, + return size + gutterSize; + } - // A static number or function that returns a number which tells the plugin - // how wide the columns are (in pixels). - columnWidth: 0, + /** + * Returns the gutter size, based on gutter width and sizer options. + * @param {number} containerWidth Size of the parent container. + * @return {number} + * @private + */ - // If your group is not json, and is comma delimeted, you could set delimeter - // to ','. - delimeter: null, + }, { + key: '_getGutterSize', + value: function _getGutterSize(containerWidth) { + var size; + if (typeof this.options.gutterWidth === 'function') { + size = this.options.gutterWidth(containerWidth); + } else if (this.useSizer) { + size = getNumberStyle(this.options.sizer, 'marginLeft'); + } else { + size = this.options.gutterWidth; + } - // Useful for percentage based heights when they might not always be exactly - // the same (in pixels). - buffer: 0, + return size; + } - // Reading the width of elements isn't precise enough and can cause columns to - // jump between values. - columnThreshold: 0.01, + /** + * Calculate the number of columns to be used. Gets css if using sizer element. + * @param {number} [containerWidth] Optionally specify a container width if + * it's already available. + */ - // Shuffle can be isInitialized with a sort object. It is the same object - // given to the sort method. - initialSort: null, + }, { + key: '_setColumns', + value: function _setColumns() { + var containerWidth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Shuffle.getSize(this.element).width; - // By default, shuffle will throttle resize events. This can be changed or - // removed. - throttle: __WEBPACK_IMPORTED_MODULE_4_throttleit___default.a, + var gutter = this._getGutterSize(containerWidth); + var columnWidth = this._getColumnSize(containerWidth, gutter); + var calculatedColumns = (containerWidth + gutter) / columnWidth; - // How often shuffle can be called on resize (in milliseconds). - throttleTime: 300, + // Widths given from getStyles are not precise enough... + if (Math.abs(Math.round(calculatedColumns) - calculatedColumns) < this.options.columnThreshold) { + // e.g. calculatedColumns = 11.998876 + calculatedColumns = Math.round(calculatedColumns); + } - // Transition delay offset for each item in milliseconds. - staggerAmount: 15, + this.cols = Math.max(Math.floor(calculatedColumns), 1); + this.containerWidth = containerWidth; + this.colWidth = columnWidth; + } - // Maximum stagger delay in milliseconds. - staggerAmountMax: 250, + /** + * Adjust the height of the grid + */ - // Whether to use transforms or absolute positioning. - useTransforms: true -}; + }, { + key: '_setContainerSize', + value: function _setContainerSize() { + this.element.style.height = this._getContainerSize() + 'px'; + } -// Expose for testing. Hack at your own risk. -Shuffle.__Point = __WEBPACK_IMPORTED_MODULE_6__point__["a" /* default */]; -Shuffle.__sorter = __WEBPACK_IMPORTED_MODULE_10__sorter__["a" /* default */]; -Shuffle.__getColumnSpan = __WEBPACK_IMPORTED_MODULE_12__layout__["b" /* getColumnSpan */]; -Shuffle.__getAvailablePositions = __WEBPACK_IMPORTED_MODULE_12__layout__["c" /* getAvailablePositions */]; -Shuffle.__getShortColumn = __WEBPACK_IMPORTED_MODULE_12__layout__["d" /* getShortColumn */]; + /** + * Based on the column heights, it returns the biggest one. + * @return {number} + * @private + */ -/* harmony default export */ __webpack_exports__["default"] = Shuffle; + }, { + key: '_getContainerSize', + value: function _getContainerSize() { + return arrayMax(this.positions); + } -/***/ }), -/* 5 */ -/***/ (function(module, exports) { + /** + * Get the clamped stagger amount. + * @param {number} index Index of the item to be staggered. + * @return {number} + */ -module.exports = function parallel(fns, context, callback) { - if (!callback) { - if (typeof context === 'function') { - callback = context - context = null - } else { - callback = noop + }, { + key: '_getStaggerAmount', + value: function _getStaggerAmount(index$$1) { + return Math.min(index$$1 * this.options.staggerAmount, this.options.staggerAmountMax); } - } - var pending = fns && fns.length - if (!pending) return callback(null, []); + /** + * @return {boolean} Whether the event was prevented or not. + */ + + }, { + key: '_dispatch', + value: function _dispatch(name) { + var details = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var finished = false - var results = new Array(pending) + if (this.isDestroyed) { + return; + } - fns.forEach(context ? function (fn, i) { - fn.call(context, maybeDone(i)) - } : function (fn, i) { - fn(maybeDone(i)) - }) + details.shuffle = this; + return !this.element.dispatchEvent(new CustomEvent(name, { + bubbles: true, + cancelable: false, + detail: details + })); + } - function maybeDone(i) { - return function (err, result) { - if (finished) return; + /** + * Zeros out the y columns array, which is used to determine item placement. + * @private + */ - if (err) { - callback(err, results) - finished = true - return + }, { + key: '_resetCols', + value: function _resetCols() { + var i = this.cols; + this.positions = []; + while (i--) { + this.positions.push(0); } - - results[i] = result - - if (!--pending) callback(null, results); } - } -} -function noop() {} + /** + * Loops through each item that should be shown and calculates the x, y position. + * @param {Array.} items Array of items that will be shown/layed + * out in order in their array. + */ + }, { + key: '_layout', + value: function _layout(items) { + var _this3 = this; -/***/ }), -/* 6 */ -/***/ (function(module, exports, __webpack_require__) { + var count = 0; + items.forEach(function (item) { + var currPos = item.point; + var currScale = item.scale; + var itemSize = Shuffle.getSize(item.element, true); + var pos = _this3._getItemPosition(itemSize); -"use strict"; -/* WEBPACK VAR INJECTION */(function(global) { + function callback() { + item.element.style.transitionDelay = ''; + item.applyCss(ShuffleItem.Css.VISIBLE.after); + } -// there's 3 implementations written in increasing order of efficiency + // If the item will not change its position, do not add it to the render + // queue. Transitions don't fire when setting a property to the same value. + if (Point.equals(currPos, pos) && currScale === ShuffleItem.Scale.VISIBLE) { + item.applyCss(ShuffleItem.Css.VISIBLE.before); + callback(); + return; + } -// 1 - no Set type is defined -function uniqNoSet(arr) { - var ret = []; + item.point = pos; + item.scale = ShuffleItem.Scale.VISIBLE; - for (var i = 0; i < arr.length; i++) { - if (ret.indexOf(arr[i]) === -1) { - ret.push(arr[i]); - } - } + // Use xtend here to clone the object so that the `before` object isn't + // modified when the transition delay is added. + var styles = immutable(ShuffleItem.Css.VISIBLE.before); + styles.transitionDelay = _this3._getStaggerAmount(count) + 'ms'; - return ret; -} + _this3._queue.push({ + item: item, + styles: styles, + callback: callback + }); -// 2 - a simple Set type is defined -function uniqSet(arr) { - var seen = new Set(); - return arr.filter(function (el) { - if (!seen.has(el)) { - seen.add(el); - return true; - } + count++; + }); + } - return false; - }); -} + /** + * Determine the location of the next item, based on its size. + * @param {{width: number, height: number}} itemSize Object with width and height. + * @return {Point} + * @private + */ -// 3 - a standard Set type is defined and it has a forEach method -function uniqSetWithForEach(arr) { - var ret = []; + }, { + key: '_getItemPosition', + value: function _getItemPosition(itemSize) { + return getItemPosition({ + itemSize: itemSize, + positions: this.positions, + gridSize: this.colWidth, + total: this.cols, + threshold: this.options.columnThreshold, + buffer: this.options.buffer + }); + } - (new Set(arr)).forEach(function (el) { - ret.push(el); - }); + /** + * Hides the elements that don't match our filter. + * @param {Array.} collection Collection to shrink. + * @private + */ - return ret; -} + }, { + key: '_shrink', + value: function _shrink() { + var _this4 = this; -// V8 currently has a broken implementation -// https://github.com/joyent/node/issues/8449 -function doesForEachActuallyWork() { - var ret = false; + var collection = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._getConcealedItems(); - (new Set([true])).forEach(function (el) { - ret = el; - }); + var count = 0; + collection.forEach(function (item) { + function callback() { + item.applyCss(ShuffleItem.Css.HIDDEN.after); + } - return ret === true; -} + // Continuing would add a transitionend event listener to the element, but + // that listener would not execute because the transform and opacity would + // stay the same. + // The callback is executed here because it is not guaranteed to be called + // after the transitionend event because the transitionend could be + // canceled if another animation starts. + if (item.scale === ShuffleItem.Scale.HIDDEN) { + item.applyCss(ShuffleItem.Css.HIDDEN.before); + callback(); + return; + } -if ('Set' in global) { - if (typeof Set.prototype.forEach === 'function' && doesForEachActuallyWork()) { - module.exports = uniqSetWithForEach; - } else { - module.exports = uniqSet; - } -} else { - module.exports = uniqNoSet; -} + item.scale = ShuffleItem.Scale.HIDDEN; -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(16))) + var styles = immutable(ShuffleItem.Css.HIDDEN.before); + styles.transitionDelay = _this4._getStaggerAmount(count) + 'ms'; -/***/ }), -/* 7 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + _this4._queue.push({ + item: item, + styles: styles, + callback: callback + }); -"use strict"; + count++; + }); + } -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); + /** + * Resize handler. + * @private + */ -var width = window.getComputedStyle(e, null).width; -var ret = width === '10px'; + }, { + key: '_handleResize', + value: function _handleResize() { + // If shuffle is disabled, destroyed, don't do anything + if (!this.isEnabled || this.isDestroyed) { + return; + } -element.removeChild(e); + // Will need to check height in the future if it's layed out horizontaly + var containerWidth = Shuffle.getSize(this.element).width; -/* harmony default export */ __webpack_exports__["a"] = ret; + // containerWidth hasn't changed, don't do anything + if (containerWidth === this.containerWidth) { + return; + } -/***/ }), -/* 8 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + this.update(); + } -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__get_number__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__computed_size__ = __webpack_require__(7); -/* harmony export (immutable) */ __webpack_exports__["a"] = getNumberStyle; + /** + * Returns styles which will be applied to the an item for a transition. + * @param {Object} obj Transition options. + * @return {!Object} Transforms for transitions, left/top for animate. + * @private + */ + }, { + key: '_getStylesForTransition', + value: function _getStylesForTransition(_ref2) { + var item = _ref2.item, + styles = _ref2.styles; + if (!styles.transitionDelay) { + styles.transitionDelay = '0ms'; + } + var x = item.point.x; + var y = item.point.y; + if (this.options.useTransforms) { + styles.transform = 'translate(' + x + 'px, ' + y + 'px) scale(' + item.scale + ')'; + } else { + styles.left = x + 'px'; + styles.top = y + 'px'; + } -/** - * Retrieve the computed style for an element, parsed as a float. - * @param {Element} element Element to get style for. - * @param {string} style Style property. - * @param {CSSStyleDeclaration} [styles] Optionally include clean styles to - * use instead of asking for them again. - * @return {number} The parsed computed value or zero if that fails because IE - * will return 'auto' when the element doesn't have margins instead of - * the computed style. - */ -function getNumberStyle(element, style) { - var styles = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : window.getComputedStyle(element, null); + return styles; + } - var value = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__get_number__["a" /* default */])(styles[style]); + /** + * Listen for the transition end on an element and execute the itemCallback + * when it finishes. + * @param {Element} element Element to listen on. + * @param {Function} itemCallback Callback for the item. + * @param {Function} done Callback to notify `parallel` that this one is done. + */ - // Support IE<=11 and W3C spec. - if (!__WEBPACK_IMPORTED_MODULE_1__computed_size__["a" /* default */] && style === 'width') { - value += __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__get_number__["a" /* default */])(styles.paddingLeft) + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__get_number__["a" /* default */])(styles.paddingRight) + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__get_number__["a" /* default */])(styles.borderLeftWidth) + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__get_number__["a" /* default */])(styles.borderRightWidth); - } else if (!__WEBPACK_IMPORTED_MODULE_1__computed_size__["a" /* default */] && style === 'height') { - value += __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__get_number__["a" /* default */])(styles.paddingTop) + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__get_number__["a" /* default */])(styles.paddingBottom) + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__get_number__["a" /* default */])(styles.borderTopWidth) + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__get_number__["a" /* default */])(styles.borderBottomWidth); - } + }, { + key: '_whenTransitionDone', + value: function _whenTransitionDone(element, itemCallback, done) { + var id = onTransitionEnd(element, function (evt) { + itemCallback(); + done(null, evt); + }); - return value; -} + this._transitions.push(id); + } -/***/ }), -/* 9 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + /** + * Return a function which will set CSS styles and call the `done` function + * when (if) the transition finishes. + * @param {Object} opts Transition object. + * @return {Function} A function to be called with a `done` function. + */ -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__point__ = __webpack_require__(0); -/* harmony export (immutable) */ __webpack_exports__["a"] = getItemPosition; -/* harmony export (immutable) */ __webpack_exports__["b"] = getColumnSpan; -/* harmony export (immutable) */ __webpack_exports__["c"] = getAvailablePositions; -/* harmony export (immutable) */ __webpack_exports__["d"] = getShortColumn; + }, { + key: '_getTransitionFunction', + value: function _getTransitionFunction(opts) { + var _this5 = this; + return function (done) { + opts.item.applyCss(_this5._getStylesForTransition(opts)); + _this5._whenTransitionDone(opts.item.element, opts.callback, done); + }; + } + /** + * Execute the styles gathered in the style queue. This applies styles to elements, + * triggering transitions. + * @private + */ + }, { + key: '_processQueue', + value: function _processQueue() { + if (this.isTransitioning) { + this._cancelMovement(); + } -function arrayMax(array) { - return Math.max.apply(Math, array); -} + var hasSpeed = this.options.speed > 0; + var hasQueue = this._queue.length > 0; -function arrayMin(array) { - return Math.min.apply(Math, array); -} + if (hasQueue && hasSpeed && this.isInitialized) { + this._startTransitions(this._queue); + } else if (hasQueue) { + this._styleImmediately(this._queue); + this._dispatchLayout(); -/** - * Determine the location of the next item, based on its size. - * @param {Object} itemSize Object with width and height. - * @param {Array.} positions Positions of the other current items. - * @param {number} gridSize The column width or row height. - * @param {number} total The total number of columns or rows. - * @param {number} threshold Buffer value for the column to fit. - * @param {number} buffer Vertical buffer for the height of items. - * @return {Point} - */ -function getItemPosition(_ref) { - var itemSize = _ref.itemSize, - positions = _ref.positions, - gridSize = _ref.gridSize, - total = _ref.total, - threshold = _ref.threshold, - buffer = _ref.buffer; + // A call to layout happened, but none of the newly visible items will + // change position or the transition duration is zero, which will not trigger + // the transitionend event. + } else { + this._dispatchLayout(); + } - var span = getColumnSpan(itemSize.width, gridSize, total, threshold); - var setY = getAvailablePositions(positions, span, total); - var shortColumnIndex = getShortColumn(setY, buffer); + // Remove everything in the style queue + this._queue.length = 0; + } - // Position the item - var point = new __WEBPACK_IMPORTED_MODULE_0__point__["a" /* default */](Math.round(gridSize * shortColumnIndex), Math.round(setY[shortColumnIndex])); + /** + * Wait for each transition to finish, the emit the layout event. + * @param {Array.} transitions Array of transition objects. + */ - // Update the columns array with the new values for each column. - // e.g. before the update the columns could be [250, 0, 0, 0] for an item - // which spans 2 columns. After it would be [250, itemHeight, itemHeight, 0]. - var setHeight = setY[shortColumnIndex] + itemSize.height; - for (var i = 0; i < span; i++) { - positions[shortColumnIndex + i] = setHeight; - } + }, { + key: '_startTransitions', + value: function _startTransitions(transitions) { + var _this6 = this; - return point; -} + // Set flag that shuffle is currently in motion. + this.isTransitioning = true; -/** - * Determine the number of columns an items spans. - * @param {number} itemWidth Width of the item. - * @param {number} columnWidth Width of the column (includes gutter). - * @param {number} columns Total number of columns - * @param {number} threshold A buffer value for the size of the column to fit. - * @return {number} - */ -function getColumnSpan(itemWidth, columnWidth, columns, threshold) { - var columnSpan = itemWidth / columnWidth; + // Create an array of functions to be called. + var callbacks = transitions.map(function (obj) { + return _this6._getTransitionFunction(obj); + }); - // If the difference between the rounded column span number and the - // calculated column span number is really small, round the number to - // make it fit. - if (Math.abs(Math.round(columnSpan) - columnSpan) < threshold) { - // e.g. columnSpan = 4.0089945390298745 - columnSpan = Math.round(columnSpan); - } + index$3(callbacks, this._movementFinished.bind(this)); + } + }, { + key: '_cancelMovement', + value: function _cancelMovement() { + // Remove the transition end event for each listener. + this._transitions.forEach(cancelTransitionEnd); - // Ensure the column span is not more than the amount of columns in the whole layout. - return Math.min(Math.ceil(columnSpan), columns); -} + // Reset the array. + this._transitions.length = 0; -/** - * 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.} An array of numbers represeting the column set. - */ -function getAvailablePositions(positions, columnSpan, columns) { - // The item spans only one column. - if (columnSpan === 1) { - return positions; - } + // Show it's no longer active. + this.isTransitioning = false; + } - // The item spans more than one column, figure out how many different - // places it could fit horizontally. - // The group count is the number of places within the positions this block - // could fit, ignoring the current positions of items. - // Imagine a 2 column brick as the second item in a 4 column grid with - // 10px height each. Find the places it would fit: - // [20, 10, 10, 0] - // | | | - // * * * - // - // Then take the places which fit and get the bigger of the two: - // max([20, 10]), max([10, 10]), max([10, 0]) = [20, 10, 0] - // - // Next, find the first smallest number (the short column). - // [20, 10, 0] - // | - // * - // - // And that's where it should be placed! - // - // Another example where the second column's item extends past the first: - // [10, 20, 10, 0] => [20, 20, 10] => 10 - var available = []; + /** + * Apply styles without a transition. + * @param {Array.} objects Array of transition objects. + * @private + */ - // For how many possible positions for this item there are. - for (var i = 0; i <= columns - columnSpan; i++) { - // Find the bigger value for each place it could fit. - available.push(arrayMax(positions.slice(i, i + columnSpan))); - } + }, { + key: '_styleImmediately', + value: function _styleImmediately(objects) { + var _this7 = this; - return available; -} + if (objects.length) { + var elements = objects.map(function (obj) { + return obj.item.element; + }); -/** - * Find index of short column, the first from the left where this item will go. - * - * @param {Array.} positions The array to search for the smallest number. - * @param {number} buffer Optional buffer which is very useful when the height - * is a percentage of the width. - * @return {number} Index of the short column. - */ -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) { - return i; + Shuffle._skipTransitions(elements, function () { + objects.forEach(function (obj) { + obj.item.applyCss(_this7._getStylesForTransition(obj)); + obj.callback(); + }); + }); + } + } + }, { + key: '_movementFinished', + value: function _movementFinished() { + this._transitions.length = 0; + this.isTransitioning = false; + this._dispatchLayout(); + } + }, { + key: '_dispatchLayout', + value: function _dispatchLayout() { + this._dispatch(Shuffle.EventType.LAYOUT); } - } - return 0; -} + /** + * The magic. This is what makes the plugin 'shuffle' + * @param {string|Function|Array.} [category] Category to filter by. + * Can be a function, string, or array of strings. + * @param {Object} [sortObj] A sort object which can sort the visible set + */ -/***/ }), -/* 10 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + }, { + key: 'filter', + value: function filter(category, sortObj) { + if (!this.isEnabled) { + return; + } -"use strict"; -/* harmony export (immutable) */ __webpack_exports__["a"] = onTransitionEnd; -/* harmony export (immutable) */ __webpack_exports__["b"] = cancelTransitionEnd; + if (!category || category && category.length === 0) { + category = Shuffle.ALL_ITEMS; + } + this._filter(category); -var transitions = {}; -var eventName = 'transitionend'; -var count = 0; + // Shrink each hidden item + this._shrink(); -function uniqueId() { - return eventName + count++; -} + // How many visible elements? + this._updateItemCount(); -function onTransitionEnd(element, callback) { - var id = uniqueId(); - var listener = function listener(evt) { - if (evt.currentTarget === evt.target) { - cancelTransitionEnd(id); - callback(evt); + // Update transforms on visible elements so they will animate to their new positions. + this.sort(sortObj); } - }; - - element.addEventListener(eventName, listener); - - transitions[id] = { element: element, listener: listener }; - return id; -} + /** + * Gets the visible elements, sorts them, and passes them to layout. + * @param {Object} opts the options object for the sorted plugin + */ -function cancelTransitionEnd(id) { - if (transitions[id]) { - transitions[id].element.removeEventListener(eventName, transitions[id].listener); - transitions[id] = null; - return true; - } + }, { + key: 'sort', + value: function sort() { + var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.lastSort; - return false; -} + if (!this.isEnabled) { + return; + } -/***/ }), -/* 11 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + this._resetCols(); -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__point__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__classes__ = __webpack_require__(1); -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + var items = this._getFilteredItems(); + items = sorter(items, opts); -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + this._layout(items); + // `_layout` always happens after `_shrink`, so it's safe to process the style + // queue here with styles from the shrink method. + this._processQueue(); + // Adjust the height of the container. + this._setContainerSize(); + this.lastSort = opts; + } -var id = 0; + /** + * Reposition everything. + * @param {boolean} isOnlyLayout If true, column and gutter widths won't be + * recalculated. + */ -var ShuffleItem = function () { - function ShuffleItem(element) { - _classCallCheck(this, ShuffleItem); + }, { + key: 'update', + value: function update(isOnlyLayout) { + if (this.isEnabled) { - this.id = id++; - this.element = element; - this.isVisible = true; - } + if (!isOnlyLayout) { + // Get updated colCount + this._setColumns(); + } - _createClass(ShuffleItem, [{ - key: 'show', - value: function show() { - this.isVisible = true; - this.element.classList.remove(__WEBPACK_IMPORTED_MODULE_1__classes__["a" /* default */].HIDDEN); - this.element.classList.add(__WEBPACK_IMPORTED_MODULE_1__classes__["a" /* default */].VISIBLE); - } - }, { - key: 'hide', - value: function hide() { - this.isVisible = false; - this.element.classList.remove(__WEBPACK_IMPORTED_MODULE_1__classes__["a" /* default */].VISIBLE); - this.element.classList.add(__WEBPACK_IMPORTED_MODULE_1__classes__["a" /* default */].HIDDEN); + // Layout items + this.sort(); + } } + + /** + * Use this instead of `update()` if you don't need the columns and gutters updated + * Maybe an image inside `shuffle` loaded (and now has a height), which means calculations + * could be off. + */ + }, { - key: 'init', - value: function init() { - this.addClasses([__WEBPACK_IMPORTED_MODULE_1__classes__["a" /* default */].SHUFFLE_ITEM, __WEBPACK_IMPORTED_MODULE_1__classes__["a" /* default */].VISIBLE]); - this.applyCss(ShuffleItem.Css.INITIAL); - this.scale = ShuffleItem.Scale.VISIBLE; - this.point = new __WEBPACK_IMPORTED_MODULE_0__point__["a" /* default */](); + key: 'layout', + value: function layout() { + this.update(true); } - }, { - key: 'addClasses', - value: function addClasses(classes) { - var _this = this; - classes.forEach(function (className) { - _this.element.classList.add(className); + /** + * New items have been appended to shuffle. Mix them in with the current + * filter or sort status. + * @param {Array.} newItems Collection of new items. + */ + + }, { + key: 'add', + value: function add(newItems) { + newItems = index$1(newItems).map(function (el) { + return new ShuffleItem(el); }); + + // Add classes and set initial positions. + this._initItems(newItems); + + // Add transition to each item. + this._setTransitions(newItems); + + // Update the list of items. + this.items = this.items.concat(newItems); + this._updateItemsOrder(); + this.filter(this.lastFilter); } - }, { - key: 'removeClasses', - value: function removeClasses(classes) { - var _this2 = this; - classes.forEach(function (className) { - _this2.element.classList.remove(className); - }); + /** + * Disables shuffle from updating dimensions and layout on resize + */ + + }, { + key: 'disable', + value: function disable() { + this.isEnabled = false; } + + /** + * Enables shuffle again + * @param {boolean} [isUpdateLayout=true] if undefined, shuffle will update columns and gutters + */ + }, { - key: 'applyCss', - value: function applyCss(obj) { - for (var key in obj) { - this.element.style[key] = obj[key]; + key: 'enable', + value: function enable(isUpdateLayout) { + this.isEnabled = true; + if (isUpdateLayout !== false) { + this.update(); } } + + /** + * Remove 1 or more shuffle items + * @param {Array.} collection An array containing one or more + * elements in shuffle + * @return {Shuffle} The shuffle object + */ + }, { - key: 'dispose', - value: function dispose() { - this.removeClasses([__WEBPACK_IMPORTED_MODULE_1__classes__["a" /* default */].HIDDEN, __WEBPACK_IMPORTED_MODULE_1__classes__["a" /* default */].VISIBLE, __WEBPACK_IMPORTED_MODULE_1__classes__["a" /* default */].SHUFFLE_ITEM]); + key: 'remove', + value: function remove(collection) { + var _this8 = this; - this.element.removeAttribute('style'); - this.element = null; - } - }]); + if (!collection.length) { + return; + } - return ShuffleItem; -}(); + collection = index$1(collection); -ShuffleItem.Css = { - INITIAL: { - position: 'absolute', - top: 0, - left: 0, - visibility: 'visible', - 'will-change': 'transform' - }, - VISIBLE: { - before: { - opacity: 1, - visibility: 'visible' - }, - after: {} - }, - HIDDEN: { - before: { - opacity: 0 - }, - after: { - visibility: 'hidden' - } - } -}; + var oldItems = collection.map(function (element) { + return _this8.getItemByElement(element); + }).filter(function (item) { + return !!item; + }); -ShuffleItem.Scale = { - VISIBLE: 1, - HIDDEN: 0.001 -}; + var handleLayout = function handleLayout() { + _this8.element.removeEventListener(Shuffle.EventType.LAYOUT, handleLayout); + _this8._disposeItems(oldItems); -/* harmony default export */ __webpack_exports__["a"] = ShuffleItem; + // Remove the collection in the callback + collection.forEach(function (element) { + element.parentNode.removeChild(element); + }); -/***/ }), -/* 12 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + _this8._dispatch(Shuffle.EventType.REMOVED, { collection: collection }); -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_xtend__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_xtend___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_xtend__); -/* harmony export (immutable) */ __webpack_exports__["a"] = sorter; + // Let it get garbage collected + collection = null; + oldItems = null; + }; + // Hide collection first. + this._toggleFilterClasses({ + visible: [], + hidden: oldItems + }); + this._shrink(oldItems); + this.sort(); -// http://stackoverflow.com/a/962890/373422 -function randomize(array) { - var tmp; - var current; - var top = array.length; + // Update the list of items here because `remove` could be called again + // with an item that is in the process of being removed. + this.items = this.items.filter(function (item) { + return !arrayIncludes(oldItems, item); + }); + this._updateItemCount(); - if (!top) { - return array; - } + this.element.addEventListener(Shuffle.EventType.LAYOUT, handleLayout); + } - while (--top) { - current = Math.floor(Math.random() * (top + 1)); - tmp = array[current]; - array[current] = array[top]; - array[top] = tmp; - } + /** + * Retrieve a shuffle item by its element. + * @param {Element} element Element to look for. + * @return {?ShuffleItem} A shuffle item or null if it's not found. + */ - return array; -} + }, { + key: 'getItemByElement', + value: function getItemByElement(element) { + for (var i = this.items.length - 1; i >= 0; i--) { + if (this.items[i].element === element) { + return this.items[i]; + } + } -var defaults = { - // Use array.reverse() to reverse the results - reverse: false, + return null; + } - // Sorting function - by: null, + /** + * Destroys shuffle, removes events, styles, and classes + */ - // If true, this will skip the sorting and return a randomized order in the array - randomize: false, + }, { + key: 'destroy', + value: function destroy() { + this._cancelMovement(); + window.removeEventListener('resize', this._onResize); - // Determines which property of each item in the array is passed to the - // sorting method. - key: 'element' -}; + // Reset container styles + this.element.classList.remove('shuffle'); + this.element.removeAttribute('style'); -// You can return `undefined` from the `by` function to revert to DOM order. -function sorter(arr, options) { - var opts = __WEBPACK_IMPORTED_MODULE_0_xtend___default()(defaults, options); - var original = [].slice.call(arr); - var revert = false; + // Reset individual item styles + this._disposeItems(); + + // Null DOM references + this.items = null; + this.options.sizer = null; + this.element = null; + this._transitions = null; - if (!arr.length) { - return []; - } + // Set a flag so if a debounced resize has been triggered, + // it can first check if it is actually isDestroyed and not doing anything + this.isDestroyed = true; + } - if (opts.randomize) { - return randomize(arr); - } + /** + * Returns the outer width of an element, optionally including its margins. + * + * There are a few different methods for getting the width of an element, none of + * which work perfectly for all Shuffle's use cases. + * + * 1. getBoundingClientRect() `left` and `right` properties. + * - Accounts for transform scaled elements, making it useless for Shuffle + * elements which have shrunk. + * 2. The `offsetWidth` property. + * - This value stays the same regardless of the elements transform property, + * however, it does not return subpixel values. + * 3. getComputedStyle() + * - This works great Chrome, Firefox, Safari, but IE<=11 does not include + * padding and border when box-sizing: border-box is set, requiring a feature + * test and extra work to add the padding back for IE and other browsers which + * follow the W3C spec here. + * + * @param {Element} element The element. + * @param {boolean} [includeMargins] Whether to include margins. Default is false. + * @return {{width: number, height: number}} The width and height. + */ - // Sort the elements by the opts.by function. - // If we don't have opts.by, default to DOM order - if (typeof opts.by === 'function') { - arr.sort(function (a, b) { + }], [{ + key: 'getSize', + value: function getSize(element, includeMargins) { + // Store the styles so that they can be used by others without asking for it again. + var styles = window.getComputedStyle(element, null); + var width = getNumberStyle(element, 'width', styles); + var height = getNumberStyle(element, 'height', styles); - // Exit early if we already know we want to revert - if (revert) { - return 0; + if (includeMargins) { + var marginLeft = getNumberStyle(element, 'marginLeft', styles); + var marginRight = getNumberStyle(element, 'marginRight', styles); + var marginTop = getNumberStyle(element, 'marginTop', styles); + var marginBottom = getNumberStyle(element, 'marginBottom', styles); + width += marginLeft + marginRight; + height += marginTop + marginBottom; } - var valA = opts.by(a[opts.key]); - var valB = opts.by(b[opts.key]); + return { + width: width, + height: height + }; + } - // If both values are undefined, use the DOM order - if (valA === undefined && valB === undefined) { - revert = true; - return 0; - } + /** + * Change a property or execute a function which will not have a transition + * @param {Array.} elements DOM elements that won't be transitioned. + * @param {Function} callback A function which will be called while transition + * is set to 0ms. + * @private + */ - if (valA < valB || valA === 'sortFirst' || valB === 'sortLast') { - return -1; - } + }, { + key: '_skipTransitions', + value: function _skipTransitions(elements, callback) { + var zero = '0ms'; - if (valA > valB || valA === 'sortLast' || valB === 'sortFirst') { - return 1; - } + // Save current duration and delay. + var data = elements.map(function (element) { + var style = element.style; + var duration = style.transitionDuration; + var delay = style.transitionDelay; - return 0; - }); - } + // Set the duration to zero so it happens immediately + style.transitionDuration = zero; + style.transitionDelay = zero; - // Revert to the original array if necessary - if (revert) { - return original; - } + return { + duration: duration, + delay: delay + }; + }); - if (opts.reverse) { - arr.reverse(); - } + callback(); - return arr; -} + // Cause reflow. + elements[0].offsetWidth; // jshint ignore:line -/***/ }), -/* 13 */ -/***/ (function(module, exports) { + // Put the duration back + elements.forEach(function (element, i) { + element.style.transitionDuration = data[i].duration; + element.style.transitionDelay = data[i].delay; + }); + } + }]); + return Shuffle; +}(); -// Polyfill for creating CustomEvents on IE9/10/11 +Shuffle.ShuffleItem = ShuffleItem; -// code pulled from: -// https://github.com/d4tocchini/customevent-polyfill -// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent#Polyfill +Shuffle.ALL_ITEMS = 'all'; +Shuffle.FILTER_ATTRIBUTE_KEY = 'groups'; -try { - var ce = new window.CustomEvent('test'); - ce.preventDefault(); - if (ce.defaultPrevented !== true) { - // IE has problems with .preventDefault() on custom events - // http://stackoverflow.com/questions/23349191 - throw new Error('Could not prevent default'); - } -} catch(e) { - var CustomEvent = function(event, params) { - var evt, origPrevent; - params = params || { - bubbles: false, - cancelable: false, - detail: undefined - }; +/** + * @enum {string} + */ +Shuffle.EventType = { + LAYOUT: 'shuffle:layout', + REMOVED: 'shuffle:removed' +}; - evt = document.createEvent("CustomEvent"); - evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); - origPrevent = evt.preventDefault; - evt.preventDefault = function () { - origPrevent.call(this); - try { - Object.defineProperty(this, 'defaultPrevented', { - get: function () { - return true; - } - }); - } catch(e) { - this.defaultPrevented = true; - } - }; - return evt; - }; +/** @enum {string} */ +Shuffle.Classes = Classes; - CustomEvent.prototype = window.Event.prototype; - window.CustomEvent = CustomEvent; // expose definition to window -} +// Overrideable options +Shuffle.options = { + // Initial filter group. + group: Shuffle.ALL_ITEMS, + // Transition/animation speed (milliseconds). + speed: 250, -/***/ }), -/* 14 */ -/***/ (function(module, exports, __webpack_require__) { + // CSS easing function to use. + easing: 'ease', -"use strict"; + // e.g. '.picture-item'. + itemSelector: '*', + // Element or selector string. Use an element to determine the size of columns + // and gutters. + sizer: null, -var proto = Element.prototype; -var vendor = proto.matches - || proto.matchesSelector - || proto.webkitMatchesSelector - || proto.mozMatchesSelector - || proto.msMatchesSelector - || proto.oMatchesSelector; + // A static number or function that tells the plugin how wide the gutters + // between columns are (in pixels). + gutterWidth: 0, -module.exports = match; + // A static number or function that returns a number which tells the plugin + // how wide the columns are (in pixels). + columnWidth: 0, -/** - * Match `el` to `selector`. - * - * @param {Element} el - * @param {String} selector - * @return {Boolean} - * @api public - */ + // If your group is not json, and is comma delimeted, you could set delimeter + // to ','. + delimeter: null, -function match(el, selector) { - if (vendor) return vendor.call(el, selector); - var nodes = el.parentNode.querySelectorAll(selector); - for (var i = 0; i < nodes.length; i++) { - if (nodes[i] == el) return true; - } - return false; -} + // Useful for percentage based heights when they might not always be exactly + // the same (in pixels). + buffer: 0, -/***/ }), -/* 15 */ -/***/ (function(module, exports) { + // Reading the width of elements isn't precise enough and can cause columns to + // jump between values. + columnThreshold: 0.01, -module.exports = throttle; + // Shuffle can be isInitialized with a sort object. It is the same object + // given to the sort method. + initialSort: null, -/** - * Returns a new function that, when invoked, invokes `func` at most once per `wait` milliseconds. - * - * @param {Function} func Function to wrap. - * @param {Number} wait Number of milliseconds that must elapse between `func` invocations. - * @return {Function} A new function that wraps the `func` function passed in. - */ + // By default, shuffle will throttle resize events. This can be changed or + // removed. + throttle: index$2, -function throttle (func, wait) { - var ctx, args, rtn, timeoutID; // caching - var last = 0; + // How often shuffle can be called on resize (in milliseconds). + throttleTime: 300, - return function throttled () { - ctx = this; - args = arguments; - var delta = new Date() - last; - if (!timeoutID) - if (delta >= wait) call(); - else timeoutID = setTimeout(call, wait - delta); - return rtn; - }; + // Transition delay offset for each item in milliseconds. + staggerAmount: 15, - function call () { - timeoutID = 0; - last = +new Date(); - rtn = func.apply(ctx, args); - ctx = null; - args = null; - } -} + // Maximum stagger delay in milliseconds. + staggerAmountMax: 250, + + // Whether to use transforms or absolute positioning. + useTransforms: true +}; + +// Expose for testing. Hack at your own risk. +Shuffle.__Point = Point; +Shuffle.__sorter = sorter; +Shuffle.__getColumnSpan = getColumnSpan; +Shuffle.__getAvailablePositions = getAvailablePositions; +Shuffle.__getShortColumn = getShortColumn; +return Shuffle; -/***/ }), -/* 16 */ -/***/ (function(module, exports) { - -var g; - -// This works in non-strict mode -g = (function() { - return this; -})(); - -try { - // This works if eval is allowed (see CSP) - g = g || Function("return this")() || (1,eval)("this"); -} catch(e) { - // This works if the window reference is available - if(typeof window === "object") - g = window; -} - -// g can still be undefined, but nothing to do about it... -// We return undefined, instead of nothing here, so it's -// easier to handle this case. if(!global) { ...} - -module.exports = g; - - -/***/ }), -/* 17 */ -/***/ (function(module, exports, __webpack_require__) { - -module.exports = __webpack_require__(4).default; - -/***/ }) -/******/ ]); -}); -//# sourceMappingURL=shuffle.js.map \ No newline at end of file +}))); +//# sourceMappingURL=shuffle.js.map diff --git a/dist/shuffle.js.map b/dist/shuffle.js.map index 23c3892..bbc09c7 100644 --- a/dist/shuffle.js.map +++ b/dist/shuffle.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap cf4e5aea55e23a3220b7","webpack:///./src/point.js","webpack:///./src/classes.js","webpack:///./src/get-number.js","webpack:///./~/xtend/immutable.js","webpack:///./src/shuffle.js","webpack:///./~/array-parallel/index.js","webpack:///./~/array-uniq/index.js","webpack:///./src/computed-size.js","webpack:///./src/get-number-style.js","webpack:///./src/layout.js","webpack:///./src/on-transition-end.js","webpack:///./src/shuffle-item.js","webpack:///./src/sorter.js","webpack:///./~/custom-event-polyfill/custom-event-polyfill.js","webpack:///./~/matches-selector/index.js","webpack:///./~/throttleit/index.js","webpack:///(webpack)/buildin/global.js","webpack:///./src/index.js"],"names":["Point","x","y","getNumber","equals","a","b","BASE","SHUFFLE_ITEM","VISIBLE","HIDDEN","value","parseFloat","toArray","arrayLike","Array","prototype","slice","call","arrayMax","array","Math","max","apply","arrayIncludes","obj","arguments","length","indexOf","id","Shuffle","element","options","xtend","useSizer","lastSort","group","lastFilter","ALL_ITEMS","isEnabled","isDestroyed","isInitialized","_transitions","isTransitioning","_queue","_getElementOption","TypeError","_init","items","_getItems","sizer","classList","add","Classes","_initItems","_onResize","_getResizeFunction","window","addEventListener","containerCss","getComputedStyle","containerWidth","getSize","width","_validateStyles","_setColumns","filter","initialSort","offsetWidth","_setTransitions","style","transition","speed","easing","resizeFunction","_handleResize","bind","throttle","throttleTime","option","querySelector","nodeType","jquery","styles","position","overflow","category","collection","set","_getFilteredSets","_toggleFilterClasses","visible","hidden","forEach","item","_doesPassFilter","push","attr","getAttribute","FILTER_ATTRIBUTE_KEY","keys","delimeter","split","JSON","parse","isArray","some","show","hide","init","dispose","visibleItems","_getFilteredItems","str","useTransforms","children","matches","el","itemSelector","map","sorter","by","isVisible","gutterSize","size","columnWidth","gutterWidth","getNumberStyle","gutter","_getGutterSize","_getColumnSize","calculatedColumns","abs","round","columnThreshold","cols","floor","colWidth","height","_getContainerSize","positions","index","min","staggerAmount","staggerAmountMax","name","details","shuffle","dispatchEvent","CustomEvent","bubbles","cancelable","detail","i","count","currPos","point","currScale","scale","itemSize","pos","_getItemPosition","callback","transitionDelay","applyCss","ShuffleItem","Css","after","Scale","before","_getStaggerAmount","getItemPosition","gridSize","total","threshold","buffer","_getConcealedItems","update","transform","left","top","itemCallback","done","onTransitionEnd","evt","opts","_getStylesForTransition","_whenTransitionDone","_cancelMovement","hasSpeed","hasQueue","_startTransitions","_styleImmediately","_dispatchLayout","transitions","callbacks","_getTransitionFunction","parallel","_movementFinished","objects","elements","_skipTransitions","_dispatch","EventType","LAYOUT","sortObj","_filter","_shrink","_updateItemCount","sort","_resetCols","_layout","_processQueue","_setContainerSize","isOnlyLayout","newItems","arrayUnique","concat","_updateItemsOrder","isUpdateLayout","oldItems","getItemByElement","handleLayout","removeEventListener","_disposeItems","parentNode","removeChild","REMOVED","remove","removeAttribute","includeMargins","marginLeft","marginRight","marginTop","marginBottom","zero","data","duration","transitionDuration","delay","__Point","__sorter","__getColumnSpan","__getAvailablePositions","__getShortColumn","document","body","documentElement","e","createElement","cssText","appendChild","ret","paddingLeft","paddingRight","borderLeftWidth","borderRightWidth","paddingTop","paddingBottom","borderTopWidth","borderBottomWidth","arrayMin","span","getColumnSpan","setY","getAvailablePositions","shortColumnIndex","getShortColumn","setHeight","itemWidth","columns","columnSpan","ceil","available","minPosition","len","eventName","uniqueId","listener","currentTarget","target","cancelTransitionEnd","addClasses","INITIAL","classes","className","key","removeClasses","visibility","opacity","randomize","tmp","current","random","defaults","reverse","arr","original","revert","valA","valB","undefined","module","exports","require","default"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA,mDAA2C,cAAc;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;;AChEA;;AAEA;;AAEA;;;;;AAKA,IAAMA,QAAQ,SAARA,KAAQ,CAAUC,CAAV,EAAaC,CAAb,EAAgB;AAC5B,OAAKD,CAAL,GAAS,mFAAAE,CAAUF,CAAV,CAAT;AACA,OAAKC,CAAL,GAAS,mFAAAC,CAAUD,CAAV,CAAT;AACD,CAHD;;AAKA;;;;;;AAMAF,MAAMI,MAAN,GAAe,UAAUC,CAAV,EAAaC,CAAb,EAAgB;AAC7B,SAAOD,EAAEJ,CAAF,KAAQK,EAAEL,CAAV,IAAeI,EAAEH,CAAF,KAAQI,EAAEJ,CAAhC;AACD,CAFD;;AAIA,wDAAeF,KAAf,C;;;;;;;ACxBA,wDAAe;AACbO,QAAM,SADO;AAEbC,gBAAc,cAFD;AAGbC,WAAS,uBAHI;AAIbC,UAAQ;AAJK,CAAf,C;;;;;;;;ACAA;;AAEA;;;;;;AAKe,SAASP,SAAT,CAAmBQ,KAAnB,EAA0B;AACvC,SAAOC,WAAWD,KAAX,KAAqB,CAA5B;AACD,C;;;;;;ACTD;;AAEA;;AAEA;AACA;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AAS,WAAxB,IAAuCC,SAAS,UAApD,EAAgE;AAC9D,eAAO,CAAC,CAAR;AACD;;AAED,UAAID,OAAOC,IAAP,IAAeD,SAAS,UAAxB,IAAsCC,SAAS,WAAnD,EAAgE;AAC9D,eAAO,CAAP;AACD;;AAED,aAAO,CAAP;AACD,KAzBD;AA0BD;;AAED;AACA,MAAIF,MAAJ,EAAY;AACV,WAAOD,QAAP;AACD;;AAED,MAAIhH,KAAK8G,OAAT,EAAkB;AAChBC,QAAID,OAAJ;AACD;;AAED,SAAOC,GAAP;AACD,C;;;;;;AC9FD;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA,mCAAmC;AACnC;;;;;;;;AC3CA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,kBAAkB;AACnC;AACA;AACA;AACA,C;;;;;;AC5BA;;AAEA;AACA;AACA;AACA,WAAW,SAAS;AACpB,WAAW,OAAO;AAClB,YAAY,SAAS;AACrB;;AAEA;AACA,gCAAgC;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC/BA;;AAEA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;;AAEA;AACA;AACA,4CAA4C;;AAE5C;;;;;;;ACpBAM,OAAOC,OAAP,GAAiB,mBAAAC,CAAQ,CAAR,EAAqBC,OAAtC,C","file":"shuffle.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"shuffle\"] = factory();\n\telse\n\t\troot[\"shuffle\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 17);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap cf4e5aea55e23a3220b7","'use strict';\n\nimport getNumber from './get-number';\n\n/**\n * Represents a coordinate pair.\n * @param {number} [x=0] X.\n * @param {number} [y=0] Y.\n */\nconst Point = function (x, y) {\n this.x = getNumber(x);\n this.y = getNumber(y);\n};\n\n/**\n * Whether two points are equal.\n * @param {Point} a Point A.\n * @param {Point} b Point B.\n * @return {boolean}\n */\nPoint.equals = function (a, b) {\n return a.x === b.x && a.y === b.y;\n};\n\nexport default Point;\n\n\n\n// WEBPACK FOOTER //\n// ./src/point.js","export default {\n BASE: 'shuffle',\n SHUFFLE_ITEM: 'shuffle-item',\n VISIBLE: 'shuffle-item--visible',\n HIDDEN: 'shuffle-item--hidden',\n};\n\n\n\n// WEBPACK FOOTER //\n// ./src/classes.js","'use strict';\n\n/**\n * Always returns a numeric value, given a value. Logic from jQuery's `isNumeric`.\n * @param {*} value Possibly numeric value.\n * @return {number} `value` or zero if `value` isn't numeric.\n */\nexport default function getNumber(value) {\n return parseFloat(value) || 0;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/get-number.js","module.exports = extend\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nfunction extend() {\n var target = {}\n\n for (var i = 0; i < arguments.length; i++) {\n var source = arguments[i]\n\n for (var key in source) {\n if (hasOwnProperty.call(source, key)) {\n target[key] = source[key]\n }\n }\n }\n\n return target\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/xtend/immutable.js\n// module id = 3\n// module chunks = 0","'use strict';\n\nimport 'custom-event-polyfill';\nimport matches from 'matches-selector';\nimport arrayUnique from 'array-uniq';\nimport xtend from 'xtend';\nimport throttle from 'throttleit';\nimport parallel from 'array-parallel';\nimport Point from './point';\nimport ShuffleItem from './shuffle-item';\nimport Classes from './classes';\nimport getNumberStyle from './get-number-style';\nimport sorter from './sorter';\nimport { onTransitionEnd, cancelTransitionEnd } from './on-transition-end';\nimport { getItemPosition, getColumnSpan, getAvailablePositions, getShortColumn } from './layout';\n\nfunction toArray(arrayLike) {\n return Array.prototype.slice.call(arrayLike);\n}\n\nfunction arrayMax(array) {\n return Math.max.apply(Math, array);\n}\n\nfunction arrayIncludes(array, obj) {\n if (arguments.length === 2) {\n return arrayIncludes(array)(obj);\n }\n\n return function (obj) {\n return array.indexOf(obj) > -1;\n };\n}\n\n// Used for unique instance variables\nlet id = 0;\n\nclass Shuffle {\n\n /**\n * Categorize, sort, and filter a responsive grid of items.\n *\n * @param {Element} element An element which is the parent container for the grid items.\n * @param {Object} [options=Shuffle.options] Options object.\n * @constructor\n */\n constructor(element, options = {}) {\n this.options = xtend(Shuffle.options, options);\n\n this.useSizer = false;\n this.lastSort = {};\n this.group = this.lastFilter = Shuffle.ALL_ITEMS;\n this.isEnabled = true;\n this.isDestroyed = false;\n this.isInitialized = false;\n this._transitions = [];\n this.isTransitioning = false;\n this._queue = [];\n\n element = this._getElementOption(element);\n\n if (!element) {\n throw new TypeError('Shuffle needs to be initialized with an element.');\n }\n\n this.element = element;\n this.id = 'shuffle_' + id++;\n\n this._init();\n this.isInitialized = true;\n }\n\n _init() {\n this.items = this._getItems();\n\n this.options.sizer = this._getElementOption(this.options.sizer);\n\n if (this.options.sizer) {\n this.useSizer = true;\n }\n\n // Add class and invalidate styles\n this.element.classList.add(Shuffle.Classes.BASE);\n\n // Set initial css for each item\n this._initItems();\n\n // Bind resize events\n this._onResize = this._getResizeFunction();\n window.addEventListener('resize', this._onResize);\n\n // Get container css all in one request. Causes reflow\n var containerCss = window.getComputedStyle(this.element, null);\n var containerWidth = Shuffle.getSize(this.element).width;\n\n // Add styles to the container if it doesn't have them.\n this._validateStyles(containerCss);\n\n // We already got the container's width above, no need to cause another\n // reflow getting it again... Calculate the number of columns there will be\n this._setColumns(containerWidth);\n\n // Kick off!\n this.filter(this.options.group, this.options.initialSort);\n\n // The shuffle items haven't had transitions set on them yet so the user\n // doesn't see the first layout. Set them now that the first layout is done.\n // First, however, a synchronous layout must be caused for the previous\n // styles to be applied without transitions.\n this.element.offsetWidth; // jshint ignore: line\n this._setTransitions();\n this.element.style.transition = 'height ' + this.options.speed + 'ms ' + this.options.easing;\n }\n\n /**\n * Returns a throttled and proxied function for the resize handler.\n * @return {Function}\n * @private\n */\n _getResizeFunction() {\n var resizeFunction = this._handleResize.bind(this);\n return this.options.throttle ?\n this.options.throttle(resizeFunction, this.options.throttleTime) :\n resizeFunction;\n }\n\n /**\n * Retrieve an element from an option.\n * @param {string|jQuery|Element} option The option to check.\n * @return {?Element} The plain element or null.\n * @private\n */\n _getElementOption(option) {\n // If column width is a string, treat is as a selector and search for the\n // sizer element within the outermost container\n if (typeof option === 'string') {\n return this.element.querySelector(option);\n\n // Check for an element\n } else if (option && option.nodeType && option.nodeType === 1) {\n return option;\n\n // Check for jQuery object\n } else if (option && option.jquery) {\n return option[0];\n }\n\n return null;\n }\n\n /**\n * Ensures the shuffle container has the css styles it needs applied to it.\n * @param {Object} styles Key value pairs for position and overflow.\n * @private\n */\n _validateStyles(styles) {\n // Position cannot be static.\n if (styles.position === 'static') {\n this.element.style.position = 'relative';\n }\n\n // Overflow has to be hidden.\n if (styles.overflow !== 'hidden') {\n this.element.style.overflow = 'hidden';\n }\n }\n\n /**\n * Filter the elements by a category.\n * @param {string} [category] Category to filter by. If it's given, the last\n * category will be used to filter the items.\n * @param {Array} [collection] Optionally filter a collection. Defaults to\n * all the items.\n * @return {!{visible: Array, hidden: Array}}\n * @private\n */\n _filter(category = this.lastFilter, collection = this.items) {\n var set = this._getFilteredSets(category, collection);\n\n // Individually add/remove hidden/visible classes\n this._toggleFilterClasses(set);\n\n // Save the last filter in case elements are appended.\n this.lastFilter = category;\n\n // This is saved mainly because providing a filter function (like searching)\n // will overwrite the `lastFilter` property every time its called.\n if (typeof category === 'string') {\n this.group = category;\n }\n\n return set;\n }\n\n /**\n * Returns an object containing the visible and hidden elements.\n * @param {string|Function} category Category or function to filter by.\n * @param {Array.} items A collection of items to filter.\n * @return {!{visible: Array, hidden: Array}}\n * @private\n */\n _getFilteredSets(category, items) {\n let visible = [];\n let hidden = [];\n\n // category === 'all', add visible class to everything\n if (category === Shuffle.ALL_ITEMS) {\n visible = items;\n\n // Loop through each item and use provided function to determine\n // whether to hide it or not.\n } else {\n items.forEach((item) => {\n if (this._doesPassFilter(category, item.element)) {\n visible.push(item);\n } else {\n hidden.push(item);\n }\n });\n }\n\n return {\n visible,\n hidden,\n };\n }\n\n /**\n * Test an item to see if it passes a category.\n * @param {string|Function} category Category or function to filter by.\n * @param {Element} element An element to test.\n * @return {boolean} Whether it passes the category/filter.\n * @private\n */\n _doesPassFilter(category, element) {\n\n if (typeof category === 'function') {\n return category.call(element, element, this);\n\n // Check each element's data-groups attribute against the given category.\n } else {\n let attr = element.getAttribute('data-' + Shuffle.FILTER_ATTRIBUTE_KEY);\n let keys = this.options.delimeter ?\n attr.split(this.options.delimeter) :\n JSON.parse(attr);\n\n if (Array.isArray(category)) {\n return category.some(arrayIncludes(keys));\n }\n\n return arrayIncludes(keys, category);\n }\n }\n\n /**\n * Toggles the visible and hidden class names.\n * @param {{visible, hidden}} Object with visible and hidden arrays.\n * @private\n */\n _toggleFilterClasses({ visible, hidden }) {\n visible.forEach((item) => {\n item.show();\n });\n\n hidden.forEach((item) => {\n item.hide();\n });\n }\n\n /**\n * Set the initial css for each item\n * @param {Array.} [items] Optionally specifiy at set to initialize.\n * @private\n */\n _initItems(items = this.items) {\n items.forEach((item) => {\n item.init();\n });\n }\n\n /**\n * Remove element reference and styles.\n * @private\n */\n _disposeItems(items = this.items) {\n items.forEach((item) => {\n item.dispose();\n });\n }\n\n /**\n * Updates the visible item count.\n * @private\n */\n _updateItemCount() {\n this.visibleItems = this._getFilteredItems().length;\n }\n\n /**\n * Sets css transform transition on a group of elements. This is not executed\n * at the same time as `item.init` so that transitions don't occur upon\n * initialization of Shuffle.\n * @param {Array.} items Shuffle items to set transitions on.\n * @private\n */\n _setTransitions(items = this.items) {\n let speed = this.options.speed;\n let easing = this.options.easing;\n\n var str;\n if (this.options.useTransforms) {\n str = 'transform ' + speed + 'ms ' + easing +\n ', opacity ' + speed + 'ms ' + easing;\n } else {\n str = 'top ' + speed + 'ms ' + easing +\n ', left ' + speed + 'ms ' + easing +\n ', opacity ' + speed + 'ms ' + easing;\n }\n\n items.forEach((item) => {\n item.element.style.transition = str;\n });\n }\n\n _getItems() {\n return toArray(this.element.children)\n .filter(el => matches(el, this.options.itemSelector))\n .map(el => new ShuffleItem(el));\n }\n\n /**\n * When new elements are added to the shuffle container, update the array of\n * items because that is the order `_layout` calls them.\n */\n _updateItemsOrder() {\n let children = this.element.children;\n this.items = sorter(this.items, {\n by(element) {\n return Array.prototype.indexOf.call(children, element);\n },\n });\n }\n\n _getFilteredItems() {\n return this.items.filter(item => item.isVisible);\n }\n\n _getConcealedItems() {\n return this.items.filter(item => !item.isVisible);\n }\n\n /**\n * Returns the column size, based on column width and sizer options.\n * @param {number} containerWidth Size of the parent container.\n * @param {number} gutterSize Size of the gutters.\n * @return {number}\n * @private\n */\n _getColumnSize(containerWidth, gutterSize) {\n var size;\n\n // If the columnWidth property is a function, then the grid is fluid\n if (typeof this.options.columnWidth === 'function') {\n size = this.options.columnWidth(containerWidth);\n\n // columnWidth option isn't a function, are they using a sizing element?\n } else if (this.useSizer) {\n size = Shuffle.getSize(this.options.sizer).width;\n\n // if not, how about the explicitly set option?\n } else if (this.options.columnWidth) {\n size = this.options.columnWidth;\n\n // or use the size of the first item\n } else if (this.items.length > 0) {\n size = Shuffle.getSize(this.items[0].element, true).width;\n\n // if there's no items, use size of container\n } else {\n size = containerWidth;\n }\n\n // Don't let them set a column width of zero.\n if (size === 0) {\n size = containerWidth;\n }\n\n return size + gutterSize;\n }\n\n /**\n * Returns the gutter size, based on gutter width and sizer options.\n * @param {number} containerWidth Size of the parent container.\n * @return {number}\n * @private\n */\n _getGutterSize(containerWidth) {\n var size;\n if (typeof this.options.gutterWidth === 'function') {\n size = this.options.gutterWidth(containerWidth);\n } else if (this.useSizer) {\n size = getNumberStyle(this.options.sizer, 'marginLeft');\n } else {\n size = this.options.gutterWidth;\n }\n\n return size;\n }\n\n /**\n * Calculate the number of columns to be used. Gets css if using sizer element.\n * @param {number} [containerWidth] Optionally specify a container width if\n * it's already available.\n */\n _setColumns(containerWidth = Shuffle.getSize(this.element).width) {\n var gutter = this._getGutterSize(containerWidth);\n var columnWidth = this._getColumnSize(containerWidth, gutter);\n var calculatedColumns = (containerWidth + gutter) / columnWidth;\n\n // Widths given from getStyles are not precise enough...\n if (Math.abs(Math.round(calculatedColumns) - calculatedColumns) <\n this.options.columnThreshold) {\n // e.g. calculatedColumns = 11.998876\n calculatedColumns = Math.round(calculatedColumns);\n }\n\n this.cols = Math.max(Math.floor(calculatedColumns), 1);\n this.containerWidth = containerWidth;\n this.colWidth = columnWidth;\n }\n\n /**\n * Adjust the height of the grid\n */\n _setContainerSize() {\n this.element.style.height = this._getContainerSize() + 'px';\n }\n\n /**\n * Based on the column heights, it returns the biggest one.\n * @return {number}\n * @private\n */\n _getContainerSize() {\n return arrayMax(this.positions);\n }\n\n /**\n * Get the clamped stagger amount.\n * @param {number} index Index of the item to be staggered.\n * @return {number}\n */\n _getStaggerAmount(index) {\n return Math.min(index * this.options.staggerAmount, this.options.staggerAmountMax);\n }\n\n /**\n * @return {boolean} Whether the event was prevented or not.\n */\n _dispatch(name, details = {}) {\n if (this.isDestroyed) {\n return;\n }\n\n details.shuffle = this;\n return !this.element.dispatchEvent(new CustomEvent(name, {\n bubbles: true,\n cancelable: false,\n detail: details,\n }));\n }\n\n /**\n * Zeros out the y columns array, which is used to determine item placement.\n * @private\n */\n _resetCols() {\n var i = this.cols;\n this.positions = [];\n while (i--) {\n this.positions.push(0);\n }\n }\n\n /**\n * Loops through each item that should be shown and calculates the x, y position.\n * @param {Array.} items Array of items that will be shown/layed\n * out in order in their array.\n */\n _layout(items) {\n let count = 0;\n items.forEach((item) => {\n var currPos = item.point;\n var currScale = item.scale;\n var itemSize = Shuffle.getSize(item.element, true);\n var pos = this._getItemPosition(itemSize);\n\n function callback() {\n item.element.style.transitionDelay = '';\n item.applyCss(ShuffleItem.Css.VISIBLE.after);\n }\n\n // If the item will not change its position, do not add it to the render\n // queue. Transitions don't fire when setting a property to the same value.\n if (Point.equals(currPos, pos) && currScale === ShuffleItem.Scale.VISIBLE) {\n item.applyCss(ShuffleItem.Css.VISIBLE.before);\n callback();\n return;\n }\n\n item.point = pos;\n item.scale = ShuffleItem.Scale.VISIBLE;\n\n // Use xtend here to clone the object so that the `before` object isn't\n // modified when the transition delay is added.\n let styles = xtend(ShuffleItem.Css.VISIBLE.before);\n styles.transitionDelay = this._getStaggerAmount(count) + 'ms';\n\n this._queue.push({\n item,\n styles,\n callback,\n });\n\n count++;\n });\n }\n\n /**\n * Determine the location of the next item, based on its size.\n * @param {{width: number, height: number}} itemSize Object with width and height.\n * @return {Point}\n * @private\n */\n _getItemPosition(itemSize) {\n return getItemPosition({\n itemSize,\n positions: this.positions,\n gridSize: this.colWidth,\n total: this.cols,\n threshold: this.options.columnThreshold,\n buffer: this.options.buffer,\n });\n }\n\n /**\n * Hides the elements that don't match our filter.\n * @param {Array.} collection Collection to shrink.\n * @private\n */\n _shrink(collection = this._getConcealedItems()) {\n let count = 0;\n collection.forEach((item) => {\n function callback() {\n item.applyCss(ShuffleItem.Css.HIDDEN.after);\n }\n\n // Continuing would add a transitionend event listener to the element, but\n // that listener would not execute because the transform and opacity would\n // stay the same.\n // The callback is executed here because it is not guaranteed to be called\n // after the transitionend event because the transitionend could be\n // canceled if another animation starts.\n if (item.scale === ShuffleItem.Scale.HIDDEN) {\n item.applyCss(ShuffleItem.Css.HIDDEN.before);\n callback();\n return;\n }\n\n item.scale = ShuffleItem.Scale.HIDDEN;\n\n let styles = xtend(ShuffleItem.Css.HIDDEN.before);\n styles.transitionDelay = this._getStaggerAmount(count) + 'ms';\n\n this._queue.push({\n item,\n styles,\n callback,\n });\n\n count++;\n });\n }\n\n /**\n * Resize handler.\n * @private\n */\n _handleResize() {\n // If shuffle is disabled, destroyed, don't do anything\n if (!this.isEnabled || this.isDestroyed) {\n return;\n }\n\n // Will need to check height in the future if it's layed out horizontaly\n var containerWidth = Shuffle.getSize(this.element).width;\n\n // containerWidth hasn't changed, don't do anything\n if (containerWidth === this.containerWidth) {\n return;\n }\n\n this.update();\n }\n\n /**\n * Returns styles which will be applied to the an item for a transition.\n * @param {Object} obj Transition options.\n * @return {!Object} Transforms for transitions, left/top for animate.\n * @private\n */\n _getStylesForTransition({ item, styles }) {\n if (!styles.transitionDelay) {\n styles.transitionDelay = '0ms';\n }\n\n let x = item.point.x;\n let y = item.point.y;\n\n if (this.options.useTransforms) {\n styles.transform = `translate(${x}px, ${y}px) scale(${item.scale})`;\n } else {\n styles.left = x + 'px';\n styles.top = y + 'px';\n }\n\n return styles;\n }\n\n /**\n * Listen for the transition end on an element and execute the itemCallback\n * when it finishes.\n * @param {Element} element Element to listen on.\n * @param {Function} itemCallback Callback for the item.\n * @param {Function} done Callback to notify `parallel` that this one is done.\n */\n _whenTransitionDone(element, itemCallback, done) {\n let id = onTransitionEnd(element, (evt) => {\n itemCallback();\n done(null, evt);\n });\n\n this._transitions.push(id);\n }\n\n /**\n * Return a function which will set CSS styles and call the `done` function\n * when (if) the transition finishes.\n * @param {Object} opts Transition object.\n * @return {Function} A function to be called with a `done` function.\n */\n _getTransitionFunction(opts) {\n return (done) => {\n opts.item.applyCss(this._getStylesForTransition(opts));\n this._whenTransitionDone(opts.item.element, opts.callback, done);\n };\n }\n\n /**\n * Execute the styles gathered in the style queue. This applies styles to elements,\n * triggering transitions.\n * @private\n */\n _processQueue() {\n if (this.isTransitioning) {\n this._cancelMovement();\n }\n\n let hasSpeed = this.options.speed > 0;\n let hasQueue = this._queue.length > 0;\n\n if (hasQueue && hasSpeed && this.isInitialized) {\n this._startTransitions(this._queue);\n\n } else if (hasQueue) {\n this._styleImmediately(this._queue);\n this._dispatchLayout();\n\n // A call to layout happened, but none of the newly visible items will\n // change position or the transition duration is zero, which will not trigger\n // the transitionend event.\n } else {\n this._dispatchLayout();\n }\n\n // Remove everything in the style queue\n this._queue.length = 0;\n }\n\n /**\n * Wait for each transition to finish, the emit the layout event.\n * @param {Array.} transitions Array of transition objects.\n */\n _startTransitions(transitions) {\n // Set flag that shuffle is currently in motion.\n this.isTransitioning = true;\n\n // Create an array of functions to be called.\n let callbacks = transitions.map(obj => this._getTransitionFunction(obj));\n\n parallel(callbacks, this._movementFinished.bind(this));\n }\n\n _cancelMovement() {\n // Remove the transition end event for each listener.\n this._transitions.forEach(cancelTransitionEnd);\n\n // Reset the array.\n this._transitions.length = 0;\n\n // Show it's no longer active.\n this.isTransitioning = false;\n }\n\n /**\n * Apply styles without a transition.\n * @param {Array.} objects Array of transition objects.\n * @private\n */\n _styleImmediately(objects) {\n if (objects.length) {\n let elements = objects.map(obj => obj.item.element);\n\n Shuffle._skipTransitions(elements, () => {\n objects.forEach((obj) => {\n obj.item.applyCss(this._getStylesForTransition(obj));\n obj.callback();\n });\n });\n }\n }\n\n _movementFinished() {\n this._transitions.length = 0;\n this.isTransitioning = false;\n this._dispatchLayout();\n }\n\n _dispatchLayout() {\n this._dispatch(Shuffle.EventType.LAYOUT);\n }\n\n /**\n * The magic. This is what makes the plugin 'shuffle'\n * @param {string|Function|Array.} [category] Category to filter by.\n * Can be a function, string, or array of strings.\n * @param {Object} [sortObj] A sort object which can sort the visible set\n */\n filter(category, sortObj) {\n if (!this.isEnabled) {\n return;\n }\n\n if (!category || (category && category.length === 0)) {\n category = Shuffle.ALL_ITEMS;\n }\n\n this._filter(category);\n\n // Shrink each hidden item\n this._shrink();\n\n // How many visible elements?\n this._updateItemCount();\n\n // Update transforms on visible elements so they will animate to their new positions.\n this.sort(sortObj);\n }\n\n /**\n * Gets the visible elements, sorts them, and passes them to layout.\n * @param {Object} opts the options object for the sorted plugin\n */\n sort(opts = this.lastSort) {\n if (!this.isEnabled) {\n return;\n }\n\n this._resetCols();\n\n var items = this._getFilteredItems();\n items = sorter(items, opts);\n\n this._layout(items);\n\n // `_layout` always happens after `_shrink`, so it's safe to process the style\n // queue here with styles from the shrink method.\n this._processQueue();\n\n // Adjust the height of the container.\n this._setContainerSize();\n\n this.lastSort = opts;\n }\n\n /**\n * Reposition everything.\n * @param {boolean} isOnlyLayout If true, column and gutter widths won't be\n * recalculated.\n */\n update(isOnlyLayout) {\n if (this.isEnabled) {\n\n if (!isOnlyLayout) {\n // Get updated colCount\n this._setColumns();\n }\n\n // Layout items\n this.sort();\n }\n }\n\n /**\n * Use this instead of `update()` if you don't need the columns and gutters updated\n * Maybe an image inside `shuffle` loaded (and now has a height), which means calculations\n * could be off.\n */\n layout() {\n this.update(true);\n }\n\n /**\n * New items have been appended to shuffle. Mix them in with the current\n * filter or sort status.\n * @param {Array.} newItems Collection of new items.\n */\n add(newItems) {\n newItems = arrayUnique(newItems).map(el => new ShuffleItem(el));\n\n // Add classes and set initial positions.\n this._initItems(newItems);\n\n // Add transition to each item.\n this._setTransitions(newItems);\n\n // Update the list of items.\n this.items = this.items.concat(newItems);\n this._updateItemsOrder();\n this.filter(this.lastFilter);\n }\n\n /**\n * Disables shuffle from updating dimensions and layout on resize\n */\n disable() {\n this.isEnabled = false;\n }\n\n /**\n * Enables shuffle again\n * @param {boolean} [isUpdateLayout=true] if undefined, shuffle will update columns and gutters\n */\n enable(isUpdateLayout) {\n this.isEnabled = true;\n if (isUpdateLayout !== false) {\n this.update();\n }\n }\n\n /**\n * Remove 1 or more shuffle items\n * @param {Array.} collection An array containing one or more\n * elements in shuffle\n * @return {Shuffle} The shuffle object\n */\n remove(collection) {\n if (!collection.length) {\n return;\n }\n\n collection = arrayUnique(collection);\n\n let oldItems = collection\n .map(element => this.getItemByElement(element))\n .filter(item => !!item);\n\n let handleLayout = () => {\n this.element.removeEventListener(Shuffle.EventType.LAYOUT, handleLayout);\n this._disposeItems(oldItems);\n\n // Remove the collection in the callback\n collection.forEach((element) => {\n element.parentNode.removeChild(element);\n });\n\n this._dispatch(Shuffle.EventType.REMOVED, { collection });\n\n // Let it get garbage collected\n collection = null;\n oldItems = null;\n };\n\n // Hide collection first.\n this._toggleFilterClasses({\n visible: [],\n hidden: oldItems,\n });\n\n this._shrink(oldItems);\n\n this.sort();\n\n // Update the list of items here because `remove` could be called again\n // with an item that is in the process of being removed.\n this.items = this.items.filter(item => !arrayIncludes(oldItems, item));\n this._updateItemCount();\n\n this.element.addEventListener(Shuffle.EventType.LAYOUT, handleLayout);\n }\n\n /**\n * Retrieve a shuffle item by its element.\n * @param {Element} element Element to look for.\n * @return {?ShuffleItem} A shuffle item or null if it's not found.\n */\n getItemByElement(element) {\n for (var i = this.items.length - 1; i >= 0; i--) {\n if (this.items[i].element === element) {\n return this.items[i];\n }\n }\n\n return null;\n }\n\n /**\n * Destroys shuffle, removes events, styles, and classes\n */\n destroy() {\n this._cancelMovement();\n window.removeEventListener('resize', this._onResize);\n\n // Reset container styles\n this.element.classList.remove('shuffle');\n this.element.removeAttribute('style');\n\n // Reset individual item styles\n this._disposeItems();\n\n // Null DOM references\n this.items = null;\n this.options.sizer = null;\n this.element = null;\n this._transitions = null;\n\n // Set a flag so if a debounced resize has been triggered,\n // it can first check if it is actually isDestroyed and not doing anything\n this.isDestroyed = true;\n }\n\n /**\n * Returns the outer width of an element, optionally including its margins.\n *\n * There are a few different methods for getting the width of an element, none of\n * which work perfectly for all Shuffle's use cases.\n *\n * 1. getBoundingClientRect() `left` and `right` properties.\n * - Accounts for transform scaled elements, making it useless for Shuffle\n * elements which have shrunk.\n * 2. The `offsetWidth` property.\n * - This value stays the same regardless of the elements transform property,\n * however, it does not return subpixel values.\n * 3. getComputedStyle()\n * - This works great Chrome, Firefox, Safari, but IE<=11 does not include\n * padding and border when box-sizing: border-box is set, requiring a feature\n * test and extra work to add the padding back for IE and other browsers which\n * follow the W3C spec here.\n *\n * @param {Element} element The element.\n * @param {boolean} [includeMargins] Whether to include margins. Default is false.\n * @return {{width: number, height: number}} The width and height.\n */\n static getSize(element, includeMargins) {\n // Store the styles so that they can be used by others without asking for it again.\n var styles = window.getComputedStyle(element, null);\n var width = getNumberStyle(element, 'width', styles);\n var height = getNumberStyle(element, 'height', styles);\n\n if (includeMargins) {\n var marginLeft = getNumberStyle(element, 'marginLeft', styles);\n var marginRight = getNumberStyle(element, 'marginRight', styles);\n var marginTop = getNumberStyle(element, 'marginTop', styles);\n var marginBottom = getNumberStyle(element, 'marginBottom', styles);\n width += marginLeft + marginRight;\n height += marginTop + marginBottom;\n }\n\n return {\n width,\n height,\n };\n }\n\n /**\n * Change a property or execute a function which will not have a transition\n * @param {Array.} elements DOM elements that won't be transitioned.\n * @param {Function} callback A function which will be called while transition\n * is set to 0ms.\n * @private\n */\n static _skipTransitions(elements, callback) {\n let zero = '0ms';\n\n // Save current duration and delay.\n let data = elements.map((element) => {\n let style = element.style;\n let duration = style.transitionDuration;\n let delay = style.transitionDelay;\n\n // Set the duration to zero so it happens immediately\n style.transitionDuration = zero;\n style.transitionDelay = zero;\n\n return {\n duration,\n delay,\n };\n });\n\n callback();\n\n // Cause reflow.\n elements[0].offsetWidth; // jshint ignore:line\n\n // Put the duration back\n elements.forEach((element, i) => {\n element.style.transitionDuration = data[i].duration;\n element.style.transitionDelay = data[i].delay;\n });\n }\n}\n\nShuffle.ShuffleItem = ShuffleItem;\n\nShuffle.ALL_ITEMS = 'all';\nShuffle.FILTER_ATTRIBUTE_KEY = 'groups';\n\n/**\n * @enum {string}\n */\nShuffle.EventType = {\n LAYOUT: 'shuffle:layout',\n REMOVED: 'shuffle:removed',\n};\n\n/** @enum {string} */\nShuffle.Classes = Classes;\n\n// Overrideable options\nShuffle.options = {\n // Initial filter group.\n group: Shuffle.ALL_ITEMS,\n\n // Transition/animation speed (milliseconds).\n speed: 250,\n\n // CSS easing function to use.\n easing: 'ease',\n\n // e.g. '.picture-item'.\n itemSelector: '*',\n\n // Element or selector string. Use an element to determine the size of columns\n // and gutters.\n sizer: null,\n\n // A static number or function that tells the plugin how wide the gutters\n // between columns are (in pixels).\n gutterWidth: 0,\n\n // A static number or function that returns a number which tells the plugin\n // how wide the columns are (in pixels).\n columnWidth: 0,\n\n // If your group is not json, and is comma delimeted, you could set delimeter\n // to ','.\n delimeter: null,\n\n // Useful for percentage based heights when they might not always be exactly\n // the same (in pixels).\n buffer: 0,\n\n // Reading the width of elements isn't precise enough and can cause columns to\n // jump between values.\n columnThreshold: 0.01,\n\n // Shuffle can be isInitialized with a sort object. It is the same object\n // given to the sort method.\n initialSort: null,\n\n // By default, shuffle will throttle resize events. This can be changed or\n // removed.\n throttle: throttle,\n\n // How often shuffle can be called on resize (in milliseconds).\n throttleTime: 300,\n\n // Transition delay offset for each item in milliseconds.\n staggerAmount: 15,\n\n // Maximum stagger delay in milliseconds.\n staggerAmountMax: 250,\n\n // Whether to use transforms or absolute positioning.\n useTransforms: true,\n};\n\n// Expose for testing. Hack at your own risk.\nShuffle.__Point = Point;\nShuffle.__sorter = sorter;\nShuffle.__getColumnSpan = getColumnSpan;\nShuffle.__getAvailablePositions = getAvailablePositions;\nShuffle.__getShortColumn = getShortColumn;\n\nexport default Shuffle;\n\n\n\n// WEBPACK FOOTER //\n// ./src/shuffle.js","module.exports = function parallel(fns, context, callback) {\n if (!callback) {\n if (typeof context === 'function') {\n callback = context\n context = null\n } else {\n callback = noop\n }\n }\n\n var pending = fns && fns.length\n if (!pending) return callback(null, []);\n\n var finished = false\n var results = new Array(pending)\n\n fns.forEach(context ? function (fn, i) {\n fn.call(context, maybeDone(i))\n } : function (fn, i) {\n fn(maybeDone(i))\n })\n\n function maybeDone(i) {\n return function (err, result) {\n if (finished) return;\n\n if (err) {\n callback(err, results)\n finished = true\n return\n }\n\n results[i] = result\n\n if (!--pending) callback(null, results);\n }\n }\n}\n\nfunction noop() {}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/array-parallel/index.js\n// module id = 5\n// module chunks = 0","'use strict';\n\n// there's 3 implementations written in increasing order of efficiency\n\n// 1 - no Set type is defined\nfunction uniqNoSet(arr) {\n\tvar ret = [];\n\n\tfor (var i = 0; i < arr.length; i++) {\n\t\tif (ret.indexOf(arr[i]) === -1) {\n\t\t\tret.push(arr[i]);\n\t\t}\n\t}\n\n\treturn ret;\n}\n\n// 2 - a simple Set type is defined\nfunction uniqSet(arr) {\n\tvar seen = new Set();\n\treturn arr.filter(function (el) {\n\t\tif (!seen.has(el)) {\n\t\t\tseen.add(el);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t});\n}\n\n// 3 - a standard Set type is defined and it has a forEach method\nfunction uniqSetWithForEach(arr) {\n\tvar ret = [];\n\n\t(new Set(arr)).forEach(function (el) {\n\t\tret.push(el);\n\t});\n\n\treturn ret;\n}\n\n// V8 currently has a broken implementation\n// https://github.com/joyent/node/issues/8449\nfunction doesForEachActuallyWork() {\n\tvar ret = false;\n\n\t(new Set([true])).forEach(function (el) {\n\t\tret = el;\n\t});\n\n\treturn ret === true;\n}\n\nif ('Set' in global) {\n\tif (typeof Set.prototype.forEach === 'function' && doesForEachActuallyWork()) {\n\t\tmodule.exports = uniqSetWithForEach;\n\t} else {\n\t\tmodule.exports = uniqSet;\n\t}\n} else {\n\tmodule.exports = uniqNoSet;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/array-uniq/index.js\n// module id = 6\n// module chunks = 0","\nlet element = document.body || document.documentElement;\nlet e = document.createElement('div');\ne.style.cssText = 'width:10px;padding:2px;box-sizing:border-box;';\nelement.appendChild(e);\n\nlet width = window.getComputedStyle(e, null).width;\nlet ret = width === '10px';\n\nelement.removeChild(e);\n\nexport default ret;\n\n\n\n// WEBPACK FOOTER //\n// ./src/computed-size.js","'use strict';\n\nimport getNumber from './get-number';\nimport COMPUTED_SIZE_INCLUDES_PADDING from './computed-size';\n\n/**\n * Retrieve the computed style for an element, parsed as a float.\n * @param {Element} element Element to get style for.\n * @param {string} style Style property.\n * @param {CSSStyleDeclaration} [styles] Optionally include clean styles to\n * use instead of asking for them again.\n * @return {number} The parsed computed value or zero if that fails because IE\n * will return 'auto' when the element doesn't have margins instead of\n * the computed style.\n */\nexport default function getNumberStyle(element, style,\n styles = window.getComputedStyle(element, null)) {\n var value = getNumber(styles[style]);\n\n // Support IE<=11 and W3C spec.\n if (!COMPUTED_SIZE_INCLUDES_PADDING && style === 'width') {\n value += getNumber(styles.paddingLeft) +\n getNumber(styles.paddingRight) +\n getNumber(styles.borderLeftWidth) +\n getNumber(styles.borderRightWidth);\n } else if (!COMPUTED_SIZE_INCLUDES_PADDING && style === 'height') {\n value += getNumber(styles.paddingTop) +\n getNumber(styles.paddingBottom) +\n getNumber(styles.borderTopWidth) +\n getNumber(styles.borderBottomWidth);\n }\n\n return value;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/get-number-style.js","'use strict';\n\nimport Point from './point';\n\nfunction arrayMax(array) {\n return Math.max.apply(Math, array);\n}\n\nfunction arrayMin(array) {\n return Math.min.apply(Math, array);\n}\n\n/**\n * Determine the location of the next item, based on its size.\n * @param {Object} itemSize Object with width and height.\n * @param {Array.} positions Positions of the other current items.\n * @param {number} gridSize The column width or row height.\n * @param {number} total The total number of columns or rows.\n * @param {number} threshold Buffer value for the column to fit.\n * @param {number} buffer Vertical buffer for the height of items.\n * @return {Point}\n */\nexport function getItemPosition({ itemSize, positions, gridSize, total, threshold, buffer }) {\n var span = getColumnSpan(itemSize.width, gridSize, total, threshold);\n var setY = getAvailablePositions(positions, span, total);\n var shortColumnIndex = getShortColumn(setY, buffer);\n\n // Position the item\n var point = new Point(\n Math.round(gridSize * shortColumnIndex),\n Math.round(setY[shortColumnIndex]));\n\n // Update the columns array with the new values for each column.\n // e.g. before the update the columns could be [250, 0, 0, 0] for an item\n // which spans 2 columns. After it would be [250, itemHeight, itemHeight, 0].\n var setHeight = setY[shortColumnIndex] + itemSize.height;\n for (var i = 0; i < span; i++) {\n positions[shortColumnIndex + i] = setHeight;\n }\n\n return point;\n}\n\n/**\n * Determine the number of columns an items spans.\n * @param {number} itemWidth Width of the item.\n * @param {number} columnWidth Width of the column (includes gutter).\n * @param {number} columns Total number of columns\n * @param {number} threshold A buffer value for the size of the column to fit.\n * @return {number}\n */\nexport function getColumnSpan(itemWidth, columnWidth, columns, threshold) {\n var columnSpan = itemWidth / columnWidth;\n\n // If the difference between the rounded column span number and the\n // calculated column span number is really small, round the number to\n // make it fit.\n if (Math.abs(Math.round(columnSpan) - columnSpan) < threshold) {\n // e.g. columnSpan = 4.0089945390298745\n columnSpan = Math.round(columnSpan);\n }\n\n // Ensure the column span is not more than the amount of columns in the whole layout.\n return Math.min(Math.ceil(columnSpan), columns);\n}\n\n/**\n * Retrieves the column set to use for placement.\n * @param {number} columnSpan The number of columns this current item spans.\n * @param {number} columns The total columns in the grid.\n * @return {Array.} An array of numbers represeting the column set.\n */\nexport function getAvailablePositions(positions, columnSpan, columns) {\n // The item spans only one column.\n if (columnSpan === 1) {\n return positions;\n }\n\n // The item spans more than one column, figure out how many different\n // places it could fit horizontally.\n // The group count is the number of places within the positions this block\n // could fit, ignoring the current positions of items.\n // Imagine a 2 column brick as the second item in a 4 column grid with\n // 10px height each. Find the places it would fit:\n // [20, 10, 10, 0]\n // | | |\n // * * *\n //\n // Then take the places which fit and get the bigger of the two:\n // max([20, 10]), max([10, 10]), max([10, 0]) = [20, 10, 0]\n //\n // Next, find the first smallest number (the short column).\n // [20, 10, 0]\n // |\n // *\n //\n // And that's where it should be placed!\n //\n // Another example where the second column's item extends past the first:\n // [10, 20, 10, 0] => [20, 20, 10] => 10\n var available = [];\n\n // For how many possible positions for this item there are.\n for (var i = 0; i <= columns - columnSpan; i++) {\n // Find the bigger value for each place it could fit.\n available.push(arrayMax(positions.slice(i, i + columnSpan)));\n }\n\n return available;\n}\n\n/**\n * Find index of short column, the first from the left where this item will go.\n *\n * @param {Array.} positions The array to search for the smallest number.\n * @param {number} buffer Optional buffer which is very useful when the height\n * is a percentage of the width.\n * @return {number} Index of the short column.\n */\nexport function getShortColumn(positions, buffer) {\n var minPosition = arrayMin(positions);\n for (var i = 0, len = positions.length; i < len; i++) {\n if (positions[i] >= minPosition - buffer && positions[i] <= minPosition + buffer) {\n return i;\n }\n }\n\n return 0;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/layout.js","'use strict';\n\nlet transitions = {};\nlet eventName = 'transitionend';\nlet count = 0;\n\nfunction uniqueId() {\n return eventName + count++;\n}\n\nexport function onTransitionEnd(element, callback) {\n let id = uniqueId();\n let listener = (evt) => {\n if (evt.currentTarget === evt.target) {\n cancelTransitionEnd(id);\n callback(evt);\n }\n };\n\n element.addEventListener(eventName, listener);\n\n transitions[id] = { element, listener };\n\n return id;\n}\n\nexport function cancelTransitionEnd(id) {\n if (transitions[id]) {\n transitions[id].element.removeEventListener(eventName, transitions[id].listener);\n transitions[id] = null;\n return true;\n }\n\n return false;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/on-transition-end.js","import Point from './point';\nimport Classes from './classes';\n\nlet id = 0;\n\nclass ShuffleItem {\n constructor(element) {\n this.id = id++;\n this.element = element;\n this.isVisible = true;\n }\n\n show() {\n this.isVisible = true;\n this.element.classList.remove(Classes.HIDDEN);\n this.element.classList.add(Classes.VISIBLE);\n }\n\n hide() {\n this.isVisible = false;\n this.element.classList.remove(Classes.VISIBLE);\n this.element.classList.add(Classes.HIDDEN);\n }\n\n init() {\n this.addClasses([Classes.SHUFFLE_ITEM, Classes.VISIBLE]);\n this.applyCss(ShuffleItem.Css.INITIAL);\n this.scale = ShuffleItem.Scale.VISIBLE;\n this.point = new Point();\n }\n\n addClasses(classes) {\n classes.forEach((className) => {\n this.element.classList.add(className);\n });\n }\n\n removeClasses(classes) {\n classes.forEach((className) => {\n this.element.classList.remove(className);\n });\n }\n\n applyCss(obj) {\n for (var key in obj) {\n this.element.style[key] = obj[key];\n }\n }\n\n dispose() {\n this.removeClasses([\n Classes.HIDDEN,\n Classes.VISIBLE,\n Classes.SHUFFLE_ITEM,\n ]);\n\n this.element.removeAttribute('style');\n this.element = null;\n }\n}\n\nShuffleItem.Css = {\n INITIAL: {\n position: 'absolute',\n top: 0,\n left: 0,\n visibility: 'visible',\n 'will-change': 'transform',\n },\n VISIBLE: {\n before: {\n opacity: 1,\n visibility: 'visible',\n },\n after: {},\n },\n HIDDEN: {\n before: {\n opacity: 0,\n },\n after: {\n visibility: 'hidden',\n },\n },\n};\n\nShuffleItem.Scale = {\n VISIBLE: 1,\n HIDDEN: 0.001,\n};\n\nexport default ShuffleItem;\n\n\n\n// WEBPACK FOOTER //\n// ./src/shuffle-item.js","'use strict';\n\nimport xtend from 'xtend';\n\n// http://stackoverflow.com/a/962890/373422\nfunction randomize(array) {\n var tmp;\n var current;\n let top = array.length;\n\n if (!top) {\n return array;\n }\n\n while (--top) {\n current = Math.floor(Math.random() * (top + 1));\n tmp = array[current];\n array[current] = array[top];\n array[top] = tmp;\n }\n\n return array;\n}\n\nlet defaults = {\n // Use array.reverse() to reverse the results\n reverse: false,\n\n // Sorting function\n by: null,\n\n // If true, this will skip the sorting and return a randomized order in the array\n randomize: false,\n\n // Determines which property of each item in the array is passed to the\n // sorting method.\n key: 'element',\n};\n\n// You can return `undefined` from the `by` function to revert to DOM order.\nexport default function sorter(arr, options) {\n let opts = xtend(defaults, options);\n let original = [].slice.call(arr);\n let revert = false;\n\n if (!arr.length) {\n return [];\n }\n\n if (opts.randomize) {\n return randomize(arr);\n }\n\n // Sort the elements by the opts.by function.\n // If we don't have opts.by, default to DOM order\n if (typeof opts.by === 'function') {\n arr.sort(function (a, b) {\n\n // Exit early if we already know we want to revert\n if (revert) {\n return 0;\n }\n\n let valA = opts.by(a[opts.key]);\n let valB = opts.by(b[opts.key]);\n\n // If both values are undefined, use the DOM order\n if (valA === undefined && valB === undefined) {\n revert = true;\n return 0;\n }\n\n if (valA < valB || valA === 'sortFirst' || valB === 'sortLast') {\n return -1;\n }\n\n if (valA > valB || valA === 'sortLast' || valB === 'sortFirst') {\n return 1;\n }\n\n return 0;\n });\n }\n\n // Revert to the original array if necessary\n if (revert) {\n return original;\n }\n\n if (opts.reverse) {\n arr.reverse();\n }\n\n return arr;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/sorter.js","// Polyfill for creating CustomEvents on IE9/10/11\n\n// code pulled from:\n// https://github.com/d4tocchini/customevent-polyfill\n// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent#Polyfill\n\ntry {\n var ce = new window.CustomEvent('test');\n ce.preventDefault();\n if (ce.defaultPrevented !== true) {\n // IE has problems with .preventDefault() on custom events\n // http://stackoverflow.com/questions/23349191\n throw new Error('Could not prevent default');\n }\n} catch(e) {\n var CustomEvent = function(event, params) {\n var evt, origPrevent;\n params = params || {\n bubbles: false,\n cancelable: false,\n detail: undefined\n };\n\n evt = document.createEvent(\"CustomEvent\");\n evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);\n origPrevent = evt.preventDefault;\n evt.preventDefault = function () {\n origPrevent.call(this);\n try {\n Object.defineProperty(this, 'defaultPrevented', {\n get: function () {\n return true;\n }\n });\n } catch(e) {\n this.defaultPrevented = true;\n }\n };\n return evt;\n };\n\n CustomEvent.prototype = window.Event.prototype;\n window.CustomEvent = CustomEvent; // expose definition to window\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/custom-event-polyfill/custom-event-polyfill.js\n// module id = 13\n// module chunks = 0","'use strict';\n\nvar proto = Element.prototype;\nvar vendor = proto.matches\n || proto.matchesSelector\n || proto.webkitMatchesSelector\n || proto.mozMatchesSelector\n || proto.msMatchesSelector\n || proto.oMatchesSelector;\n\nmodule.exports = match;\n\n/**\n * Match `el` to `selector`.\n *\n * @param {Element} el\n * @param {String} selector\n * @return {Boolean}\n * @api public\n */\n\nfunction match(el, selector) {\n if (vendor) return vendor.call(el, selector);\n var nodes = el.parentNode.querySelectorAll(selector);\n for (var i = 0; i < nodes.length; i++) {\n if (nodes[i] == el) return true;\n }\n return false;\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/matches-selector/index.js\n// module id = 14\n// module chunks = 0","module.exports = throttle;\n\n/**\n * Returns a new function that, when invoked, invokes `func` at most once per `wait` milliseconds.\n *\n * @param {Function} func Function to wrap.\n * @param {Number} wait Number of milliseconds that must elapse between `func` invocations.\n * @return {Function} A new function that wraps the `func` function passed in.\n */\n\nfunction throttle (func, wait) {\n var ctx, args, rtn, timeoutID; // caching\n var last = 0;\n\n return function throttled () {\n ctx = this;\n args = arguments;\n var delta = new Date() - last;\n if (!timeoutID)\n if (delta >= wait) call();\n else timeoutID = setTimeout(call, wait - delta);\n return rtn;\n };\n\n function call () {\n timeoutID = 0;\n last = +new Date();\n rtn = func.apply(ctx, args);\n ctx = null;\n args = null;\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/throttleit/index.js\n// module id = 15\n// module chunks = 0","var g;\r\n\r\n// This works in non-strict mode\r\ng = (function() {\r\n\treturn this;\r\n})();\r\n\r\ntry {\r\n\t// This works if eval is allowed (see CSP)\r\n\tg = g || Function(\"return this\")() || (1,eval)(\"this\");\r\n} catch(e) {\r\n\t// This works if the window reference is available\r\n\tif(typeof window === \"object\")\r\n\t\tg = window;\r\n}\r\n\r\n// g can still be undefined, but nothing to do about it...\r\n// We return undefined, instead of nothing here, so it's\r\n// easier to handle this case. if(!global) { ...}\r\n\r\nmodule.exports = g;\r\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/buildin/global.js\n// module id = 16\n// module chunks = 0","module.exports = require('./shuffle').default;\n\n\n\n// WEBPACK FOOTER //\n// ./src/index.js"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"shuffle.js","sources":["../node_modules/custom-event-polyfill/custom-event-polyfill.js","../node_modules/matches-selector/index.js","../node_modules/array-uniq/index.js","../node_modules/xtend/immutable.js","../node_modules/throttleit/index.js","../node_modules/array-parallel/index.js","../src/get-number.js","../src/point.js","../src/classes.js","../src/shuffle-item.js","../src/computed-size.js","../src/get-number-style.js","../src/sorter.js","../src/on-transition-end.js","../src/array-max.js","../src/array-min.js","../src/layout.js","../src/shuffle.js"],"sourcesContent":["// Polyfill for creating CustomEvents on IE9/10/11\n\n// code pulled from:\n// https://github.com/d4tocchini/customevent-polyfill\n// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent#Polyfill\n\ntry {\n var ce = new window.CustomEvent('test');\n ce.preventDefault();\n if (ce.defaultPrevented !== true) {\n // IE has problems with .preventDefault() on custom events\n // http://stackoverflow.com/questions/23349191\n throw new Error('Could not prevent default');\n }\n} catch(e) {\n var CustomEvent = function(event, params) {\n var evt, origPrevent;\n params = params || {\n bubbles: false,\n cancelable: false,\n detail: undefined\n };\n\n evt = document.createEvent(\"CustomEvent\");\n evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);\n origPrevent = evt.preventDefault;\n evt.preventDefault = function () {\n origPrevent.call(this);\n try {\n Object.defineProperty(this, 'defaultPrevented', {\n get: function () {\n return true;\n }\n });\n } catch(e) {\n this.defaultPrevented = true;\n }\n };\n return evt;\n };\n\n CustomEvent.prototype = window.Event.prototype;\n window.CustomEvent = CustomEvent; // expose definition to window\n}\n","'use strict';\n\nvar proto = Element.prototype;\nvar vendor = proto.matches\n || proto.matchesSelector\n || proto.webkitMatchesSelector\n || proto.mozMatchesSelector\n || proto.msMatchesSelector\n || proto.oMatchesSelector;\n\nmodule.exports = match;\n\n/**\n * Match `el` to `selector`.\n *\n * @param {Element} el\n * @param {String} selector\n * @return {Boolean}\n * @api public\n */\n\nfunction match(el, selector) {\n if (vendor) return vendor.call(el, selector);\n var nodes = el.parentNode.querySelectorAll(selector);\n for (var i = 0; i < nodes.length; i++) {\n if (nodes[i] == el) return true;\n }\n return false;\n}","'use strict';\n\n// there's 3 implementations written in increasing order of efficiency\n\n// 1 - no Set type is defined\nfunction uniqNoSet(arr) {\n\tvar ret = [];\n\n\tfor (var i = 0; i < arr.length; i++) {\n\t\tif (ret.indexOf(arr[i]) === -1) {\n\t\t\tret.push(arr[i]);\n\t\t}\n\t}\n\n\treturn ret;\n}\n\n// 2 - a simple Set type is defined\nfunction uniqSet(arr) {\n\tvar seen = new Set();\n\treturn arr.filter(function (el) {\n\t\tif (!seen.has(el)) {\n\t\t\tseen.add(el);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t});\n}\n\n// 3 - a standard Set type is defined and it has a forEach method\nfunction uniqSetWithForEach(arr) {\n\tvar ret = [];\n\n\t(new Set(arr)).forEach(function (el) {\n\t\tret.push(el);\n\t});\n\n\treturn ret;\n}\n\n// V8 currently has a broken implementation\n// https://github.com/joyent/node/issues/8449\nfunction doesForEachActuallyWork() {\n\tvar ret = false;\n\n\t(new Set([true])).forEach(function (el) {\n\t\tret = el;\n\t});\n\n\treturn ret === true;\n}\n\nif ('Set' in global) {\n\tif (typeof Set.prototype.forEach === 'function' && doesForEachActuallyWork()) {\n\t\tmodule.exports = uniqSetWithForEach;\n\t} else {\n\t\tmodule.exports = uniqSet;\n\t}\n} else {\n\tmodule.exports = uniqNoSet;\n}\n","module.exports = extend\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nfunction extend() {\n var target = {}\n\n for (var i = 0; i < arguments.length; i++) {\n var source = arguments[i]\n\n for (var key in source) {\n if (hasOwnProperty.call(source, key)) {\n target[key] = source[key]\n }\n }\n }\n\n return target\n}\n","module.exports = throttle;\n\n/**\n * Returns a new function that, when invoked, invokes `func` at most once per `wait` milliseconds.\n *\n * @param {Function} func Function to wrap.\n * @param {Number} wait Number of milliseconds that must elapse between `func` invocations.\n * @return {Function} A new function that wraps the `func` function passed in.\n */\n\nfunction throttle (func, wait) {\n var ctx, args, rtn, timeoutID; // caching\n var last = 0;\n\n return function throttled () {\n ctx = this;\n args = arguments;\n var delta = new Date() - last;\n if (!timeoutID)\n if (delta >= wait) call();\n else timeoutID = setTimeout(call, wait - delta);\n return rtn;\n };\n\n function call () {\n timeoutID = 0;\n last = +new Date();\n rtn = func.apply(ctx, args);\n ctx = null;\n args = null;\n }\n}\n","module.exports = function parallel(fns, context, callback) {\n if (!callback) {\n if (typeof context === 'function') {\n callback = context\n context = null\n } else {\n callback = noop\n }\n }\n\n var pending = fns && fns.length\n if (!pending) return callback(null, []);\n\n var finished = false\n var results = new Array(pending)\n\n fns.forEach(context ? function (fn, i) {\n fn.call(context, maybeDone(i))\n } : function (fn, i) {\n fn(maybeDone(i))\n })\n\n function maybeDone(i) {\n return function (err, result) {\n if (finished) return;\n\n if (err) {\n callback(err, results)\n finished = true\n return\n }\n\n results[i] = result\n\n if (!--pending) callback(null, results);\n }\n }\n}\n\nfunction noop() {}\n","/**\n * Always returns a numeric value, given a value. Logic from jQuery's `isNumeric`.\n * @param {*} value Possibly numeric value.\n * @return {number} `value` or zero if `value` isn't numeric.\n */\nexport default function getNumber(value) {\n return parseFloat(value) || 0;\n}\n","import getNumber from './get-number';\n\n/**\n * Represents a coordinate pair.\n * @param {number} [x=0] X.\n * @param {number} [y=0] Y.\n */\nconst Point = function (x, y) {\n this.x = getNumber(x);\n this.y = getNumber(y);\n};\n\n/**\n * Whether two points are equal.\n * @param {Point} a Point A.\n * @param {Point} b Point B.\n * @return {boolean}\n */\nPoint.equals = function (a, b) {\n return a.x === b.x && a.y === b.y;\n};\n\nexport default Point;\n","export default {\n BASE: 'shuffle',\n SHUFFLE_ITEM: 'shuffle-item',\n VISIBLE: 'shuffle-item--visible',\n HIDDEN: 'shuffle-item--hidden',\n};\n","import Point from './point';\nimport Classes from './classes';\n\nlet id = 0;\n\nclass ShuffleItem {\n constructor(element) {\n this.id = id++;\n this.element = element;\n this.isVisible = true;\n }\n\n show() {\n this.isVisible = true;\n this.element.classList.remove(Classes.HIDDEN);\n this.element.classList.add(Classes.VISIBLE);\n }\n\n hide() {\n this.isVisible = false;\n this.element.classList.remove(Classes.VISIBLE);\n this.element.classList.add(Classes.HIDDEN);\n }\n\n init() {\n this.addClasses([Classes.SHUFFLE_ITEM, Classes.VISIBLE]);\n this.applyCss(ShuffleItem.Css.INITIAL);\n this.scale = ShuffleItem.Scale.VISIBLE;\n this.point = new Point();\n }\n\n addClasses(classes) {\n classes.forEach((className) => {\n this.element.classList.add(className);\n });\n }\n\n removeClasses(classes) {\n classes.forEach((className) => {\n this.element.classList.remove(className);\n });\n }\n\n applyCss(obj) {\n for (var key in obj) {\n this.element.style[key] = obj[key];\n }\n }\n\n dispose() {\n this.removeClasses([\n Classes.HIDDEN,\n Classes.VISIBLE,\n Classes.SHUFFLE_ITEM,\n ]);\n\n this.element.removeAttribute('style');\n this.element = null;\n }\n}\n\nShuffleItem.Css = {\n INITIAL: {\n position: 'absolute',\n top: 0,\n left: 0,\n visibility: 'visible',\n 'will-change': 'transform',\n },\n VISIBLE: {\n before: {\n opacity: 1,\n visibility: 'visible',\n },\n after: {},\n },\n HIDDEN: {\n before: {\n opacity: 0,\n },\n after: {\n visibility: 'hidden',\n },\n },\n};\n\nShuffleItem.Scale = {\n VISIBLE: 1,\n HIDDEN: 0.001,\n};\n\nexport default ShuffleItem;\n","let element = document.body || document.documentElement;\nlet e = document.createElement('div');\ne.style.cssText = 'width:10px;padding:2px;box-sizing:border-box;';\nelement.appendChild(e);\n\nlet width = window.getComputedStyle(e, null).width;\nlet ret = width === '10px';\n\nelement.removeChild(e);\n\nexport default ret;\n","import getNumber from './get-number';\nimport COMPUTED_SIZE_INCLUDES_PADDING from './computed-size';\n\n/**\n * Retrieve the computed style for an element, parsed as a float.\n * @param {Element} element Element to get style for.\n * @param {string} style Style property.\n * @param {CSSStyleDeclaration} [styles] Optionally include clean styles to\n * use instead of asking for them again.\n * @return {number} The parsed computed value or zero if that fails because IE\n * will return 'auto' when the element doesn't have margins instead of\n * the computed style.\n */\nexport default function getNumberStyle(element, style,\n styles = window.getComputedStyle(element, null)) {\n var value = getNumber(styles[style]);\n\n // Support IE<=11 and W3C spec.\n if (!COMPUTED_SIZE_INCLUDES_PADDING && style === 'width') {\n value += getNumber(styles.paddingLeft) +\n getNumber(styles.paddingRight) +\n getNumber(styles.borderLeftWidth) +\n getNumber(styles.borderRightWidth);\n } else if (!COMPUTED_SIZE_INCLUDES_PADDING && style === 'height') {\n value += getNumber(styles.paddingTop) +\n getNumber(styles.paddingBottom) +\n getNumber(styles.borderTopWidth) +\n getNumber(styles.borderBottomWidth);\n }\n\n return value;\n}\n","import xtend from 'xtend';\n\n// http://stackoverflow.com/a/962890/373422\nfunction randomize(array) {\n var tmp;\n var current;\n let top = array.length;\n\n if (!top) {\n return array;\n }\n\n while (--top) {\n current = Math.floor(Math.random() * (top + 1));\n tmp = array[current];\n array[current] = array[top];\n array[top] = tmp;\n }\n\n return array;\n}\n\nlet defaults = {\n // Use array.reverse() to reverse the results\n reverse: false,\n\n // Sorting function\n by: null,\n\n // If true, this will skip the sorting and return a randomized order in the array\n randomize: false,\n\n // Determines which property of each item in the array is passed to the\n // sorting method.\n key: 'element',\n};\n\n// You can return `undefined` from the `by` function to revert to DOM order.\nexport default function sorter(arr, options) {\n let opts = xtend(defaults, options);\n let original = [].slice.call(arr);\n let revert = false;\n\n if (!arr.length) {\n return [];\n }\n\n if (opts.randomize) {\n return randomize(arr);\n }\n\n // Sort the elements by the opts.by function.\n // If we don't have opts.by, default to DOM order\n if (typeof opts.by === 'function') {\n arr.sort(function (a, b) {\n\n // Exit early if we already know we want to revert\n if (revert) {\n return 0;\n }\n\n let valA = opts.by(a[opts.key]);\n let valB = opts.by(b[opts.key]);\n\n // If both values are undefined, use the DOM order\n if (valA === undefined && valB === undefined) {\n revert = true;\n return 0;\n }\n\n if (valA < valB || valA === 'sortFirst' || valB === 'sortLast') {\n return -1;\n }\n\n if (valA > valB || valA === 'sortLast' || valB === 'sortFirst') {\n return 1;\n }\n\n return 0;\n });\n }\n\n // Revert to the original array if necessary\n if (revert) {\n return original;\n }\n\n if (opts.reverse) {\n arr.reverse();\n }\n\n return arr;\n}\n","let transitions = {};\nlet eventName = 'transitionend';\nlet count = 0;\n\nfunction uniqueId() {\n return eventName + count++;\n}\n\nexport function onTransitionEnd(element, callback) {\n let id = uniqueId();\n let listener = (evt) => {\n if (evt.currentTarget === evt.target) {\n cancelTransitionEnd(id);\n callback(evt);\n }\n };\n\n element.addEventListener(eventName, listener);\n\n transitions[id] = { element, listener };\n\n return id;\n}\n\nexport function cancelTransitionEnd(id) {\n if (transitions[id]) {\n transitions[id].element.removeEventListener(eventName, transitions[id].listener);\n transitions[id] = null;\n return true;\n }\n\n return false;\n}\n","export default function arrayMax(array) {\n return Math.max.apply(Math, array);\n}\n","export default function arrayMin(array) {\n return Math.min.apply(Math, array);\n}\n","'use strict';\n\nimport Point from './point';\nimport arrayMax from './array-max';\nimport arrayMin from './array-min';\n\n/**\n * Determine the location of the next item, based on its size.\n * @param {Object} itemSize Object with width and height.\n * @param {Array.} positions Positions of the other current items.\n * @param {number} gridSize The column width or row height.\n * @param {number} total The total number of columns or rows.\n * @param {number} threshold Buffer value for the column to fit.\n * @param {number} buffer Vertical buffer for the height of items.\n * @return {Point}\n */\nexport function getItemPosition({ itemSize, positions, gridSize, total, threshold, buffer }) {\n var span = getColumnSpan(itemSize.width, gridSize, total, threshold);\n var setY = getAvailablePositions(positions, span, total);\n var shortColumnIndex = getShortColumn(setY, buffer);\n\n // Position the item\n var point = new Point(\n Math.round(gridSize * shortColumnIndex),\n Math.round(setY[shortColumnIndex]));\n\n // Update the columns array with the new values for each column.\n // e.g. before the update the columns could be [250, 0, 0, 0] for an item\n // which spans 2 columns. After it would be [250, itemHeight, itemHeight, 0].\n var setHeight = setY[shortColumnIndex] + itemSize.height;\n for (var i = 0; i < span; i++) {\n positions[shortColumnIndex + i] = setHeight;\n }\n\n return point;\n}\n\n/**\n * Determine the number of columns an items spans.\n * @param {number} itemWidth Width of the item.\n * @param {number} columnWidth Width of the column (includes gutter).\n * @param {number} columns Total number of columns\n * @param {number} threshold A buffer value for the size of the column to fit.\n * @return {number}\n */\nexport function getColumnSpan(itemWidth, columnWidth, columns, threshold) {\n var columnSpan = itemWidth / columnWidth;\n\n // If the difference between the rounded column span number and the\n // calculated column span number is really small, round the number to\n // make it fit.\n if (Math.abs(Math.round(columnSpan) - columnSpan) < threshold) {\n // e.g. columnSpan = 4.0089945390298745\n columnSpan = Math.round(columnSpan);\n }\n\n // Ensure the column span is not more than the amount of columns in the whole layout.\n return Math.min(Math.ceil(columnSpan), columns);\n}\n\n/**\n * Retrieves the column set to use for placement.\n * @param {number} columnSpan The number of columns this current item spans.\n * @param {number} columns The total columns in the grid.\n * @return {Array.} An array of numbers represeting the column set.\n */\nexport function getAvailablePositions(positions, columnSpan, columns) {\n // The item spans only one column.\n if (columnSpan === 1) {\n return positions;\n }\n\n // The item spans more than one column, figure out how many different\n // places it could fit horizontally.\n // The group count is the number of places within the positions this block\n // could fit, ignoring the current positions of items.\n // Imagine a 2 column brick as the second item in a 4 column grid with\n // 10px height each. Find the places it would fit:\n // [20, 10, 10, 0]\n // | | |\n // * * *\n //\n // Then take the places which fit and get the bigger of the two:\n // max([20, 10]), max([10, 10]), max([10, 0]) = [20, 10, 0]\n //\n // Next, find the first smallest number (the short column).\n // [20, 10, 0]\n // |\n // *\n //\n // And that's where it should be placed!\n //\n // Another example where the second column's item extends past the first:\n // [10, 20, 10, 0] => [20, 20, 10] => 10\n var available = [];\n\n // For how many possible positions for this item there are.\n for (var i = 0; i <= columns - columnSpan; i++) {\n // Find the bigger value for each place it could fit.\n available.push(arrayMax(positions.slice(i, i + columnSpan)));\n }\n\n return available;\n}\n\n/**\n * Find index of short column, the first from the left where this item will go.\n *\n * @param {Array.} positions The array to search for the smallest number.\n * @param {number} buffer Optional buffer which is very useful when the height\n * is a percentage of the width.\n * @return {number} Index of the short column.\n */\nexport function getShortColumn(positions, buffer) {\n var minPosition = arrayMin(positions);\n for (var i = 0, len = positions.length; i < len; i++) {\n if (positions[i] >= minPosition - buffer && positions[i] <= minPosition + buffer) {\n return i;\n }\n }\n\n return 0;\n}\n","import 'custom-event-polyfill';\nimport matches from 'matches-selector';\nimport arrayUnique from 'array-uniq';\nimport xtend from 'xtend';\nimport throttle from 'throttleit';\nimport parallel from 'array-parallel';\nimport Point from './point';\nimport ShuffleItem from './shuffle-item';\nimport Classes from './classes';\nimport getNumberStyle from './get-number-style';\nimport sorter from './sorter';\nimport { onTransitionEnd, cancelTransitionEnd } from './on-transition-end';\nimport { getItemPosition, getColumnSpan, getAvailablePositions, getShortColumn } from './layout';\nimport arrayMax from './array-max';\n\nfunction toArray(arrayLike) {\n return Array.prototype.slice.call(arrayLike);\n}\n\nfunction arrayIncludes(array, obj) {\n if (arguments.length === 2) {\n return arrayIncludes(array)(obj);\n }\n\n return function (obj) {\n return array.indexOf(obj) > -1;\n };\n}\n\n// Used for unique instance variables\nlet id = 0;\n\nclass Shuffle {\n\n /**\n * Categorize, sort, and filter a responsive grid of items.\n *\n * @param {Element} element An element which is the parent container for the grid items.\n * @param {Object} [options=Shuffle.options] Options object.\n * @constructor\n */\n constructor(element, options = {}) {\n this.options = xtend(Shuffle.options, options);\n\n this.useSizer = false;\n this.lastSort = {};\n this.group = this.lastFilter = Shuffle.ALL_ITEMS;\n this.isEnabled = true;\n this.isDestroyed = false;\n this.isInitialized = false;\n this._transitions = [];\n this.isTransitioning = false;\n this._queue = [];\n\n element = this._getElementOption(element);\n\n if (!element) {\n throw new TypeError('Shuffle needs to be initialized with an element.');\n }\n\n this.element = element;\n this.id = 'shuffle_' + id++;\n\n this._init();\n this.isInitialized = true;\n }\n\n _init() {\n this.items = this._getItems();\n\n this.options.sizer = this._getElementOption(this.options.sizer);\n\n if (this.options.sizer) {\n this.useSizer = true;\n }\n\n // Add class and invalidate styles\n this.element.classList.add(Shuffle.Classes.BASE);\n\n // Set initial css for each item\n this._initItems();\n\n // Bind resize events\n this._onResize = this._getResizeFunction();\n window.addEventListener('resize', this._onResize);\n\n // Get container css all in one request. Causes reflow\n var containerCss = window.getComputedStyle(this.element, null);\n var containerWidth = Shuffle.getSize(this.element).width;\n\n // Add styles to the container if it doesn't have them.\n this._validateStyles(containerCss);\n\n // We already got the container's width above, no need to cause another\n // reflow getting it again... Calculate the number of columns there will be\n this._setColumns(containerWidth);\n\n // Kick off!\n this.filter(this.options.group, this.options.initialSort);\n\n // The shuffle items haven't had transitions set on them yet so the user\n // doesn't see the first layout. Set them now that the first layout is done.\n // First, however, a synchronous layout must be caused for the previous\n // styles to be applied without transitions.\n this.element.offsetWidth; // jshint ignore: line\n this._setTransitions();\n this.element.style.transition = 'height ' + this.options.speed + 'ms ' + this.options.easing;\n }\n\n /**\n * Returns a throttled and proxied function for the resize handler.\n * @return {Function}\n * @private\n */\n _getResizeFunction() {\n var resizeFunction = this._handleResize.bind(this);\n return this.options.throttle ?\n this.options.throttle(resizeFunction, this.options.throttleTime) :\n resizeFunction;\n }\n\n /**\n * Retrieve an element from an option.\n * @param {string|jQuery|Element} option The option to check.\n * @return {?Element} The plain element or null.\n * @private\n */\n _getElementOption(option) {\n // If column width is a string, treat is as a selector and search for the\n // sizer element within the outermost container\n if (typeof option === 'string') {\n return this.element.querySelector(option);\n\n // Check for an element\n } else if (option && option.nodeType && option.nodeType === 1) {\n return option;\n\n // Check for jQuery object\n } else if (option && option.jquery) {\n return option[0];\n }\n\n return null;\n }\n\n /**\n * Ensures the shuffle container has the css styles it needs applied to it.\n * @param {Object} styles Key value pairs for position and overflow.\n * @private\n */\n _validateStyles(styles) {\n // Position cannot be static.\n if (styles.position === 'static') {\n this.element.style.position = 'relative';\n }\n\n // Overflow has to be hidden.\n if (styles.overflow !== 'hidden') {\n this.element.style.overflow = 'hidden';\n }\n }\n\n /**\n * Filter the elements by a category.\n * @param {string} [category] Category to filter by. If it's given, the last\n * category will be used to filter the items.\n * @param {Array} [collection] Optionally filter a collection. Defaults to\n * all the items.\n * @return {!{visible: Array, hidden: Array}}\n * @private\n */\n _filter(category = this.lastFilter, collection = this.items) {\n var set = this._getFilteredSets(category, collection);\n\n // Individually add/remove hidden/visible classes\n this._toggleFilterClasses(set);\n\n // Save the last filter in case elements are appended.\n this.lastFilter = category;\n\n // This is saved mainly because providing a filter function (like searching)\n // will overwrite the `lastFilter` property every time its called.\n if (typeof category === 'string') {\n this.group = category;\n }\n\n return set;\n }\n\n /**\n * Returns an object containing the visible and hidden elements.\n * @param {string|Function} category Category or function to filter by.\n * @param {Array.} items A collection of items to filter.\n * @return {!{visible: Array, hidden: Array}}\n * @private\n */\n _getFilteredSets(category, items) {\n let visible = [];\n let hidden = [];\n\n // category === 'all', add visible class to everything\n if (category === Shuffle.ALL_ITEMS) {\n visible = items;\n\n // Loop through each item and use provided function to determine\n // whether to hide it or not.\n } else {\n items.forEach((item) => {\n if (this._doesPassFilter(category, item.element)) {\n visible.push(item);\n } else {\n hidden.push(item);\n }\n });\n }\n\n return {\n visible,\n hidden,\n };\n }\n\n /**\n * Test an item to see if it passes a category.\n * @param {string|Function} category Category or function to filter by.\n * @param {Element} element An element to test.\n * @return {boolean} Whether it passes the category/filter.\n * @private\n */\n _doesPassFilter(category, element) {\n\n if (typeof category === 'function') {\n return category.call(element, element, this);\n\n // Check each element's data-groups attribute against the given category.\n } else {\n let attr = element.getAttribute('data-' + Shuffle.FILTER_ATTRIBUTE_KEY);\n let keys = this.options.delimeter ?\n attr.split(this.options.delimeter) :\n JSON.parse(attr);\n\n if (Array.isArray(category)) {\n return category.some(arrayIncludes(keys));\n }\n\n return arrayIncludes(keys, category);\n }\n }\n\n /**\n * Toggles the visible and hidden class names.\n * @param {{visible, hidden}} Object with visible and hidden arrays.\n * @private\n */\n _toggleFilterClasses({ visible, hidden }) {\n visible.forEach((item) => {\n item.show();\n });\n\n hidden.forEach((item) => {\n item.hide();\n });\n }\n\n /**\n * Set the initial css for each item\n * @param {Array.} [items] Optionally specifiy at set to initialize.\n * @private\n */\n _initItems(items = this.items) {\n items.forEach((item) => {\n item.init();\n });\n }\n\n /**\n * Remove element reference and styles.\n * @private\n */\n _disposeItems(items = this.items) {\n items.forEach((item) => {\n item.dispose();\n });\n }\n\n /**\n * Updates the visible item count.\n * @private\n */\n _updateItemCount() {\n this.visibleItems = this._getFilteredItems().length;\n }\n\n /**\n * Sets css transform transition on a group of elements. This is not executed\n * at the same time as `item.init` so that transitions don't occur upon\n * initialization of Shuffle.\n * @param {Array.} items Shuffle items to set transitions on.\n * @private\n */\n _setTransitions(items = this.items) {\n let speed = this.options.speed;\n let easing = this.options.easing;\n\n var str;\n if (this.options.useTransforms) {\n str = 'transform ' + speed + 'ms ' + easing +\n ', opacity ' + speed + 'ms ' + easing;\n } else {\n str = 'top ' + speed + 'ms ' + easing +\n ', left ' + speed + 'ms ' + easing +\n ', opacity ' + speed + 'ms ' + easing;\n }\n\n items.forEach((item) => {\n item.element.style.transition = str;\n });\n }\n\n _getItems() {\n return toArray(this.element.children)\n .filter(el => matches(el, this.options.itemSelector))\n .map(el => new ShuffleItem(el));\n }\n\n /**\n * When new elements are added to the shuffle container, update the array of\n * items because that is the order `_layout` calls them.\n */\n _updateItemsOrder() {\n let children = this.element.children;\n this.items = sorter(this.items, {\n by(element) {\n return Array.prototype.indexOf.call(children, element);\n },\n });\n }\n\n _getFilteredItems() {\n return this.items.filter(item => item.isVisible);\n }\n\n _getConcealedItems() {\n return this.items.filter(item => !item.isVisible);\n }\n\n /**\n * Returns the column size, based on column width and sizer options.\n * @param {number} containerWidth Size of the parent container.\n * @param {number} gutterSize Size of the gutters.\n * @return {number}\n * @private\n */\n _getColumnSize(containerWidth, gutterSize) {\n var size;\n\n // If the columnWidth property is a function, then the grid is fluid\n if (typeof this.options.columnWidth === 'function') {\n size = this.options.columnWidth(containerWidth);\n\n // columnWidth option isn't a function, are they using a sizing element?\n } else if (this.useSizer) {\n size = Shuffle.getSize(this.options.sizer).width;\n\n // if not, how about the explicitly set option?\n } else if (this.options.columnWidth) {\n size = this.options.columnWidth;\n\n // or use the size of the first item\n } else if (this.items.length > 0) {\n size = Shuffle.getSize(this.items[0].element, true).width;\n\n // if there's no items, use size of container\n } else {\n size = containerWidth;\n }\n\n // Don't let them set a column width of zero.\n if (size === 0) {\n size = containerWidth;\n }\n\n return size + gutterSize;\n }\n\n /**\n * Returns the gutter size, based on gutter width and sizer options.\n * @param {number} containerWidth Size of the parent container.\n * @return {number}\n * @private\n */\n _getGutterSize(containerWidth) {\n var size;\n if (typeof this.options.gutterWidth === 'function') {\n size = this.options.gutterWidth(containerWidth);\n } else if (this.useSizer) {\n size = getNumberStyle(this.options.sizer, 'marginLeft');\n } else {\n size = this.options.gutterWidth;\n }\n\n return size;\n }\n\n /**\n * Calculate the number of columns to be used. Gets css if using sizer element.\n * @param {number} [containerWidth] Optionally specify a container width if\n * it's already available.\n */\n _setColumns(containerWidth = Shuffle.getSize(this.element).width) {\n var gutter = this._getGutterSize(containerWidth);\n var columnWidth = this._getColumnSize(containerWidth, gutter);\n var calculatedColumns = (containerWidth + gutter) / columnWidth;\n\n // Widths given from getStyles are not precise enough...\n if (Math.abs(Math.round(calculatedColumns) - calculatedColumns) <\n this.options.columnThreshold) {\n // e.g. calculatedColumns = 11.998876\n calculatedColumns = Math.round(calculatedColumns);\n }\n\n this.cols = Math.max(Math.floor(calculatedColumns), 1);\n this.containerWidth = containerWidth;\n this.colWidth = columnWidth;\n }\n\n /**\n * Adjust the height of the grid\n */\n _setContainerSize() {\n this.element.style.height = this._getContainerSize() + 'px';\n }\n\n /**\n * Based on the column heights, it returns the biggest one.\n * @return {number}\n * @private\n */\n _getContainerSize() {\n return arrayMax(this.positions);\n }\n\n /**\n * Get the clamped stagger amount.\n * @param {number} index Index of the item to be staggered.\n * @return {number}\n */\n _getStaggerAmount(index) {\n return Math.min(index * this.options.staggerAmount, this.options.staggerAmountMax);\n }\n\n /**\n * @return {boolean} Whether the event was prevented or not.\n */\n _dispatch(name, details = {}) {\n if (this.isDestroyed) {\n return;\n }\n\n details.shuffle = this;\n return !this.element.dispatchEvent(new CustomEvent(name, {\n bubbles: true,\n cancelable: false,\n detail: details,\n }));\n }\n\n /**\n * Zeros out the y columns array, which is used to determine item placement.\n * @private\n */\n _resetCols() {\n var i = this.cols;\n this.positions = [];\n while (i--) {\n this.positions.push(0);\n }\n }\n\n /**\n * Loops through each item that should be shown and calculates the x, y position.\n * @param {Array.} items Array of items that will be shown/layed\n * out in order in their array.\n */\n _layout(items) {\n let count = 0;\n items.forEach((item) => {\n var currPos = item.point;\n var currScale = item.scale;\n var itemSize = Shuffle.getSize(item.element, true);\n var pos = this._getItemPosition(itemSize);\n\n function callback() {\n item.element.style.transitionDelay = '';\n item.applyCss(ShuffleItem.Css.VISIBLE.after);\n }\n\n // If the item will not change its position, do not add it to the render\n // queue. Transitions don't fire when setting a property to the same value.\n if (Point.equals(currPos, pos) && currScale === ShuffleItem.Scale.VISIBLE) {\n item.applyCss(ShuffleItem.Css.VISIBLE.before);\n callback();\n return;\n }\n\n item.point = pos;\n item.scale = ShuffleItem.Scale.VISIBLE;\n\n // Use xtend here to clone the object so that the `before` object isn't\n // modified when the transition delay is added.\n let styles = xtend(ShuffleItem.Css.VISIBLE.before);\n styles.transitionDelay = this._getStaggerAmount(count) + 'ms';\n\n this._queue.push({\n item,\n styles,\n callback,\n });\n\n count++;\n });\n }\n\n /**\n * Determine the location of the next item, based on its size.\n * @param {{width: number, height: number}} itemSize Object with width and height.\n * @return {Point}\n * @private\n */\n _getItemPosition(itemSize) {\n return getItemPosition({\n itemSize,\n positions: this.positions,\n gridSize: this.colWidth,\n total: this.cols,\n threshold: this.options.columnThreshold,\n buffer: this.options.buffer,\n });\n }\n\n /**\n * Hides the elements that don't match our filter.\n * @param {Array.} collection Collection to shrink.\n * @private\n */\n _shrink(collection = this._getConcealedItems()) {\n let count = 0;\n collection.forEach((item) => {\n function callback() {\n item.applyCss(ShuffleItem.Css.HIDDEN.after);\n }\n\n // Continuing would add a transitionend event listener to the element, but\n // that listener would not execute because the transform and opacity would\n // stay the same.\n // The callback is executed here because it is not guaranteed to be called\n // after the transitionend event because the transitionend could be\n // canceled if another animation starts.\n if (item.scale === ShuffleItem.Scale.HIDDEN) {\n item.applyCss(ShuffleItem.Css.HIDDEN.before);\n callback();\n return;\n }\n\n item.scale = ShuffleItem.Scale.HIDDEN;\n\n let styles = xtend(ShuffleItem.Css.HIDDEN.before);\n styles.transitionDelay = this._getStaggerAmount(count) + 'ms';\n\n this._queue.push({\n item,\n styles,\n callback,\n });\n\n count++;\n });\n }\n\n /**\n * Resize handler.\n * @private\n */\n _handleResize() {\n // If shuffle is disabled, destroyed, don't do anything\n if (!this.isEnabled || this.isDestroyed) {\n return;\n }\n\n // Will need to check height in the future if it's layed out horizontaly\n var containerWidth = Shuffle.getSize(this.element).width;\n\n // containerWidth hasn't changed, don't do anything\n if (containerWidth === this.containerWidth) {\n return;\n }\n\n this.update();\n }\n\n /**\n * Returns styles which will be applied to the an item for a transition.\n * @param {Object} obj Transition options.\n * @return {!Object} Transforms for transitions, left/top for animate.\n * @private\n */\n _getStylesForTransition({ item, styles }) {\n if (!styles.transitionDelay) {\n styles.transitionDelay = '0ms';\n }\n\n let x = item.point.x;\n let y = item.point.y;\n\n if (this.options.useTransforms) {\n styles.transform = `translate(${x}px, ${y}px) scale(${item.scale})`;\n } else {\n styles.left = x + 'px';\n styles.top = y + 'px';\n }\n\n return styles;\n }\n\n /**\n * Listen for the transition end on an element and execute the itemCallback\n * when it finishes.\n * @param {Element} element Element to listen on.\n * @param {Function} itemCallback Callback for the item.\n * @param {Function} done Callback to notify `parallel` that this one is done.\n */\n _whenTransitionDone(element, itemCallback, done) {\n let id = onTransitionEnd(element, (evt) => {\n itemCallback();\n done(null, evt);\n });\n\n this._transitions.push(id);\n }\n\n /**\n * Return a function which will set CSS styles and call the `done` function\n * when (if) the transition finishes.\n * @param {Object} opts Transition object.\n * @return {Function} A function to be called with a `done` function.\n */\n _getTransitionFunction(opts) {\n return (done) => {\n opts.item.applyCss(this._getStylesForTransition(opts));\n this._whenTransitionDone(opts.item.element, opts.callback, done);\n };\n }\n\n /**\n * Execute the styles gathered in the style queue. This applies styles to elements,\n * triggering transitions.\n * @private\n */\n _processQueue() {\n if (this.isTransitioning) {\n this._cancelMovement();\n }\n\n let hasSpeed = this.options.speed > 0;\n let hasQueue = this._queue.length > 0;\n\n if (hasQueue && hasSpeed && this.isInitialized) {\n this._startTransitions(this._queue);\n\n } else if (hasQueue) {\n this._styleImmediately(this._queue);\n this._dispatchLayout();\n\n // A call to layout happened, but none of the newly visible items will\n // change position or the transition duration is zero, which will not trigger\n // the transitionend event.\n } else {\n this._dispatchLayout();\n }\n\n // Remove everything in the style queue\n this._queue.length = 0;\n }\n\n /**\n * Wait for each transition to finish, the emit the layout event.\n * @param {Array.} transitions Array of transition objects.\n */\n _startTransitions(transitions) {\n // Set flag that shuffle is currently in motion.\n this.isTransitioning = true;\n\n // Create an array of functions to be called.\n let callbacks = transitions.map(obj => this._getTransitionFunction(obj));\n\n parallel(callbacks, this._movementFinished.bind(this));\n }\n\n _cancelMovement() {\n // Remove the transition end event for each listener.\n this._transitions.forEach(cancelTransitionEnd);\n\n // Reset the array.\n this._transitions.length = 0;\n\n // Show it's no longer active.\n this.isTransitioning = false;\n }\n\n /**\n * Apply styles without a transition.\n * @param {Array.} objects Array of transition objects.\n * @private\n */\n _styleImmediately(objects) {\n if (objects.length) {\n let elements = objects.map(obj => obj.item.element);\n\n Shuffle._skipTransitions(elements, () => {\n objects.forEach((obj) => {\n obj.item.applyCss(this._getStylesForTransition(obj));\n obj.callback();\n });\n });\n }\n }\n\n _movementFinished() {\n this._transitions.length = 0;\n this.isTransitioning = false;\n this._dispatchLayout();\n }\n\n _dispatchLayout() {\n this._dispatch(Shuffle.EventType.LAYOUT);\n }\n\n /**\n * The magic. This is what makes the plugin 'shuffle'\n * @param {string|Function|Array.} [category] Category to filter by.\n * Can be a function, string, or array of strings.\n * @param {Object} [sortObj] A sort object which can sort the visible set\n */\n filter(category, sortObj) {\n if (!this.isEnabled) {\n return;\n }\n\n if (!category || (category && category.length === 0)) {\n category = Shuffle.ALL_ITEMS;\n }\n\n this._filter(category);\n\n // Shrink each hidden item\n this._shrink();\n\n // How many visible elements?\n this._updateItemCount();\n\n // Update transforms on visible elements so they will animate to their new positions.\n this.sort(sortObj);\n }\n\n /**\n * Gets the visible elements, sorts them, and passes them to layout.\n * @param {Object} opts the options object for the sorted plugin\n */\n sort(opts = this.lastSort) {\n if (!this.isEnabled) {\n return;\n }\n\n this._resetCols();\n\n var items = this._getFilteredItems();\n items = sorter(items, opts);\n\n this._layout(items);\n\n // `_layout` always happens after `_shrink`, so it's safe to process the style\n // queue here with styles from the shrink method.\n this._processQueue();\n\n // Adjust the height of the container.\n this._setContainerSize();\n\n this.lastSort = opts;\n }\n\n /**\n * Reposition everything.\n * @param {boolean} isOnlyLayout If true, column and gutter widths won't be\n * recalculated.\n */\n update(isOnlyLayout) {\n if (this.isEnabled) {\n\n if (!isOnlyLayout) {\n // Get updated colCount\n this._setColumns();\n }\n\n // Layout items\n this.sort();\n }\n }\n\n /**\n * Use this instead of `update()` if you don't need the columns and gutters updated\n * Maybe an image inside `shuffle` loaded (and now has a height), which means calculations\n * could be off.\n */\n layout() {\n this.update(true);\n }\n\n /**\n * New items have been appended to shuffle. Mix them in with the current\n * filter or sort status.\n * @param {Array.} newItems Collection of new items.\n */\n add(newItems) {\n newItems = arrayUnique(newItems).map(el => new ShuffleItem(el));\n\n // Add classes and set initial positions.\n this._initItems(newItems);\n\n // Add transition to each item.\n this._setTransitions(newItems);\n\n // Update the list of items.\n this.items = this.items.concat(newItems);\n this._updateItemsOrder();\n this.filter(this.lastFilter);\n }\n\n /**\n * Disables shuffle from updating dimensions and layout on resize\n */\n disable() {\n this.isEnabled = false;\n }\n\n /**\n * Enables shuffle again\n * @param {boolean} [isUpdateLayout=true] if undefined, shuffle will update columns and gutters\n */\n enable(isUpdateLayout) {\n this.isEnabled = true;\n if (isUpdateLayout !== false) {\n this.update();\n }\n }\n\n /**\n * Remove 1 or more shuffle items\n * @param {Array.} collection An array containing one or more\n * elements in shuffle\n * @return {Shuffle} The shuffle object\n */\n remove(collection) {\n if (!collection.length) {\n return;\n }\n\n collection = arrayUnique(collection);\n\n let oldItems = collection\n .map(element => this.getItemByElement(element))\n .filter(item => !!item);\n\n let handleLayout = () => {\n this.element.removeEventListener(Shuffle.EventType.LAYOUT, handleLayout);\n this._disposeItems(oldItems);\n\n // Remove the collection in the callback\n collection.forEach((element) => {\n element.parentNode.removeChild(element);\n });\n\n this._dispatch(Shuffle.EventType.REMOVED, { collection });\n\n // Let it get garbage collected\n collection = null;\n oldItems = null;\n };\n\n // Hide collection first.\n this._toggleFilterClasses({\n visible: [],\n hidden: oldItems,\n });\n\n this._shrink(oldItems);\n\n this.sort();\n\n // Update the list of items here because `remove` could be called again\n // with an item that is in the process of being removed.\n this.items = this.items.filter(item => !arrayIncludes(oldItems, item));\n this._updateItemCount();\n\n this.element.addEventListener(Shuffle.EventType.LAYOUT, handleLayout);\n }\n\n /**\n * Retrieve a shuffle item by its element.\n * @param {Element} element Element to look for.\n * @return {?ShuffleItem} A shuffle item or null if it's not found.\n */\n getItemByElement(element) {\n for (var i = this.items.length - 1; i >= 0; i--) {\n if (this.items[i].element === element) {\n return this.items[i];\n }\n }\n\n return null;\n }\n\n /**\n * Destroys shuffle, removes events, styles, and classes\n */\n destroy() {\n this._cancelMovement();\n window.removeEventListener('resize', this._onResize);\n\n // Reset container styles\n this.element.classList.remove('shuffle');\n this.element.removeAttribute('style');\n\n // Reset individual item styles\n this._disposeItems();\n\n // Null DOM references\n this.items = null;\n this.options.sizer = null;\n this.element = null;\n this._transitions = null;\n\n // Set a flag so if a debounced resize has been triggered,\n // it can first check if it is actually isDestroyed and not doing anything\n this.isDestroyed = true;\n }\n\n /**\n * Returns the outer width of an element, optionally including its margins.\n *\n * There are a few different methods for getting the width of an element, none of\n * which work perfectly for all Shuffle's use cases.\n *\n * 1. getBoundingClientRect() `left` and `right` properties.\n * - Accounts for transform scaled elements, making it useless for Shuffle\n * elements which have shrunk.\n * 2. The `offsetWidth` property.\n * - This value stays the same regardless of the elements transform property,\n * however, it does not return subpixel values.\n * 3. getComputedStyle()\n * - This works great Chrome, Firefox, Safari, but IE<=11 does not include\n * padding and border when box-sizing: border-box is set, requiring a feature\n * test and extra work to add the padding back for IE and other browsers which\n * follow the W3C spec here.\n *\n * @param {Element} element The element.\n * @param {boolean} [includeMargins] Whether to include margins. Default is false.\n * @return {{width: number, height: number}} The width and height.\n */\n static getSize(element, includeMargins) {\n // Store the styles so that they can be used by others without asking for it again.\n var styles = window.getComputedStyle(element, null);\n var width = getNumberStyle(element, 'width', styles);\n var height = getNumberStyle(element, 'height', styles);\n\n if (includeMargins) {\n var marginLeft = getNumberStyle(element, 'marginLeft', styles);\n var marginRight = getNumberStyle(element, 'marginRight', styles);\n var marginTop = getNumberStyle(element, 'marginTop', styles);\n var marginBottom = getNumberStyle(element, 'marginBottom', styles);\n width += marginLeft + marginRight;\n height += marginTop + marginBottom;\n }\n\n return {\n width,\n height,\n };\n }\n\n /**\n * Change a property or execute a function which will not have a transition\n * @param {Array.} elements DOM elements that won't be transitioned.\n * @param {Function} callback A function which will be called while transition\n * is set to 0ms.\n * @private\n */\n static _skipTransitions(elements, callback) {\n let zero = '0ms';\n\n // Save current duration and delay.\n let data = elements.map((element) => {\n let style = element.style;\n let duration = style.transitionDuration;\n let delay = style.transitionDelay;\n\n // Set the duration to zero so it happens immediately\n style.transitionDuration = zero;\n style.transitionDelay = zero;\n\n return {\n duration,\n delay,\n };\n });\n\n callback();\n\n // Cause reflow.\n elements[0].offsetWidth; // jshint ignore:line\n\n // Put the duration back\n elements.forEach((element, i) => {\n element.style.transitionDuration = data[i].duration;\n element.style.transitionDelay = data[i].delay;\n });\n }\n}\n\nShuffle.ShuffleItem = ShuffleItem;\n\nShuffle.ALL_ITEMS = 'all';\nShuffle.FILTER_ATTRIBUTE_KEY = 'groups';\n\n/**\n * @enum {string}\n */\nShuffle.EventType = {\n LAYOUT: 'shuffle:layout',\n REMOVED: 'shuffle:removed',\n};\n\n/** @enum {string} */\nShuffle.Classes = Classes;\n\n// Overrideable options\nShuffle.options = {\n // Initial filter group.\n group: Shuffle.ALL_ITEMS,\n\n // Transition/animation speed (milliseconds).\n speed: 250,\n\n // CSS easing function to use.\n easing: 'ease',\n\n // e.g. '.picture-item'.\n itemSelector: '*',\n\n // Element or selector string. Use an element to determine the size of columns\n // and gutters.\n sizer: null,\n\n // A static number or function that tells the plugin how wide the gutters\n // between columns are (in pixels).\n gutterWidth: 0,\n\n // A static number or function that returns a number which tells the plugin\n // how wide the columns are (in pixels).\n columnWidth: 0,\n\n // If your group is not json, and is comma delimeted, you could set delimeter\n // to ','.\n delimeter: null,\n\n // Useful for percentage based heights when they might not always be exactly\n // the same (in pixels).\n buffer: 0,\n\n // Reading the width of elements isn't precise enough and can cause columns to\n // jump between values.\n columnThreshold: 0.01,\n\n // Shuffle can be isInitialized with a sort object. It is the same object\n // given to the sort method.\n initialSort: null,\n\n // By default, shuffle will throttle resize events. This can be changed or\n // removed.\n throttle: throttle,\n\n // How often shuffle can be called on resize (in milliseconds).\n throttleTime: 300,\n\n // Transition delay offset for each item in milliseconds.\n staggerAmount: 15,\n\n // Maximum stagger delay in milliseconds.\n staggerAmountMax: 250,\n\n // Whether to use transforms or absolute positioning.\n useTransforms: true,\n};\n\n// Expose for testing. Hack at your own risk.\nShuffle.__Point = Point;\nShuffle.__sorter = sorter;\nShuffle.__getColumnSpan = getColumnSpan;\nShuffle.__getAvailablePositions = getAvailablePositions;\nShuffle.__getShortColumn = getShortColumn;\n\nexport default Shuffle;\n"],"names":["CustomEvent","global","getNumber","value","parseFloat","Point","x","y","equals","a","b","id","ShuffleItem","element","isVisible","classList","remove","Classes","HIDDEN","add","VISIBLE","addClasses","SHUFFLE_ITEM","applyCss","Css","INITIAL","scale","Scale","point","classes","forEach","className","obj","key","style","removeClasses","removeAttribute","document","body","documentElement","e","createElement","cssText","appendChild","width","window","getComputedStyle","ret","removeChild","getNumberStyle","styles","COMPUTED_SIZE_INCLUDES_PADDING","paddingLeft","paddingRight","borderLeftWidth","borderRightWidth","paddingTop","paddingBottom","borderTopWidth","borderBottomWidth","randomize","array","tmp","current","top","length","Math","floor","random","defaults","sorter","arr","options","opts","xtend","original","slice","call","revert","by","sort","valA","valB","undefined","reverse","transitions","eventName","count","uniqueId","onTransitionEnd","callback","listener","evt","currentTarget","target","addEventListener","cancelTransitionEnd","removeEventListener","arrayMax","max","apply","arrayMin","min","getItemPosition","itemSize","positions","gridSize","total","threshold","buffer","span","getColumnSpan","setY","getAvailablePositions","shortColumnIndex","getShortColumn","round","setHeight","height","i","itemWidth","columnWidth","columns","columnSpan","abs","ceil","available","push","minPosition","len","toArray","arrayLike","Array","prototype","arrayIncludes","arguments","indexOf","Shuffle","useSizer","lastSort","group","lastFilter","ALL_ITEMS","isEnabled","isDestroyed","isInitialized","_transitions","isTransitioning","_queue","_getElementOption","TypeError","_init","items","_getItems","sizer","BASE","_initItems","_onResize","_getResizeFunction","containerCss","containerWidth","getSize","_validateStyles","_setColumns","filter","initialSort","offsetWidth","_setTransitions","transition","speed","easing","resizeFunction","_handleResize","bind","throttle","throttleTime","option","querySelector","nodeType","jquery","position","overflow","category","collection","set","_getFilteredSets","_toggleFilterClasses","visible","hidden","item","_doesPassFilter","attr","getAttribute","FILTER_ATTRIBUTE_KEY","keys","delimeter","split","JSON","parse","isArray","some","show","hide","init","dispose","visibleItems","_getFilteredItems","str","useTransforms","children","matches","el","itemSelector","map","gutterSize","size","gutterWidth","gutter","_getGutterSize","_getColumnSize","calculatedColumns","columnThreshold","cols","colWidth","_getContainerSize","index","staggerAmount","staggerAmountMax","name","details","shuffle","dispatchEvent","currPos","currScale","pos","_getItemPosition","transitionDelay","after","before","_getStaggerAmount","_getConcealedItems","update","transform","left","itemCallback","done","_getStylesForTransition","_whenTransitionDone","_cancelMovement","hasSpeed","hasQueue","_startTransitions","_styleImmediately","_dispatchLayout","callbacks","_getTransitionFunction","_movementFinished","objects","elements","_skipTransitions","_dispatch","EventType","LAYOUT","sortObj","_filter","_shrink","_updateItemCount","_resetCols","_layout","_processQueue","_setContainerSize","isOnlyLayout","newItems","arrayUnique","concat","_updateItemsOrder","isUpdateLayout","oldItems","getItemByElement","handleLayout","_disposeItems","parentNode","REMOVED","includeMargins","marginLeft","marginRight","marginTop","marginBottom","zero","data","duration","transitionDuration","delay","__Point","__sorter","__getColumnSpan","__getAvailablePositions","__getShortColumn"],"mappings":";;;;;;AAAA;;;;;;AAMA,IAAI;IACA,IAAI,EAAE,GAAG,IAAI,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACxC,EAAE,CAAC,cAAc,EAAE,CAAC;IACpB,IAAI,EAAE,CAAC,gBAAgB,KAAK,IAAI,EAAE;;;QAG9B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;KAChD;CACJ,CAAC,MAAM,CAAC,EAAE;EACT,IAAIA,aAAW,GAAG,SAAS,KAAK,EAAE,MAAM,EAAE;IACxC,IAAI,GAAG,EAAE,WAAW,CAAC;IACrB,MAAM,GAAG,MAAM,IAAI;MACjB,OAAO,EAAE,KAAK;MACd,UAAU,EAAE,KAAK;MACjB,MAAM,EAAE,SAAS;KAClB,CAAC;;IAEF,GAAG,GAAG,QAAQ,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAC1C,GAAG,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7E,WAAW,GAAG,GAAG,CAAC,cAAc,CAAC;IACjC,GAAG,CAAC,cAAc,GAAG,YAAY;MAC/B,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;MACvB,IAAI;QACF,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,kBAAkB,EAAE;UAC9C,GAAG,EAAE,YAAY;YACf,OAAO,IAAI,CAAC;WACb;SACF,CAAC,CAAC;OACJ,CAAC,MAAM,CAAC,EAAE;QACT,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;OAC9B;KACF,CAAC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CAvBG;;;;aA2BL,IA3BK;;;;UA+BR,CA/BQ;;;;mBAmCC,IAnCD;;;;eAuCH,IAvCG;;;;YA2CNgC,OA3CM;;;gBA8CF,GA9CE;;;iBAiDD,EAjDC;;;oBAoDE,GApDF;;;iBAuDD;CAvDjB;;;AA2DArC,QAAQ4J,OAAR,GAAkBhS,KAAlB;AACAoI,QAAQ6J,QAAR,GAAmBhO,MAAnB;AACAmE,QAAQ8J,eAAR,GAA0BxL,aAA1B;AACA0B,QAAQ+J,uBAAR,GAAkCvL,qBAAlC;AACAwB,QAAQgK,gBAAR,GAA2BtL,cAA3B,CAEA;;;;"} \ No newline at end of file diff --git a/dist/shuffle.min.js b/dist/shuffle.min.js index 07876db..07956de 100644 --- a/dist/shuffle.min.js +++ b/dist/shuffle.min.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.shuffle=e():t.shuffle=e()}(this,function(){return function(t){function e(n){if(i[n])return i[n].exports;var s=i[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,e),s.l=!0,s.exports}var i={};return e.m=t,e.c=i,e.i=function(t){return t},e.d=function(t,i,n){e.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,"a",i),i},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=17)}([function(t,e,i){"use strict";var n=i(2),s=function(t,e){this.x=i.i(n.a)(t),this.y=i.i(n.a)(e)};s.equals=function(t,e){return t.x===e.x&&t.y===e.y},e.a=s},function(t,e,i){"use strict";e.a={BASE:"shuffle",SHUFFLE_ITEM:"shuffle-item",VISIBLE:"shuffle-item--visible",HIDDEN:"shuffle-item--hidden"}},function(t,e,i){"use strict";function n(t){return parseFloat(t)||0}e.a=n},function(t,e){function i(){for(var t={},e=0;e-1}}Object.defineProperty(e,"__esModule",{value:!0});var a=i(13),u=(i.n(a),i(14)),l=i.n(u),h=i(6),c=i.n(h),f=i(3),d=i.n(f),p=i(15),v=i.n(p),m=i(5),y=i.n(m),g=i(0),_=i(11),E=i(1),b=i(8),S=i(12),I=i(10),k=i(9),w=function(){function t(t,e){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:{};if(n(this,t),this.options=d()(t.options,i),this.useSizer=!1,this.lastSort={},this.group=this.lastFilter=t.ALL_ITEMS,this.isEnabled=!0,this.isDestroyed=!1,this.isInitialized=!1,this._transitions=[],this.isTransitioning=!1,this._queue=[],e=this._getElementOption(e),!e)throw new TypeError("Shuffle needs to be initialized with an element.");this.element=e,this.id="shuffle_"+T++,this._init(),this.isInitialized=!0}return w(t,[{key:"_init",value:function(){this.items=this._getItems(),this.options.sizer=this._getElementOption(this.options.sizer),this.options.sizer&&(this.useSizer=!0),this.element.classList.add(t.Classes.BASE),this._initItems(),this._onResize=this._getResizeFunction(),window.addEventListener("resize",this._onResize);var e=window.getComputedStyle(this.element,null),i=t.getSize(this.element).width;this._validateStyles(e),this._setColumns(i),this.filter(this.options.group,this.options.initialSort),this.element.offsetWidth,this._setTransitions(),this.element.style.transition="height "+this.options.speed+"ms "+this.options.easing}},{key:"_getResizeFunction",value:function(){var t=this._handleResize.bind(this);return this.options.throttle?this.options.throttle(t,this.options.throttleTime):t}},{key:"_getElementOption",value:function(t){return"string"==typeof t?this.element.querySelector(t):t&&t.nodeType&&1===t.nodeType?t:t&&t.jquery?t[0]:null}},{key:"_validateStyles",value:function(t){"static"===t.position&&(this.element.style.position="relative"),"hidden"!==t.overflow&&(this.element.style.overflow="hidden")}},{key:"_filter",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.lastFilter,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.items,i=this._getFilteredSets(t,e);return this._toggleFilterClasses(i),this.lastFilter=t,"string"==typeof t&&(this.group=t),i}},{key:"_getFilteredSets",value:function(e,i){var n=this,s=[],o=[];return e===t.ALL_ITEMS?s=i:i.forEach(function(t){n._doesPassFilter(e,t.element)?s.push(t):o.push(t)}),{visible:s,hidden:o}}},{key:"_doesPassFilter",value:function(e,i){if("function"==typeof e)return e.call(i,i,this);var n=i.getAttribute("data-"+t.FILTER_ATTRIBUTE_KEY),s=this.options.delimeter?n.split(this.options.delimeter):JSON.parse(n);return Array.isArray(e)?e.some(r(s)):r(s,e)}},{key:"_toggleFilterClasses",value:function(t){var e=t.visible,i=t.hidden;e.forEach(function(t){t.show()}),i.forEach(function(t){t.hide()})}},{key:"_initItems",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.items;t.forEach(function(t){t.init()})}},{key:"_disposeItems",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.items;t.forEach(function(t){t.dispose()})}},{key:"_updateItemCount",value:function(){this.visibleItems=this._getFilteredItems().length}},{key:"_setTransitions",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.items,i=this.options.speed,n=this.options.easing;t=this.options.useTransforms?"transform "+i+"ms "+n+", opacity "+i+"ms "+n:"top "+i+"ms "+n+", left "+i+"ms "+n+", opacity "+i+"ms "+n,e.forEach(function(e){e.element.style.transition=t})}},{key:"_getItems",value:function(){var t=this;return s(this.element.children).filter(function(e){return l()(e,t.options.itemSelector)}).map(function(t){return new _.a(t)})}},{key:"_updateItemsOrder",value:function(){var t=this.element.children;this.items=i.i(S.a)(this.items,{by:function(e){return Array.prototype.indexOf.call(t,e)}})}},{key:"_getFilteredItems",value:function(){return this.items.filter(function(t){return t.isVisible})}},{key:"_getConcealedItems",value:function(){return this.items.filter(function(t){return!t.isVisible})}},{key:"_getColumnSize",value:function(e,i){var n;return n="function"==typeof this.options.columnWidth?this.options.columnWidth(e):this.useSizer?t.getSize(this.options.sizer).width:this.options.columnWidth?this.options.columnWidth:this.items.length>0?t.getSize(this.items[0].element,!0).width:e,0===n&&(n=e),n+i}},{key:"_getGutterSize",value:function(t){var e;return e="function"==typeof this.options.gutterWidth?this.options.gutterWidth(t):this.useSizer?i.i(b.a)(this.options.sizer,"marginLeft"):this.options.gutterWidth}},{key:"_setColumns",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:t.getSize(this.element).width,i=this._getGutterSize(e),n=this._getColumnSize(e,i),s=(e+i)/n;Math.abs(Math.round(s)-s)1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isDestroyed)return e.shuffle=this,!this.element.dispatchEvent(new CustomEvent(t,{bubbles:!0,cancelable:!1,detail:e}))}},{key:"_resetCols",value:function(){var t=this.cols;for(this.positions=[];t--;)this.positions.push(0)}},{key:"_layout",value:function(e){var i=this,n=0;e.forEach(function(e){function s(){e.element.style.transitionDelay="",e.applyCss(_.a.Css.VISIBLE.after)}var o=e.point,r=e.scale,a=t.getSize(e.element,!0),u=i._getItemPosition(a);if(g.a.equals(o,u)&&r===_.a.Scale.VISIBLE)return e.applyCss(_.a.Css.VISIBLE.before),void s();e.point=u,e.scale=_.a.Scale.VISIBLE;var l=d()(_.a.Css.VISIBLE.before);l.transitionDelay=i._getStaggerAmount(n)+"ms",i._queue.push({item:e,styles:l,callback:s}),n++})}},{key:"_getItemPosition",value:function(t){return i.i(k.a)({itemSize:t,positions:this.positions,gridSize:this.colWidth,total:this.cols,threshold:this.options.columnThreshold,buffer:this.options.buffer})}},{key:"_shrink",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._getConcealedItems(),i=0;e.forEach(function(e){function n(){e.applyCss(_.a.Css.HIDDEN.after)}if(e.scale===_.a.Scale.HIDDEN)return e.applyCss(_.a.Css.HIDDEN.before),void n();e.scale=_.a.Scale.HIDDEN;var s=d()(_.a.Css.HIDDEN.before);s.transitionDelay=t._getStaggerAmount(i)+"ms",t._queue.push({item:e,styles:s,callback:n}),i++})}},{key:"_handleResize",value:function(){if(this.isEnabled&&!this.isDestroyed){var e=t.getSize(this.element).width;e!==this.containerWidth&&this.update()}}},{key:"_getStylesForTransition",value:function(t){var e=t.item,i=t.styles;i.transitionDelay||(i.transitionDelay="0ms");var n=e.point.x,s=e.point.y;return this.options.useTransforms?i.transform="translate("+n+"px, "+s+"px) scale("+e.scale+")":(i.left=n+"px",i.top=s+"px"),i}},{key:"_whenTransitionDone",value:function(t,e,n){var s=i.i(I.a)(t,function(t){e(),n(null,t)});this._transitions.push(s)}},{key:"_getTransitionFunction",value:function(t){var e=this;return function(i){t.item.applyCss(e._getStylesForTransition(t)),e._whenTransitionDone(t.item.element,t.callback,i)}}},{key:"_processQueue",value:function(){this.isTransitioning&&this._cancelMovement();var t=this.options.speed>0,e=this._queue.length>0;e&&t&&this.isInitialized?this._startTransitions(this._queue):e?(this._styleImmediately(this._queue),this._dispatchLayout()):this._dispatchLayout(),this._queue.length=0}},{key:"_startTransitions",value:function(t){var e=this;this.isTransitioning=!0;var i=t.map(function(t){return e._getTransitionFunction(t)});y()(i,this._movementFinished.bind(this))}},{key:"_cancelMovement",value:function(){this._transitions.forEach(I.b),this._transitions.length=0,this.isTransitioning=!1}},{key:"_styleImmediately",value:function(e){var i=this;if(e.length){var n=e.map(function(t){return t.item.element});t._skipTransitions(n,function(){e.forEach(function(t){t.item.applyCss(i._getStylesForTransition(t)),t.callback()})})}}},{key:"_movementFinished",value:function(){this._transitions.length=0,this.isTransitioning=!1,this._dispatchLayout()}},{key:"_dispatchLayout",value:function(){this._dispatch(t.EventType.LAYOUT)}},{key:"filter",value:function(e,i){this.isEnabled&&((!e||e&&0===e.length)&&(e=t.ALL_ITEMS),this._filter(e),this._shrink(),this._updateItemCount(),this.sort(i))}},{key:"sort",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.lastSort;if(this.isEnabled){this._resetCols();var e=this._getFilteredItems();e=i.i(S.a)(e,t),this._layout(e),this._processQueue(),this._setContainerSize(),this.lastSort=t}}},{key:"update",value:function(t){this.isEnabled&&(t||this._setColumns(),this.sort())}},{key:"layout",value:function(){this.update(!0)}},{key:"add",value:function(t){t=c()(t).map(function(t){return new _.a(t)}),this._initItems(t),this._setTransitions(t),this.items=this.items.concat(t),this._updateItemsOrder(),this.filter(this.lastFilter)}},{key:"disable",value:function(){this.isEnabled=!1}},{key:"enable",value:function(t){this.isEnabled=!0,t!==!1&&this.update()}},{key:"remove",value:function(e){var i=this;if(e.length){e=c()(e);var n=e.map(function(t){return i.getItemByElement(t)}).filter(function(t){return!!t}),s=function s(){i.element.removeEventListener(t.EventType.LAYOUT,s),i._disposeItems(n),e.forEach(function(t){t.parentNode.removeChild(t)}),i._dispatch(t.EventType.REMOVED,{collection:e}),e=null,n=null};this._toggleFilterClasses({visible:[],hidden:n}),this._shrink(n),this.sort(),this.items=this.items.filter(function(t){return!r(n,t)}),this._updateItemCount(),this.element.addEventListener(t.EventType.LAYOUT,s)}}},{key:"getItemByElement",value:function(t){for(var e=this.items.length-1;e>=0;e--)if(this.items[e].element===t)return this.items[e];return null}},{key:"destroy",value:function(){this._cancelMovement(),window.removeEventListener("resize",this._onResize),this.element.classList.remove("shuffle"),this.element.removeAttribute("style"),this._disposeItems(),this.items=null,this.options.sizer=null,this.element=null,this._transitions=null,this.isDestroyed=!0}}],[{key:"getSize",value:function(t,e){var n=window.getComputedStyle(t,null),s=i.i(b.a)(t,"width",n),o=i.i(b.a)(t,"height",n);if(e){var r=i.i(b.a)(t,"marginLeft",n),a=i.i(b.a)(t,"marginRight",n),u=i.i(b.a)(t,"marginTop",n),l=i.i(b.a)(t,"marginBottom",n);s+=r+a,o+=u+l}return{width:s,height:o}}},{key:"_skipTransitions",value:function(t,e){var i="0ms",n=t.map(function(t){var e=t.style,n=e.transitionDuration,s=e.transitionDelay;return e.transitionDuration=i,e.transitionDelay=i,{duration:n,delay:s}});e(),t[0].offsetWidth,t.forEach(function(t,e){t.style.transitionDuration=n[e].duration,t.style.transitionDelay=n[e].delay})}}]),t}();C.ShuffleItem=_.a,C.ALL_ITEMS="all",C.FILTER_ATTRIBUTE_KEY="groups",C.EventType={LAYOUT:"shuffle:layout",REMOVED:"shuffle:removed"},C.Classes=E.a,C.options={group:C.ALL_ITEMS,speed:250,easing:"ease",itemSelector:"*",sizer:null,gutterWidth:0,columnWidth:0,delimeter:null,buffer:0,columnThreshold:.01,initialSort:null,throttle:v.a,throttleTime:300,staggerAmount:15,staggerAmountMax:250,useTransforms:!0},C.__Point=g.a,C.__sorter=S.a,C.__getColumnSpan=k.b,C.__getAvailablePositions=k.c,C.__getShortColumn=k.d,e.default=C},function(t,e){function i(){}t.exports=function(t,e,n){function s(t){return function(e,i){if(!r){if(e)return n(e,a),void(r=!0);a[t]=i,--o||n(null,a)}}}n||("function"==typeof e?(n=e,e=null):n=i);var o=t&&t.length;if(!o)return n(null,[]);var r=!1,a=new Array(o);t.forEach(e?function(t,i){t.call(e,s(i))}:function(t,e){t(s(e))})}},function(t,e,i){"use strict";(function(e){function i(t){for(var e=[],i=0;i2&&void 0!==arguments[2]?arguments[2]:window.getComputedStyle(t,null),r=i.i(s.a)(n[e]);return o.a||"width"!==e?o.a||"height"!==e||(r+=i.i(s.a)(n.paddingTop)+i.i(s.a)(n.paddingBottom)+i.i(s.a)(n.borderTopWidth)+i.i(s.a)(n.borderBottomWidth)):r+=i.i(s.a)(n.paddingLeft)+i.i(s.a)(n.paddingRight)+i.i(s.a)(n.borderLeftWidth)+i.i(s.a)(n.borderRightWidth),r}var s=i(2),o=i(7);e.a=n},function(t,e,i){"use strict";function n(t){return Math.max.apply(Math,t)}function s(t){return Math.min.apply(Math,t)}function o(t){for(var e=t.itemSize,i=t.positions,n=t.gridSize,s=t.total,o=t.threshold,h=t.buffer,c=r(e.width,n,s,o),f=a(i,c,s),d=u(f,h),p=new l.a(Math.round(n*d),Math.round(f[d])),v=f[d]+e.height,m=0;m=i-e&&t[n]<=i+e)return n;return 0}var l=i(0);e.a=o,e.b=r,e.c=a,e.d=u},function(t,e,i){"use strict";function n(){return a+u++}function s(t,e){var i=n(),s=function(t){t.currentTarget===t.target&&(o(i),e(t))};return t.addEventListener(a,s),r[i]={element:t,listener:s},i}function o(t){return!!r[t]&&(r[t].element.removeEventListener(a,r[t].listener),r[t]=null,!0)}e.a=s,e.b=o;var r={},a="transitionend",u=0},function(t,e,i){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var s=i(0),o=i(1),r=function(){function t(t,e){for(var i=0;is||"sortLast"===n||"sortFirst"===s?1:0}),o?s:(i.reverse&&t.reverse(),t)):[]}var o=i(3),r=i.n(o);e.a=s;var a={reverse:!1,by:null,randomize:!1,key:"element"}},function(t,e){try{var i=new window.CustomEvent("test");if(i.preventDefault(),i.defaultPrevented!==!0)throw new Error("Could not prevent default")}catch(t){var n=function(t,e){var i,n;return e=e||{bubbles:!1,cancelable:!1,detail:void 0},i=document.createEvent("CustomEvent"),i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),n=i.preventDefault,i.preventDefault=function(){n.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(t){this.defaultPrevented=!0}},i};n.prototype=window.Event.prototype,window.CustomEvent=n}},function(t,e,i){"use strict";function n(t,e){if(o)return o.call(t,e);for(var i=t.parentNode.querySelectorAll(e),n=0;n=e?i():r=setTimeout(i,e-t)),o}}t.exports=i},function(t,e){var i;i=function(){return this}();try{i=i||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){t.exports=i(4).default}])}); -//# sourceMappingURL=shuffle.min.js.map \ No newline at end of file +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.shuffle=e()}(this,function(){"use strict";function t(t,e){if(b)return b.call(t,e);for(var i=t.parentNode.querySelectorAll(e),n=0;n=e?i():r=setTimeout(i,e-t)),o}}function n(){}function s(t){return parseFloat(t)||0}function o(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:window.getComputedStyle(t,null),n=s(i[e]);return N||"width"!==e?N||"height"!==e||(n+=s(i.paddingTop)+s(i.paddingBottom)+s(i.borderTopWidth)+s(i.borderBottomWidth)):n+=s(i.paddingLeft)+s(i.paddingRight)+s(i.borderLeftWidth)+s(i.borderRightWidth),n}function r(t){var e,i,n=t.length;if(!n)return t;for(;--n;)i=Math.floor(Math.random()*(n+1)),e=t[i],t[i]=t[n],t[n]=e;return t}function l(t,e){var i=w(R,e),n=[].slice.call(t),s=!1;return t.length?i.randomize?r(t):("function"==typeof i.by&&t.sort(function(t,e){if(s)return 0;var n=i.by(t[i.key]),o=i.by(e[i.key]);return void 0===n&&void 0===o?(s=!0,0):no||"sortLast"===n||"sortFirst"===o?1:0}),s?n:(i.reverse&&t.reverse(),t)):[]}function a(){return q+P++}function u(t,e){var i=a(),n=function(t){t.currentTarget===t.target&&(h(i),e(t))};return t.addEventListener(q,n),H[i]={element:t,listener:n},i}function h(t){return!!H[t]&&(H[t].element.removeEventListener(q,H[t].listener),H[t]=null,!0)}function f(t){return Math.max.apply(Math,t)}function c(t){return Math.min.apply(Math,t)}function d(t){for(var e=t.itemSize,i=t.positions,n=t.gridSize,s=t.total,o=t.threshold,r=t.buffer,l=m(e.width,n,s,o),a=p(i,l,s),u=v(a,r),h=new D(Math.round(n*u),Math.round(a[u])),f=a[u]+e.height,c=0;c=i-e&&t[n]<=i+e)return n;return 0}function y(t){return Array.prototype.slice.call(t)}function g(t,e){return 2===arguments.length?g(t)(e):function(e){return t.indexOf(e)>-1}}try{var _=new window.CustomEvent("test");if(_.preventDefault(),!0!==_.defaultPrevented)throw new Error("Could not prevent default")}catch(t){var E=function(t,e){var i,n;return e=e||{bubbles:!1,cancelable:!1,detail:void 0},i=document.createEvent("CustomEvent"),i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),n=i.preventDefault,i.preventDefault=function(){n.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(t){this.defaultPrevented=!0}},i};E.prototype=window.Event.prototype,window.CustomEvent=E}var S=Element.prototype,b=S.matches||S.matchesSelector||S.webkitMatchesSelector||S.mozMatchesSelector||S.msMatchesSelector||S.oMatchesSelector,I=t,k="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},T=function(t,e){return e={exports:{}},t(e,e.exports),e.exports}(function(t){function e(t){for(var e=[],i=0;i1&&void 0!==arguments[1]?arguments[1]:{};if(F(this,t),this.options=w(t.options,i),this.useSizer=!1,this.lastSort={},this.group=this.lastFilter=t.ALL_ITEMS,this.isEnabled=!0,this.isDestroyed=!1,this.isInitialized=!1,this._transitions=[],this.isTransitioning=!1,this._queue=[],!(e=this._getElementOption(e)))throw new TypeError("Shuffle needs to be initialized with an element.");this.element=e,this.id="shuffle_"+U++,this._init(),this.isInitialized=!0}return A(t,[{key:"_init",value:function(){this.items=this._getItems(),this.options.sizer=this._getElementOption(this.options.sizer),this.options.sizer&&(this.useSizer=!0),this.element.classList.add(t.Classes.BASE),this._initItems(),this._onResize=this._getResizeFunction(),window.addEventListener("resize",this._onResize);var e=window.getComputedStyle(this.element,null),i=t.getSize(this.element).width;this._validateStyles(e),this._setColumns(i),this.filter(this.options.group,this.options.initialSort),this.element.offsetWidth,this._setTransitions(),this.element.style.transition="height "+this.options.speed+"ms "+this.options.easing}},{key:"_getResizeFunction",value:function(){var t=this._handleResize.bind(this);return this.options.throttle?this.options.throttle(t,this.options.throttleTime):t}},{key:"_getElementOption",value:function(t){return"string"==typeof t?this.element.querySelector(t):t&&t.nodeType&&1===t.nodeType?t:t&&t.jquery?t[0]:null}},{key:"_validateStyles",value:function(t){"static"===t.position&&(this.element.style.position="relative"),"hidden"!==t.overflow&&(this.element.style.overflow="hidden")}},{key:"_filter",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.lastFilter,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.items,i=this._getFilteredSets(t,e);return this._toggleFilterClasses(i),this.lastFilter=t,"string"==typeof t&&(this.group=t),i}},{key:"_getFilteredSets",value:function(e,i){var n=this,s=[],o=[];return e===t.ALL_ITEMS?s=i:i.forEach(function(t){n._doesPassFilter(e,t.element)?s.push(t):o.push(t)}),{visible:s,hidden:o}}},{key:"_doesPassFilter",value:function(e,i){if("function"==typeof e)return e.call(i,i,this);var n=i.getAttribute("data-"+t.FILTER_ATTRIBUTE_KEY),s=this.options.delimeter?n.split(this.options.delimeter):JSON.parse(n);return Array.isArray(e)?e.some(g(s)):g(s,e)}},{key:"_toggleFilterClasses",value:function(t){var e=t.visible,i=t.hidden;e.forEach(function(t){t.show()}),i.forEach(function(t){t.hide()})}},{key:"_initItems",value:function(){(arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.items).forEach(function(t){t.init()})}},{key:"_disposeItems",value:function(){(arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.items).forEach(function(t){t.dispose()})}},{key:"_updateItemCount",value:function(){this.visibleItems=this._getFilteredItems().length}},{key:"_setTransitions",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.items,i=this.options.speed,n=this.options.easing;t=this.options.useTransforms?"transform "+i+"ms "+n+", opacity "+i+"ms "+n:"top "+i+"ms "+n+", left "+i+"ms "+n+", opacity "+i+"ms "+n,e.forEach(function(e){e.element.style.transition=t})}},{key:"_getItems",value:function(){var t=this;return y(this.element.children).filter(function(e){return I(e,t.options.itemSelector)}).map(function(t){return new B(t)})}},{key:"_updateItemsOrder",value:function(){var t=this.element.children;this.items=l(this.items,{by:function(e){return Array.prototype.indexOf.call(t,e)}})}},{key:"_getFilteredItems",value:function(){return this.items.filter(function(t){return t.isVisible})}},{key:"_getConcealedItems",value:function(){return this.items.filter(function(t){return!t.isVisible})}},{key:"_getColumnSize",value:function(e,i){var n;return n="function"==typeof this.options.columnWidth?this.options.columnWidth(e):this.useSizer?t.getSize(this.options.sizer).width:this.options.columnWidth?this.options.columnWidth:this.items.length>0?t.getSize(this.items[0].element,!0).width:e,0===n&&(n=e),n+i}},{key:"_getGutterSize",value:function(t){return"function"==typeof this.options.gutterWidth?this.options.gutterWidth(t):this.useSizer?o(this.options.sizer,"marginLeft"):this.options.gutterWidth}},{key:"_setColumns",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:t.getSize(this.element).width,i=this._getGutterSize(e),n=this._getColumnSize(e,i),s=(e+i)/n;Math.abs(Math.round(s)-s)1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isDestroyed)return e.shuffle=this,!this.element.dispatchEvent(new CustomEvent(t,{bubbles:!0,cancelable:!1,detail:e}))}},{key:"_resetCols",value:function(){var t=this.cols;for(this.positions=[];t--;)this.positions.push(0)}},{key:"_layout",value:function(e){var i=this,n=0;e.forEach(function(e){function s(){e.element.style.transitionDelay="",e.applyCss(B.Css.VISIBLE.after)}var o=e.point,r=e.scale,l=t.getSize(e.element,!0),a=i._getItemPosition(l);if(D.equals(o,a)&&r===B.Scale.VISIBLE)return e.applyCss(B.Css.VISIBLE.before),void s();e.point=a,e.scale=B.Scale.VISIBLE;var u=w(B.Css.VISIBLE.before);u.transitionDelay=i._getStaggerAmount(n)+"ms",i._queue.push({item:e,styles:u,callback:s}),n++})}},{key:"_getItemPosition",value:function(t){return d({itemSize:t,positions:this.positions,gridSize:this.colWidth,total:this.cols,threshold:this.options.columnThreshold,buffer:this.options.buffer})}},{key:"_shrink",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._getConcealedItems(),i=0;e.forEach(function(e){function n(){e.applyCss(B.Css.HIDDEN.after)}if(e.scale===B.Scale.HIDDEN)return e.applyCss(B.Css.HIDDEN.before),void n();e.scale=B.Scale.HIDDEN;var s=w(B.Css.HIDDEN.before);s.transitionDelay=t._getStaggerAmount(i)+"ms",t._queue.push({item:e,styles:s,callback:n}),i++})}},{key:"_handleResize",value:function(){if(this.isEnabled&&!this.isDestroyed){t.getSize(this.element).width!==this.containerWidth&&this.update()}}},{key:"_getStylesForTransition",value:function(t){var e=t.item,i=t.styles;i.transitionDelay||(i.transitionDelay="0ms");var n=e.point.x,s=e.point.y;return this.options.useTransforms?i.transform="translate("+n+"px, "+s+"px) scale("+e.scale+")":(i.left=n+"px",i.top=s+"px"),i}},{key:"_whenTransitionDone",value:function(t,e,i){var n=u(t,function(t){e(),i(null,t)});this._transitions.push(n)}},{key:"_getTransitionFunction",value:function(t){var e=this;return function(i){t.item.applyCss(e._getStylesForTransition(t)),e._whenTransitionDone(t.item.element,t.callback,i)}}},{key:"_processQueue",value:function(){this.isTransitioning&&this._cancelMovement();var t=this.options.speed>0,e=this._queue.length>0;e&&t&&this.isInitialized?this._startTransitions(this._queue):e?(this._styleImmediately(this._queue),this._dispatchLayout()):this._dispatchLayout(),this._queue.length=0}},{key:"_startTransitions",value:function(t){var e=this;this.isTransitioning=!0;var i=t.map(function(t){return e._getTransitionFunction(t)});z(i,this._movementFinished.bind(this))}},{key:"_cancelMovement",value:function(){this._transitions.forEach(h),this._transitions.length=0,this.isTransitioning=!1}},{key:"_styleImmediately",value:function(e){var i=this;if(e.length){var n=e.map(function(t){return t.item.element});t._skipTransitions(n,function(){e.forEach(function(t){t.item.applyCss(i._getStylesForTransition(t)),t.callback()})})}}},{key:"_movementFinished",value:function(){this._transitions.length=0,this.isTransitioning=!1,this._dispatchLayout()}},{key:"_dispatchLayout",value:function(){this._dispatch(t.EventType.LAYOUT)}},{key:"filter",value:function(e,i){this.isEnabled&&((!e||e&&0===e.length)&&(e=t.ALL_ITEMS),this._filter(e),this._shrink(),this._updateItemCount(),this.sort(i))}},{key:"sort",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.lastSort;if(this.isEnabled){this._resetCols();var e=this._getFilteredItems();e=l(e,t),this._layout(e),this._processQueue(),this._setContainerSize(),this.lastSort=t}}},{key:"update",value:function(t){this.isEnabled&&(t||this._setColumns(),this.sort())}},{key:"layout",value:function(){this.update(!0)}},{key:"add",value:function(t){t=T(t).map(function(t){return new B(t)}),this._initItems(t),this._setTransitions(t),this.items=this.items.concat(t),this._updateItemsOrder(),this.filter(this.lastFilter)}},{key:"disable",value:function(){this.isEnabled=!1}},{key:"enable",value:function(t){this.isEnabled=!0,!1!==t&&this.update()}},{key:"remove",value:function(e){var i=this;if(e.length){e=T(e);var n=e.map(function(t){return i.getItemByElement(t)}).filter(function(t){return!!t}),s=function s(){i.element.removeEventListener(t.EventType.LAYOUT,s),i._disposeItems(n),e.forEach(function(t){t.parentNode.removeChild(t)}),i._dispatch(t.EventType.REMOVED,{collection:e}),e=null,n=null};this._toggleFilterClasses({visible:[],hidden:n}),this._shrink(n),this.sort(),this.items=this.items.filter(function(t){return!g(n,t)}),this._updateItemCount(),this.element.addEventListener(t.EventType.LAYOUT,s)}}},{key:"getItemByElement",value:function(t){for(var e=this.items.length-1;e>=0;e--)if(this.items[e].element===t)return this.items[e];return null}},{key:"destroy",value:function(){this._cancelMovement(),window.removeEventListener("resize",this._onResize),this.element.classList.remove("shuffle"),this.element.removeAttribute("style"),this._disposeItems(),this.items=null,this.options.sizer=null,this.element=null,this._transitions=null,this.isDestroyed=!0}}],[{key:"getSize",value:function(t,e){var i=window.getComputedStyle(t,null),n=o(t,"width",i),s=o(t,"height",i);if(e){var r=o(t,"marginLeft",i),l=o(t,"marginRight",i),a=o(t,"marginTop",i),u=o(t,"marginBottom",i);n+=r+l,s+=a+u}return{width:n,height:s}}},{key:"_skipTransitions",value:function(t,e){var i=t.map(function(t){var e=t.style,i=e.transitionDuration,n=e.transitionDelay;return e.transitionDuration="0ms",e.transitionDelay="0ms",{duration:i,delay:n}});e(),t[0].offsetWidth,t.forEach(function(t,e){t.style.transitionDuration=i[e].duration,t.style.transitionDelay=i[e].delay})}}]),t}();return Y.ShuffleItem=B,Y.ALL_ITEMS="all",Y.FILTER_ATTRIBUTE_KEY="groups",Y.EventType={LAYOUT:"shuffle:layout",REMOVED:"shuffle:removed"},Y.Classes=M,Y.options={group:Y.ALL_ITEMS,speed:250,easing:"ease",itemSelector:"*",sizer:null,gutterWidth:0,columnWidth:0,delimeter:null,buffer:0,columnThreshold:.01,initialSort:null,throttle:C,throttleTime:300,staggerAmount:15,staggerAmountMax:250,useTransforms:!0},Y.__Point=D,Y.__sorter=l,Y.__getColumnSpan=m,Y.__getAvailablePositions=p,Y.__getShortColumn=v,Y}); +//# sourceMappingURL=shuffle.min.js.map diff --git a/dist/shuffle.min.js.map b/dist/shuffle.min.js.map index 852ee98..0ef6f0d 100644 --- a/dist/shuffle.min.js.map +++ b/dist/shuffle.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///shuffle.min.js","webpack:///webpack/bootstrap 35a3cfe3322ce6f556df","webpack:///./src/point.js","webpack:///./src/classes.js","webpack:///./src/get-number.js","webpack:///./~/xtend/immutable.js","webpack:///./src/shuffle.js","webpack:///./~/array-parallel/index.js","webpack:///./~/array-uniq/index.js","webpack:///./src/computed-size.js","webpack:///./src/get-number-style.js","webpack:///./src/layout.js","webpack:///./src/on-transition-end.js","webpack:///./src/shuffle-item.js","webpack:///./src/sorter.js","webpack:///./~/custom-event-polyfill/custom-event-polyfill.js","webpack:///./~/matches-selector/index.js","webpack:///./~/throttleit/index.js","webpack:///(webpack)/buildin/global.js","webpack:///./src/index.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","value","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","__webpack_exports__","__WEBPACK_IMPORTED_MODULE_0__get_number__","Point","x","y","equals","a","b","BASE","SHUFFLE_ITEM","VISIBLE","HIDDEN","getNumber","parseFloat","extend","target","arguments","length","source","key","_classCallCheck","instance","Constructor","TypeError","toArray","arrayLike","Array","slice","arrayMax","array","Math","max","apply","arrayIncludes","obj","indexOf","__WEBPACK_IMPORTED_MODULE_0_custom_event_polyfill__","__WEBPACK_IMPORTED_MODULE_1_matches_selector__","__WEBPACK_IMPORTED_MODULE_1_matches_selector___default","__WEBPACK_IMPORTED_MODULE_2_array_uniq__","__WEBPACK_IMPORTED_MODULE_2_array_uniq___default","__WEBPACK_IMPORTED_MODULE_3_xtend__","__WEBPACK_IMPORTED_MODULE_3_xtend___default","__WEBPACK_IMPORTED_MODULE_4_throttleit__","__WEBPACK_IMPORTED_MODULE_4_throttleit___default","__WEBPACK_IMPORTED_MODULE_5_array_parallel__","__WEBPACK_IMPORTED_MODULE_5_array_parallel___default","__WEBPACK_IMPORTED_MODULE_6__point__","__WEBPACK_IMPORTED_MODULE_7__shuffle_item__","__WEBPACK_IMPORTED_MODULE_8__classes__","__WEBPACK_IMPORTED_MODULE_9__get_number_style__","__WEBPACK_IMPORTED_MODULE_10__sorter__","__WEBPACK_IMPORTED_MODULE_11__on_transition_end__","__WEBPACK_IMPORTED_MODULE_12__layout__","_createClass","defineProperties","props","descriptor","writable","protoProps","staticProps","id","Shuffle","element","options","undefined","useSizer","lastSort","group","lastFilter","ALL_ITEMS","isEnabled","isDestroyed","isInitialized","_transitions","isTransitioning","_queue","_getElementOption","_init","items","_getItems","sizer","classList","add","Classes","_initItems","_onResize","_getResizeFunction","window","addEventListener","containerCss","getComputedStyle","containerWidth","getSize","width","_validateStyles","_setColumns","filter","initialSort","offsetWidth","_setTransitions","style","transition","speed","easing","resizeFunction","_handleResize","bind","throttle","throttleTime","option","querySelector","nodeType","jquery","styles","position","overflow","category","collection","set","_getFilteredSets","_toggleFilterClasses","_this","visible","hidden","forEach","item","_doesPassFilter","push","attr","getAttribute","FILTER_ATTRIBUTE_KEY","keys","delimeter","split","JSON","parse","isArray","some","_ref","show","hide","init","dispose","visibleItems","_getFilteredItems","str","useTransforms","_this2","children","el","itemSelector","map","by","isVisible","gutterSize","size","columnWidth","gutterWidth","gutter","_getGutterSize","_getColumnSize","calculatedColumns","abs","round","columnThreshold","cols","floor","colWidth","height","_getContainerSize","positions","index","min","staggerAmount","staggerAmountMax","details","shuffle","dispatchEvent","CustomEvent","bubbles","cancelable","detail","_this3","count","callback","transitionDelay","applyCss","Css","after","currPos","point","currScale","scale","itemSize","pos","_getItemPosition","Scale","before","_getStaggerAmount","gridSize","total","threshold","buffer","_this4","_getConcealedItems","update","_ref2","transform","left","top","itemCallback","done","evt","opts","_this5","_getStylesForTransition","_whenTransitionDone","_cancelMovement","hasSpeed","hasQueue","_startTransitions","_styleImmediately","_dispatchLayout","transitions","_this6","callbacks","_getTransitionFunction","_movementFinished","objects","_this7","elements","_skipTransitions","_dispatch","EventType","LAYOUT","sortObj","_filter","_shrink","_updateItemCount","sort","_resetCols","_layout","_processQueue","_setContainerSize","isOnlyLayout","newItems","concat","_updateItemsOrder","isUpdateLayout","_this8","oldItems","getItemByElement","handleLayout","removeEventListener","_disposeItems","parentNode","removeChild","REMOVED","remove","removeAttribute","includeMargins","marginLeft","marginRight","marginTop","marginBottom","zero","data","duration","transitionDuration","delay","ShuffleItem","__Point","__sorter","__getColumnSpan","__getAvailablePositions","__getShortColumn","noop","fns","context","maybeDone","err","result","finished","results","pending","fn","global","uniqNoSet","arr","ret","uniqSet","seen","Set","has","uniqSetWithForEach","doesForEachActuallyWork","document","body","documentElement","e","createElement","cssText","appendChild","getNumberStyle","__WEBPACK_IMPORTED_MODULE_1__computed_size__","paddingTop","paddingBottom","borderTopWidth","borderBottomWidth","paddingLeft","paddingRight","borderLeftWidth","borderRightWidth","arrayMin","getItemPosition","span","getColumnSpan","setY","getAvailablePositions","shortColumnIndex","getShortColumn","__WEBPACK_IMPORTED_MODULE_0__point__","setHeight","itemWidth","columns","columnSpan","ceil","available","minPosition","len","uniqueId","eventName","onTransitionEnd","listener","currentTarget","cancelTransitionEnd","__WEBPACK_IMPORTED_MODULE_1__classes__","addClasses","INITIAL","classes","className","removeClasses","visibility","will-change","opacity","randomize","tmp","current","random","sorter","__WEBPACK_IMPORTED_MODULE_0_xtend___default","defaults","original","revert","valA","valB","reverse","__WEBPACK_IMPORTED_MODULE_0_xtend__","ce","preventDefault","defaultPrevented","Error","event","params","origPrevent","createEvent","initCustomEvent","Event","match","selector","vendor","nodes","querySelectorAll","proto","Element","matches","matchesSelector","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector","func","wait","timeoutID","last","Date","rtn","ctx","args","delta","setTimeout","g","Function","eval","default"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,IACA,kBAAAG,gBAAAC,IACAD,UAAAH,GACA,gBAAAC,SACAA,QAAA,QAAAD,IAEAD,EAAA,QAAAC,KACCK,KAAA,WACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAP,OAGA,IAAAC,GAAAO,EAAAD,IACAE,EAAAF,EACAG,GAAA,EACAV,WAUA,OANAK,GAAAE,GAAAI,KAAAV,EAAAD,QAAAC,IAAAD,QAAAM,GAGAL,EAAAS,GAAA,EAGAT,EAAAD,QAvBA,GAAAQ,KA+DA,OAnCAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAG,EAAA,SAAAK,GAA2C,MAAAA,IAG3CR,EAAAS,EAAA,SAAAf,EAAAgB,EAAAC,GACAX,EAAAY,EAAAlB,EAAAgB,IACAG,OAAAC,eAAApB,EAAAgB,GACAK,cAAA,EACAC,YAAA,EACAC,IAAAN,KAMAX,EAAAkB,EAAA,SAAAvB,GACA,GAAAgB,GAAAhB,KAAAwB,WACA,WAA2B,MAAAxB,GAAA,SAC3B,WAAiC,MAAAA,GAEjC,OADAK,GAAAS,EAAAE,EAAA,IAAAA,GACAA,GAIAX,EAAAY,EAAA,SAAAQ,EAAAC,GAAsD,MAAAR,QAAAS,UAAAC,eAAAlB,KAAAe,EAAAC,IAGtDrB,EAAAwB,EAAA,GAGAxB,IAAAyB,EAAA,MDgBM,SAAU9B,EAAQ+B,EAAqB1B,GAE7C,YACqB,IAAI2B,GAA4C3B,EAAoB,GE1EnF4B,EAAQ,SAAUC,EAAGC,GACzBhC,KAAK+B,EAAI7B,EAAAG,EAAAwB,EAAA,GA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A,GAAAgO,GAAAC,QAAA3X,UACAuX,EAAAG,EAAAE,SACAF,EAAAG,iBACAH,EAAAI,uBACAJ,EAAAK,oBACAL,EAAAM,mBACAN,EAAAO,gBAEA5Z,GAAAD,QAAAiZ,GhB4mEM,SAAUhZ,EAAQD,GiB5mExB,QAAA4I,GAAAkR,EAAAC,GAcA,QAAApZ,KACAqZ,EAAA,EACAC,GAAA,GAAAC,MACAC,EAAAL,EAAA9V,MAAAoW,EAAAC,GACAD,EAAA,KACAC,EAAA,KAlBA,GAAAD,GAAAC,EAAAF,EAAAH,EACAC,EAAA,CAEA,mBACAG,EAAAha,KACAia,EAAArX,SACA,IAAAsX,GAAA,GAAAJ,MAAAD,CAIA,OAHAD,KACAM,GAAAP,EAAApZ,IACAqZ,EAAAO,WAAA5Z,EAAAoZ,EAAAO,IACAH,GArBAla,EAAAD,QAAA4I,GjB4pEM,SAAU3I,EAAQD,GkB5pExB,GAAAwa,EAGAA,GAAA,WACA,MAAApa,QAGA,KAEAoa,KAAAC,SAAA,qBAAAC,MAAA,QACC,MAAA9F,GAED,gBAAApN,UACAgT,EAAAhT,QAOAvH,EAAAD,QAAAwa,GlBmqEM,SAAUva,EAAQD,EAASM,GmBvrEjCL,EAAOD,QAAUM,EAAQ,GAAaqa","file":"shuffle.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"shuffle\"] = factory();\n\telse\n\t\troot[\"shuffle\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"shuffle\"] = factory();\n\telse\n\t\troot[\"shuffle\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// identity function for calling harmony imports with the correct context\n/******/ \t__webpack_require__.i = function(value) { return value; };\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 17);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__get_number__ = __webpack_require__(2);\n\n\n\n\n/**\n * Represents a coordinate pair.\n * @param {number} [x=0] X.\n * @param {number} [y=0] Y.\n */\nvar Point = function Point(x, y) {\n this.x = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__get_number__[\"a\" /* default */])(x);\n this.y = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__get_number__[\"a\" /* default */])(y);\n};\n\n/**\n * Whether two points are equal.\n * @param {Point} a Point A.\n * @param {Point} b Point B.\n * @return {boolean}\n */\nPoint.equals = function (a, b) {\n return a.x === b.x && a.y === b.y;\n};\n\n/* harmony default export */ __webpack_exports__[\"a\"] = Point;\n\n/***/ }),\n/* 1 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n/* harmony default export */ __webpack_exports__[\"a\"] = {\n BASE: 'shuffle',\n SHUFFLE_ITEM: 'shuffle-item',\n VISIBLE: 'shuffle-item--visible',\n HIDDEN: 'shuffle-item--hidden'\n};\n\n/***/ }),\n/* 2 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n/* harmony export (immutable) */ __webpack_exports__[\"a\"] = getNumber;\n\n\n/**\n * Always returns a numeric value, given a value. Logic from jQuery's `isNumeric`.\n * @param {*} value Possibly numeric value.\n * @return {number} `value` or zero if `value` isn't numeric.\n */\n\nfunction getNumber(value) {\n return parseFloat(value) || 0;\n}\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports) {\n\nmodule.exports = extend\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nfunction extend() {\n var target = {}\n\n for (var i = 0; i < arguments.length; i++) {\n var source = arguments[i]\n\n for (var key in source) {\n if (hasOwnProperty.call(source, key)) {\n target[key] = source[key]\n }\n }\n }\n\n return target\n}\n\n\n/***/ }),\n/* 4 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\nObject.defineProperty(__webpack_exports__, \"__esModule\", { value: true });\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_custom_event_polyfill__ = __webpack_require__(13);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_custom_event_polyfill___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_custom_event_polyfill__);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_matches_selector__ = __webpack_require__(14);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_matches_selector___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_matches_selector__);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_array_uniq__ = __webpack_require__(6);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_array_uniq___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_array_uniq__);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_xtend__ = __webpack_require__(3);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_xtend___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_xtend__);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_throttleit__ = __webpack_require__(15);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_throttleit___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_throttleit__);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_array_parallel__ = __webpack_require__(5);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_array_parallel___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_5_array_parallel__);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__point__ = __webpack_require__(0);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__shuffle_item__ = __webpack_require__(11);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__classes__ = __webpack_require__(1);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__get_number_style__ = __webpack_require__(8);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__sorter__ = __webpack_require__(12);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__on_transition_end__ = __webpack_require__(10);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__layout__ = __webpack_require__(9);\n\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfunction toArray(arrayLike) {\n return Array.prototype.slice.call(arrayLike);\n}\n\nfunction arrayMax(array) {\n return Math.max.apply(Math, array);\n}\n\nfunction arrayIncludes(array, obj) {\n if (arguments.length === 2) {\n return arrayIncludes(array)(obj);\n }\n\n return function (obj) {\n return array.indexOf(obj) > -1;\n };\n}\n\n// Used for unique instance variables\nvar id = 0;\n\nvar Shuffle = function () {\n\n /**\n * Categorize, sort, and filter a responsive grid of items.\n *\n * @param {Element} element An element which is the parent container for the grid items.\n * @param {Object} [options=Shuffle.options] Options object.\n * @constructor\n */\n function Shuffle(element) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n _classCallCheck(this, Shuffle);\n\n this.options = __WEBPACK_IMPORTED_MODULE_3_xtend___default()(Shuffle.options, options);\n\n this.useSizer = false;\n this.lastSort = {};\n this.group = this.lastFilter = Shuffle.ALL_ITEMS;\n this.isEnabled = true;\n this.isDestroyed = false;\n this.isInitialized = false;\n this._transitions = [];\n this.isTransitioning = false;\n this._queue = [];\n\n element = this._getElementOption(element);\n\n if (!element) {\n throw new TypeError('Shuffle needs to be initialized with an element.');\n }\n\n this.element = element;\n this.id = 'shuffle_' + id++;\n\n this._init();\n this.isInitialized = true;\n }\n\n _createClass(Shuffle, [{\n key: '_init',\n value: function _init() {\n this.items = this._getItems();\n\n this.options.sizer = this._getElementOption(this.options.sizer);\n\n if (this.options.sizer) {\n this.useSizer = true;\n }\n\n // Add class and invalidate styles\n this.element.classList.add(Shuffle.Classes.BASE);\n\n // Set initial css for each item\n this._initItems();\n\n // Bind resize events\n this._onResize = this._getResizeFunction();\n window.addEventListener('resize', this._onResize);\n\n // Get container css all in one request. Causes reflow\n var containerCss = window.getComputedStyle(this.element, null);\n var containerWidth = Shuffle.getSize(this.element).width;\n\n // Add styles to the container if it doesn't have them.\n this._validateStyles(containerCss);\n\n // We already got the container's width above, no need to cause another\n // reflow getting it again... Calculate the number of columns there will be\n this._setColumns(containerWidth);\n\n // Kick off!\n this.filter(this.options.group, this.options.initialSort);\n\n // The shuffle items haven't had transitions set on them yet so the user\n // doesn't see the first layout. Set them now that the first layout is done.\n // First, however, a synchronous layout must be caused for the previous\n // styles to be applied without transitions.\n this.element.offsetWidth; // jshint ignore: line\n this._setTransitions();\n this.element.style.transition = 'height ' + this.options.speed + 'ms ' + this.options.easing;\n }\n\n /**\n * Returns a throttled and proxied function for the resize handler.\n * @return {Function}\n * @private\n */\n\n }, {\n key: '_getResizeFunction',\n value: function _getResizeFunction() {\n var resizeFunction = this._handleResize.bind(this);\n return this.options.throttle ? this.options.throttle(resizeFunction, this.options.throttleTime) : resizeFunction;\n }\n\n /**\n * Retrieve an element from an option.\n * @param {string|jQuery|Element} option The option to check.\n * @return {?Element} The plain element or null.\n * @private\n */\n\n }, {\n key: '_getElementOption',\n value: function _getElementOption(option) {\n // If column width is a string, treat is as a selector and search for the\n // sizer element within the outermost container\n if (typeof option === 'string') {\n return this.element.querySelector(option);\n\n // Check for an element\n } else if (option && option.nodeType && option.nodeType === 1) {\n return option;\n\n // Check for jQuery object\n } else if (option && option.jquery) {\n return option[0];\n }\n\n return null;\n }\n\n /**\n * Ensures the shuffle container has the css styles it needs applied to it.\n * @param {Object} styles Key value pairs for position and overflow.\n * @private\n */\n\n }, {\n key: '_validateStyles',\n value: function _validateStyles(styles) {\n // Position cannot be static.\n if (styles.position === 'static') {\n this.element.style.position = 'relative';\n }\n\n // Overflow has to be hidden.\n if (styles.overflow !== 'hidden') {\n this.element.style.overflow = 'hidden';\n }\n }\n\n /**\n * Filter the elements by a category.\n * @param {string} [category] Category to filter by. If it's given, the last\n * category will be used to filter the items.\n * @param {Array} [collection] Optionally filter a collection. Defaults to\n * all the items.\n * @return {!{visible: Array, hidden: Array}}\n * @private\n */\n\n }, {\n key: '_filter',\n value: function _filter() {\n var category = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.lastFilter;\n var collection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.items;\n\n var set = this._getFilteredSets(category, collection);\n\n // Individually add/remove hidden/visible classes\n this._toggleFilterClasses(set);\n\n // Save the last filter in case elements are appended.\n this.lastFilter = category;\n\n // This is saved mainly because providing a filter function (like searching)\n // will overwrite the `lastFilter` property every time its called.\n if (typeof category === 'string') {\n this.group = category;\n }\n\n return set;\n }\n\n /**\n * Returns an object containing the visible and hidden elements.\n * @param {string|Function} category Category or function to filter by.\n * @param {Array.} items A collection of items to filter.\n * @return {!{visible: Array, hidden: Array}}\n * @private\n */\n\n }, {\n key: '_getFilteredSets',\n value: function _getFilteredSets(category, items) {\n var _this = this;\n\n var visible = [];\n var hidden = [];\n\n // category === 'all', add visible class to everything\n if (category === Shuffle.ALL_ITEMS) {\n visible = items;\n\n // Loop through each item and use provided function to determine\n // whether to hide it or not.\n } else {\n items.forEach(function (item) {\n if (_this._doesPassFilter(category, item.element)) {\n visible.push(item);\n } else {\n hidden.push(item);\n }\n });\n }\n\n return {\n visible: visible,\n hidden: hidden\n };\n }\n\n /**\n * Test an item to see if it passes a category.\n * @param {string|Function} category Category or function to filter by.\n * @param {Element} element An element to test.\n * @return {boolean} Whether it passes the category/filter.\n * @private\n */\n\n }, {\n key: '_doesPassFilter',\n value: function _doesPassFilter(category, element) {\n\n if (typeof category === 'function') {\n return category.call(element, element, this);\n\n // Check each element's data-groups attribute against the given category.\n } else {\n var attr = element.getAttribute('data-' + Shuffle.FILTER_ATTRIBUTE_KEY);\n var keys = this.options.delimeter ? attr.split(this.options.delimeter) : JSON.parse(attr);\n\n if (Array.isArray(category)) {\n return category.some(arrayIncludes(keys));\n }\n\n return arrayIncludes(keys, category);\n }\n }\n\n /**\n * Toggles the visible and hidden class names.\n * @param {{visible, hidden}} Object with visible and hidden arrays.\n * @private\n */\n\n }, {\n key: '_toggleFilterClasses',\n value: function _toggleFilterClasses(_ref) {\n var visible = _ref.visible,\n hidden = _ref.hidden;\n\n visible.forEach(function (item) {\n item.show();\n });\n\n hidden.forEach(function (item) {\n item.hide();\n });\n }\n\n /**\n * Set the initial css for each item\n * @param {Array.} [items] Optionally specifiy at set to initialize.\n * @private\n */\n\n }, {\n key: '_initItems',\n value: function _initItems() {\n var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.items;\n\n items.forEach(function (item) {\n item.init();\n });\n }\n\n /**\n * Remove element reference and styles.\n * @private\n */\n\n }, {\n key: '_disposeItems',\n value: function _disposeItems() {\n var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.items;\n\n items.forEach(function (item) {\n item.dispose();\n });\n }\n\n /**\n * Updates the visible item count.\n * @private\n */\n\n }, {\n key: '_updateItemCount',\n value: function _updateItemCount() {\n this.visibleItems = this._getFilteredItems().length;\n }\n\n /**\n * Sets css transform transition on a group of elements. This is not executed\n * at the same time as `item.init` so that transitions don't occur upon\n * initialization of Shuffle.\n * @param {Array.} items Shuffle items to set transitions on.\n * @private\n */\n\n }, {\n key: '_setTransitions',\n value: function _setTransitions() {\n var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.items;\n\n var speed = this.options.speed;\n var easing = this.options.easing;\n\n var str;\n if (this.options.useTransforms) {\n str = 'transform ' + speed + 'ms ' + easing + ', opacity ' + speed + 'ms ' + easing;\n } else {\n str = 'top ' + speed + 'ms ' + easing + ', left ' + speed + 'ms ' + easing + ', opacity ' + speed + 'ms ' + easing;\n }\n\n items.forEach(function (item) {\n item.element.style.transition = str;\n });\n }\n }, {\n key: '_getItems',\n value: function _getItems() {\n var _this2 = this;\n\n return toArray(this.element.children).filter(function (el) {\n return __WEBPACK_IMPORTED_MODULE_1_matches_selector___default()(el, _this2.options.itemSelector);\n }).map(function (el) {\n return new __WEBPACK_IMPORTED_MODULE_7__shuffle_item__[\"a\" /* default */](el);\n });\n }\n\n /**\n * When new elements are added to the shuffle container, update the array of\n * items because that is the order `_layout` calls them.\n */\n\n }, {\n key: '_updateItemsOrder',\n value: function _updateItemsOrder() {\n var children = this.element.children;\n this.items = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_10__sorter__[\"a\" /* default */])(this.items, {\n by: function by(element) {\n return Array.prototype.indexOf.call(children, element);\n }\n });\n }\n }, {\n key: '_getFilteredItems',\n value: function _getFilteredItems() {\n return this.items.filter(function (item) {\n return item.isVisible;\n });\n }\n }, {\n key: '_getConcealedItems',\n value: function _getConcealedItems() {\n return this.items.filter(function (item) {\n return !item.isVisible;\n });\n }\n\n /**\n * Returns the column size, based on column width and sizer options.\n * @param {number} containerWidth Size of the parent container.\n * @param {number} gutterSize Size of the gutters.\n * @return {number}\n * @private\n */\n\n }, {\n key: '_getColumnSize',\n value: function _getColumnSize(containerWidth, gutterSize) {\n var size;\n\n // If the columnWidth property is a function, then the grid is fluid\n if (typeof this.options.columnWidth === 'function') {\n size = this.options.columnWidth(containerWidth);\n\n // columnWidth option isn't a function, are they using a sizing element?\n } else if (this.useSizer) {\n size = Shuffle.getSize(this.options.sizer).width;\n\n // if not, how about the explicitly set option?\n } else if (this.options.columnWidth) {\n size = this.options.columnWidth;\n\n // or use the size of the first item\n } else if (this.items.length > 0) {\n size = Shuffle.getSize(this.items[0].element, true).width;\n\n // if there's no items, use size of container\n } else {\n size = containerWidth;\n }\n\n // Don't let them set a column width of zero.\n if (size === 0) {\n size = containerWidth;\n }\n\n return size + gutterSize;\n }\n\n /**\n * Returns the gutter size, based on gutter width and sizer options.\n * @param {number} containerWidth Size of the parent container.\n * @return {number}\n * @private\n */\n\n }, {\n key: '_getGutterSize',\n value: function _getGutterSize(containerWidth) {\n var size;\n if (typeof this.options.gutterWidth === 'function') {\n size = this.options.gutterWidth(containerWidth);\n } else if (this.useSizer) {\n size = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_9__get_number_style__[\"a\" /* default */])(this.options.sizer, 'marginLeft');\n } else {\n size = this.options.gutterWidth;\n }\n\n return size;\n }\n\n /**\n * Calculate the number of columns to be used. Gets css if using sizer element.\n * @param {number} [containerWidth] Optionally specify a container width if\n * it's already available.\n */\n\n }, {\n key: '_setColumns',\n value: function _setColumns() {\n var containerWidth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Shuffle.getSize(this.element).width;\n\n var gutter = this._getGutterSize(containerWidth);\n var columnWidth = this._getColumnSize(containerWidth, gutter);\n var calculatedColumns = (containerWidth + gutter) / columnWidth;\n\n // Widths given from getStyles are not precise enough...\n if (Math.abs(Math.round(calculatedColumns) - calculatedColumns) < this.options.columnThreshold) {\n // e.g. calculatedColumns = 11.998876\n calculatedColumns = Math.round(calculatedColumns);\n }\n\n this.cols = Math.max(Math.floor(calculatedColumns), 1);\n this.containerWidth = containerWidth;\n this.colWidth = columnWidth;\n }\n\n /**\n * Adjust the height of the grid\n */\n\n }, {\n key: '_setContainerSize',\n value: function _setContainerSize() {\n this.element.style.height = this._getContainerSize() + 'px';\n }\n\n /**\n * Based on the column heights, it returns the biggest one.\n * @return {number}\n * @private\n */\n\n }, {\n key: '_getContainerSize',\n value: function _getContainerSize() {\n return arrayMax(this.positions);\n }\n\n /**\n * Get the clamped stagger amount.\n * @param {number} index Index of the item to be staggered.\n * @return {number}\n */\n\n }, {\n key: '_getStaggerAmount',\n value: function _getStaggerAmount(index) {\n return Math.min(index * this.options.staggerAmount, this.options.staggerAmountMax);\n }\n\n /**\n * @return {boolean} Whether the event was prevented or not.\n */\n\n }, {\n key: '_dispatch',\n value: function _dispatch(name) {\n var details = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (this.isDestroyed) {\n return;\n }\n\n details.shuffle = this;\n return !this.element.dispatchEvent(new CustomEvent(name, {\n bubbles: true,\n cancelable: false,\n detail: details\n }));\n }\n\n /**\n * Zeros out the y columns array, which is used to determine item placement.\n * @private\n */\n\n }, {\n key: '_resetCols',\n value: function _resetCols() {\n var i = this.cols;\n this.positions = [];\n while (i--) {\n this.positions.push(0);\n }\n }\n\n /**\n * Loops through each item that should be shown and calculates the x, y position.\n * @param {Array.} items Array of items that will be shown/layed\n * out in order in their array.\n */\n\n }, {\n key: '_layout',\n value: function _layout(items) {\n var _this3 = this;\n\n var count = 0;\n items.forEach(function (item) {\n var currPos = item.point;\n var currScale = item.scale;\n var itemSize = Shuffle.getSize(item.element, true);\n var pos = _this3._getItemPosition(itemSize);\n\n function callback() {\n item.element.style.transitionDelay = '';\n item.applyCss(__WEBPACK_IMPORTED_MODULE_7__shuffle_item__[\"a\" /* default */].Css.VISIBLE.after);\n }\n\n // If the item will not change its position, do not add it to the render\n // queue. Transitions don't fire when setting a property to the same value.\n if (__WEBPACK_IMPORTED_MODULE_6__point__[\"a\" /* default */].equals(currPos, pos) && currScale === __WEBPACK_IMPORTED_MODULE_7__shuffle_item__[\"a\" /* default */].Scale.VISIBLE) {\n item.applyCss(__WEBPACK_IMPORTED_MODULE_7__shuffle_item__[\"a\" /* default */].Css.VISIBLE.before);\n callback();\n return;\n }\n\n item.point = pos;\n item.scale = __WEBPACK_IMPORTED_MODULE_7__shuffle_item__[\"a\" /* default */].Scale.VISIBLE;\n\n // Use xtend here to clone the object so that the `before` object isn't\n // modified when the transition delay is added.\n var styles = __WEBPACK_IMPORTED_MODULE_3_xtend___default()(__WEBPACK_IMPORTED_MODULE_7__shuffle_item__[\"a\" /* default */].Css.VISIBLE.before);\n styles.transitionDelay = _this3._getStaggerAmount(count) + 'ms';\n\n _this3._queue.push({\n item: item,\n styles: styles,\n callback: callback\n });\n\n count++;\n });\n }\n\n /**\n * Determine the location of the next item, based on its size.\n * @param {{width: number, height: number}} itemSize Object with width and height.\n * @return {Point}\n * @private\n */\n\n }, {\n key: '_getItemPosition',\n value: function _getItemPosition(itemSize) {\n return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_12__layout__[\"a\" /* getItemPosition */])({\n itemSize: itemSize,\n positions: this.positions,\n gridSize: this.colWidth,\n total: this.cols,\n threshold: this.options.columnThreshold,\n buffer: this.options.buffer\n });\n }\n\n /**\n * Hides the elements that don't match our filter.\n * @param {Array.} collection Collection to shrink.\n * @private\n */\n\n }, {\n key: '_shrink',\n value: function _shrink() {\n var _this4 = this;\n\n var collection = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._getConcealedItems();\n\n var count = 0;\n collection.forEach(function (item) {\n function callback() {\n item.applyCss(__WEBPACK_IMPORTED_MODULE_7__shuffle_item__[\"a\" /* default */].Css.HIDDEN.after);\n }\n\n // Continuing would add a transitionend event listener to the element, but\n // that listener would not execute because the transform and opacity would\n // stay the same.\n // The callback is executed here because it is not guaranteed to be called\n // after the transitionend event because the transitionend could be\n // canceled if another animation starts.\n if (item.scale === __WEBPACK_IMPORTED_MODULE_7__shuffle_item__[\"a\" /* default */].Scale.HIDDEN) {\n item.applyCss(__WEBPACK_IMPORTED_MODULE_7__shuffle_item__[\"a\" /* default */].Css.HIDDEN.before);\n callback();\n return;\n }\n\n item.scale = __WEBPACK_IMPORTED_MODULE_7__shuffle_item__[\"a\" /* default */].Scale.HIDDEN;\n\n var styles = __WEBPACK_IMPORTED_MODULE_3_xtend___default()(__WEBPACK_IMPORTED_MODULE_7__shuffle_item__[\"a\" /* default */].Css.HIDDEN.before);\n styles.transitionDelay = _this4._getStaggerAmount(count) + 'ms';\n\n _this4._queue.push({\n item: item,\n styles: styles,\n callback: callback\n });\n\n count++;\n });\n }\n\n /**\n * Resize handler.\n * @private\n */\n\n }, {\n key: '_handleResize',\n value: function _handleResize() {\n // If shuffle is disabled, destroyed, don't do anything\n if (!this.isEnabled || this.isDestroyed) {\n return;\n }\n\n // Will need to check height in the future if it's layed out horizontaly\n var containerWidth = Shuffle.getSize(this.element).width;\n\n // containerWidth hasn't changed, don't do anything\n if (containerWidth === this.containerWidth) {\n return;\n }\n\n this.update();\n }\n\n /**\n * Returns styles which will be applied to the an item for a transition.\n * @param {Object} obj Transition options.\n * @return {!Object} Transforms for transitions, left/top for animate.\n * @private\n */\n\n }, {\n key: '_getStylesForTransition',\n value: function _getStylesForTransition(_ref2) {\n var item = _ref2.item,\n styles = _ref2.styles;\n\n if (!styles.transitionDelay) {\n styles.transitionDelay = '0ms';\n }\n\n var x = item.point.x;\n var y = item.point.y;\n\n if (this.options.useTransforms) {\n styles.transform = 'translate(' + x + 'px, ' + y + 'px) scale(' + item.scale + ')';\n } else {\n styles.left = x + 'px';\n styles.top = y + 'px';\n }\n\n return styles;\n }\n\n /**\n * Listen for the transition end on an element and execute the itemCallback\n * when it finishes.\n * @param {Element} element Element to listen on.\n * @param {Function} itemCallback Callback for the item.\n * @param {Function} done Callback to notify `parallel` that this one is done.\n */\n\n }, {\n key: '_whenTransitionDone',\n value: function _whenTransitionDone(element, itemCallback, done) {\n var id = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_11__on_transition_end__[\"a\" /* onTransitionEnd */])(element, function (evt) {\n itemCallback();\n done(null, evt);\n });\n\n this._transitions.push(id);\n }\n\n /**\n * Return a function which will set CSS styles and call the `done` function\n * when (if) the transition finishes.\n * @param {Object} opts Transition object.\n * @return {Function} A function to be called with a `done` function.\n */\n\n }, {\n key: '_getTransitionFunction',\n value: function _getTransitionFunction(opts) {\n var _this5 = this;\n\n return function (done) {\n opts.item.applyCss(_this5._getStylesForTransition(opts));\n _this5._whenTransitionDone(opts.item.element, opts.callback, done);\n };\n }\n\n /**\n * Execute the styles gathered in the style queue. This applies styles to elements,\n * triggering transitions.\n * @private\n */\n\n }, {\n key: '_processQueue',\n value: function _processQueue() {\n if (this.isTransitioning) {\n this._cancelMovement();\n }\n\n var hasSpeed = this.options.speed > 0;\n var hasQueue = this._queue.length > 0;\n\n if (hasQueue && hasSpeed && this.isInitialized) {\n this._startTransitions(this._queue);\n } else if (hasQueue) {\n this._styleImmediately(this._queue);\n this._dispatchLayout();\n\n // A call to layout happened, but none of the newly visible items will\n // change position or the transition duration is zero, which will not trigger\n // the transitionend event.\n } else {\n this._dispatchLayout();\n }\n\n // Remove everything in the style queue\n this._queue.length = 0;\n }\n\n /**\n * Wait for each transition to finish, the emit the layout event.\n * @param {Array.} transitions Array of transition objects.\n */\n\n }, {\n key: '_startTransitions',\n value: function _startTransitions(transitions) {\n var _this6 = this;\n\n // Set flag that shuffle is currently in motion.\n this.isTransitioning = true;\n\n // Create an array of functions to be called.\n var callbacks = transitions.map(function (obj) {\n return _this6._getTransitionFunction(obj);\n });\n\n __WEBPACK_IMPORTED_MODULE_5_array_parallel___default()(callbacks, this._movementFinished.bind(this));\n }\n }, {\n key: '_cancelMovement',\n value: function _cancelMovement() {\n // Remove the transition end event for each listener.\n this._transitions.forEach(__WEBPACK_IMPORTED_MODULE_11__on_transition_end__[\"b\" /* cancelTransitionEnd */]);\n\n // Reset the array.\n this._transitions.length = 0;\n\n // Show it's no longer active.\n this.isTransitioning = false;\n }\n\n /**\n * Apply styles without a transition.\n * @param {Array.} objects Array of transition objects.\n * @private\n */\n\n }, {\n key: '_styleImmediately',\n value: function _styleImmediately(objects) {\n var _this7 = this;\n\n if (objects.length) {\n var elements = objects.map(function (obj) {\n return obj.item.element;\n });\n\n Shuffle._skipTransitions(elements, function () {\n objects.forEach(function (obj) {\n obj.item.applyCss(_this7._getStylesForTransition(obj));\n obj.callback();\n });\n });\n }\n }\n }, {\n key: '_movementFinished',\n value: function _movementFinished() {\n this._transitions.length = 0;\n this.isTransitioning = false;\n this._dispatchLayout();\n }\n }, {\n key: '_dispatchLayout',\n value: function _dispatchLayout() {\n this._dispatch(Shuffle.EventType.LAYOUT);\n }\n\n /**\n * The magic. This is what makes the plugin 'shuffle'\n * @param {string|Function|Array.} [category] Category to filter by.\n * Can be a function, string, or array of strings.\n * @param {Object} [sortObj] A sort object which can sort the visible set\n */\n\n }, {\n key: 'filter',\n value: function filter(category, sortObj) {\n if (!this.isEnabled) {\n return;\n }\n\n if (!category || category && category.length === 0) {\n category = Shuffle.ALL_ITEMS;\n }\n\n this._filter(category);\n\n // Shrink each hidden item\n this._shrink();\n\n // How many visible elements?\n this._updateItemCount();\n\n // Update transforms on visible elements so they will animate to their new positions.\n this.sort(sortObj);\n }\n\n /**\n * Gets the visible elements, sorts them, and passes them to layout.\n * @param {Object} opts the options object for the sorted plugin\n */\n\n }, {\n key: 'sort',\n value: function sort() {\n var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.lastSort;\n\n if (!this.isEnabled) {\n return;\n }\n\n this._resetCols();\n\n var items = this._getFilteredItems();\n items = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_10__sorter__[\"a\" /* default */])(items, opts);\n\n this._layout(items);\n\n // `_layout` always happens after `_shrink`, so it's safe to process the style\n // queue here with styles from the shrink method.\n this._processQueue();\n\n // Adjust the height of the container.\n this._setContainerSize();\n\n this.lastSort = opts;\n }\n\n /**\n * Reposition everything.\n * @param {boolean} isOnlyLayout If true, column and gutter widths won't be\n * recalculated.\n */\n\n }, {\n key: 'update',\n value: function update(isOnlyLayout) {\n if (this.isEnabled) {\n\n if (!isOnlyLayout) {\n // Get updated colCount\n this._setColumns();\n }\n\n // Layout items\n this.sort();\n }\n }\n\n /**\n * Use this instead of `update()` if you don't need the columns and gutters updated\n * Maybe an image inside `shuffle` loaded (and now has a height), which means calculations\n * could be off.\n */\n\n }, {\n key: 'layout',\n value: function layout() {\n this.update(true);\n }\n\n /**\n * New items have been appended to shuffle. Mix them in with the current\n * filter or sort status.\n * @param {Array.} newItems Collection of new items.\n */\n\n }, {\n key: 'add',\n value: function add(newItems) {\n newItems = __WEBPACK_IMPORTED_MODULE_2_array_uniq___default()(newItems).map(function (el) {\n return new __WEBPACK_IMPORTED_MODULE_7__shuffle_item__[\"a\" /* default */](el);\n });\n\n // Add classes and set initial positions.\n this._initItems(newItems);\n\n // Add transition to each item.\n this._setTransitions(newItems);\n\n // Update the list of items.\n this.items = this.items.concat(newItems);\n this._updateItemsOrder();\n this.filter(this.lastFilter);\n }\n\n /**\n * Disables shuffle from updating dimensions and layout on resize\n */\n\n }, {\n key: 'disable',\n value: function disable() {\n this.isEnabled = false;\n }\n\n /**\n * Enables shuffle again\n * @param {boolean} [isUpdateLayout=true] if undefined, shuffle will update columns and gutters\n */\n\n }, {\n key: 'enable',\n value: function enable(isUpdateLayout) {\n this.isEnabled = true;\n if (isUpdateLayout !== false) {\n this.update();\n }\n }\n\n /**\n * Remove 1 or more shuffle items\n * @param {Array.} collection An array containing one or more\n * elements in shuffle\n * @return {Shuffle} The shuffle object\n */\n\n }, {\n key: 'remove',\n value: function remove(collection) {\n var _this8 = this;\n\n if (!collection.length) {\n return;\n }\n\n collection = __WEBPACK_IMPORTED_MODULE_2_array_uniq___default()(collection);\n\n var oldItems = collection.map(function (element) {\n return _this8.getItemByElement(element);\n }).filter(function (item) {\n return !!item;\n });\n\n var handleLayout = function handleLayout() {\n _this8.element.removeEventListener(Shuffle.EventType.LAYOUT, handleLayout);\n _this8._disposeItems(oldItems);\n\n // Remove the collection in the callback\n collection.forEach(function (element) {\n element.parentNode.removeChild(element);\n });\n\n _this8._dispatch(Shuffle.EventType.REMOVED, { collection: collection });\n\n // Let it get garbage collected\n collection = null;\n oldItems = null;\n };\n\n // Hide collection first.\n this._toggleFilterClasses({\n visible: [],\n hidden: oldItems\n });\n\n this._shrink(oldItems);\n\n this.sort();\n\n // Update the list of items here because `remove` could be called again\n // with an item that is in the process of being removed.\n this.items = this.items.filter(function (item) {\n return !arrayIncludes(oldItems, item);\n });\n this._updateItemCount();\n\n this.element.addEventListener(Shuffle.EventType.LAYOUT, handleLayout);\n }\n\n /**\n * Retrieve a shuffle item by its element.\n * @param {Element} element Element to look for.\n * @return {?ShuffleItem} A shuffle item or null if it's not found.\n */\n\n }, {\n key: 'getItemByElement',\n value: function getItemByElement(element) {\n for (var i = this.items.length - 1; i >= 0; i--) {\n if (this.items[i].element === element) {\n return this.items[i];\n }\n }\n\n return null;\n }\n\n /**\n * Destroys shuffle, removes events, styles, and classes\n */\n\n }, {\n key: 'destroy',\n value: function destroy() {\n this._cancelMovement();\n window.removeEventListener('resize', this._onResize);\n\n // Reset container styles\n this.element.classList.remove('shuffle');\n this.element.removeAttribute('style');\n\n // Reset individual item styles\n this._disposeItems();\n\n // Null DOM references\n this.items = null;\n this.options.sizer = null;\n this.element = null;\n this._transitions = null;\n\n // Set a flag so if a debounced resize has been triggered,\n // it can first check if it is actually isDestroyed and not doing anything\n this.isDestroyed = true;\n }\n\n /**\n * Returns the outer width of an element, optionally including its margins.\n *\n * There are a few different methods for getting the width of an element, none of\n * which work perfectly for all Shuffle's use cases.\n *\n * 1. getBoundingClientRect() `left` and `right` properties.\n * - Accounts for transform scaled elements, making it useless for Shuffle\n * elements which have shrunk.\n * 2. The `offsetWidth` property.\n * - This value stays the same regardless of the elements transform property,\n * however, it does not return subpixel values.\n * 3. getComputedStyle()\n * - This works great Chrome, Firefox, Safari, but IE<=11 does not include\n * padding and border when box-sizing: border-box is set, requiring a feature\n * test and extra work to add the padding back for IE and other browsers which\n * follow the W3C spec here.\n *\n * @param {Element} element The element.\n * @param {boolean} [includeMargins] Whether to include margins. Default is false.\n * @return {{width: number, height: number}} The width and height.\n */\n\n }], [{\n key: 'getSize',\n value: function getSize(element, includeMargins) {\n // Store the styles so that they can be used by others without asking for it again.\n var styles = window.getComputedStyle(element, null);\n var width = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_9__get_number_style__[\"a\" /* default */])(element, 'width', styles);\n var height = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_9__get_number_style__[\"a\" /* default */])(element, 'height', styles);\n\n if (includeMargins) {\n var marginLeft = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_9__get_number_style__[\"a\" /* default */])(element, 'marginLeft', styles);\n var marginRight = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_9__get_number_style__[\"a\" /* default */])(element, 'marginRight', styles);\n var marginTop = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_9__get_number_style__[\"a\" /* default */])(element, 'marginTop', styles);\n var marginBottom = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_9__get_number_style__[\"a\" /* default */])(element, 'marginBottom', styles);\n width += marginLeft + marginRight;\n height += marginTop + marginBottom;\n }\n\n return {\n width: width,\n height: height\n };\n }\n\n /**\n * Change a property or execute a function which will not have a transition\n * @param {Array.} elements DOM elements that won't be transitioned.\n * @param {Function} callback A function which will be called while transition\n * is set to 0ms.\n * @private\n */\n\n }, {\n key: '_skipTransitions',\n value: function _skipTransitions(elements, callback) {\n var zero = '0ms';\n\n // Save current duration and delay.\n var data = elements.map(function (element) {\n var style = element.style;\n var duration = style.transitionDuration;\n var delay = style.transitionDelay;\n\n // Set the duration to zero so it happens immediately\n style.transitionDuration = zero;\n style.transitionDelay = zero;\n\n return {\n duration: duration,\n delay: delay\n };\n });\n\n callback();\n\n // Cause reflow.\n elements[0].offsetWidth; // jshint ignore:line\n\n // Put the duration back\n elements.forEach(function (element, i) {\n element.style.transitionDuration = data[i].duration;\n element.style.transitionDelay = data[i].delay;\n });\n }\n }]);\n\n return Shuffle;\n}();\n\nShuffle.ShuffleItem = __WEBPACK_IMPORTED_MODULE_7__shuffle_item__[\"a\" /* default */];\n\nShuffle.ALL_ITEMS = 'all';\nShuffle.FILTER_ATTRIBUTE_KEY = 'groups';\n\n/**\n * @enum {string}\n */\nShuffle.EventType = {\n LAYOUT: 'shuffle:layout',\n REMOVED: 'shuffle:removed'\n};\n\n/** @enum {string} */\nShuffle.Classes = __WEBPACK_IMPORTED_MODULE_8__classes__[\"a\" /* default */];\n\n// Overrideable options\nShuffle.options = {\n // Initial filter group.\n group: Shuffle.ALL_ITEMS,\n\n // Transition/animation speed (milliseconds).\n speed: 250,\n\n // CSS easing function to use.\n easing: 'ease',\n\n // e.g. '.picture-item'.\n itemSelector: '*',\n\n // Element or selector string. Use an element to determine the size of columns\n // and gutters.\n sizer: null,\n\n // A static number or function that tells the plugin how wide the gutters\n // between columns are (in pixels).\n gutterWidth: 0,\n\n // A static number or function that returns a number which tells the plugin\n // how wide the columns are (in pixels).\n columnWidth: 0,\n\n // If your group is not json, and is comma delimeted, you could set delimeter\n // to ','.\n delimeter: null,\n\n // Useful for percentage based heights when they might not always be exactly\n // the same (in pixels).\n buffer: 0,\n\n // Reading the width of elements isn't precise enough and can cause columns to\n // jump between values.\n columnThreshold: 0.01,\n\n // Shuffle can be isInitialized with a sort object. It is the same object\n // given to the sort method.\n initialSort: null,\n\n // By default, shuffle will throttle resize events. This can be changed or\n // removed.\n throttle: __WEBPACK_IMPORTED_MODULE_4_throttleit___default.a,\n\n // How often shuffle can be called on resize (in milliseconds).\n throttleTime: 300,\n\n // Transition delay offset for each item in milliseconds.\n staggerAmount: 15,\n\n // Maximum stagger delay in milliseconds.\n staggerAmountMax: 250,\n\n // Whether to use transforms or absolute positioning.\n useTransforms: true\n};\n\n// Expose for testing. Hack at your own risk.\nShuffle.__Point = __WEBPACK_IMPORTED_MODULE_6__point__[\"a\" /* default */];\nShuffle.__sorter = __WEBPACK_IMPORTED_MODULE_10__sorter__[\"a\" /* default */];\nShuffle.__getColumnSpan = __WEBPACK_IMPORTED_MODULE_12__layout__[\"b\" /* getColumnSpan */];\nShuffle.__getAvailablePositions = __WEBPACK_IMPORTED_MODULE_12__layout__[\"c\" /* getAvailablePositions */];\nShuffle.__getShortColumn = __WEBPACK_IMPORTED_MODULE_12__layout__[\"d\" /* getShortColumn */];\n\n/* harmony default export */ __webpack_exports__[\"default\"] = Shuffle;\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports) {\n\nmodule.exports = function parallel(fns, context, callback) {\n if (!callback) {\n if (typeof context === 'function') {\n callback = context\n context = null\n } else {\n callback = noop\n }\n }\n\n var pending = fns && fns.length\n if (!pending) return callback(null, []);\n\n var finished = false\n var results = new Array(pending)\n\n fns.forEach(context ? function (fn, i) {\n fn.call(context, maybeDone(i))\n } : function (fn, i) {\n fn(maybeDone(i))\n })\n\n function maybeDone(i) {\n return function (err, result) {\n if (finished) return;\n\n if (err) {\n callback(err, results)\n finished = true\n return\n }\n\n results[i] = result\n\n if (!--pending) callback(null, results);\n }\n }\n}\n\nfunction noop() {}\n\n\n/***/ }),\n/* 6 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n/* WEBPACK VAR INJECTION */(function(global) {\n\n// there's 3 implementations written in increasing order of efficiency\n\n// 1 - no Set type is defined\nfunction uniqNoSet(arr) {\n\tvar ret = [];\n\n\tfor (var i = 0; i < arr.length; i++) {\n\t\tif (ret.indexOf(arr[i]) === -1) {\n\t\t\tret.push(arr[i]);\n\t\t}\n\t}\n\n\treturn ret;\n}\n\n// 2 - a simple Set type is defined\nfunction uniqSet(arr) {\n\tvar seen = new Set();\n\treturn arr.filter(function (el) {\n\t\tif (!seen.has(el)) {\n\t\t\tseen.add(el);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t});\n}\n\n// 3 - a standard Set type is defined and it has a forEach method\nfunction uniqSetWithForEach(arr) {\n\tvar ret = [];\n\n\t(new Set(arr)).forEach(function (el) {\n\t\tret.push(el);\n\t});\n\n\treturn ret;\n}\n\n// V8 currently has a broken implementation\n// https://github.com/joyent/node/issues/8449\nfunction doesForEachActuallyWork() {\n\tvar ret = false;\n\n\t(new Set([true])).forEach(function (el) {\n\t\tret = el;\n\t});\n\n\treturn ret === true;\n}\n\nif ('Set' in global) {\n\tif (typeof Set.prototype.forEach === 'function' && doesForEachActuallyWork()) {\n\t\tmodule.exports = uniqSetWithForEach;\n\t} else {\n\t\tmodule.exports = uniqSet;\n\t}\n} else {\n\tmodule.exports = uniqNoSet;\n}\n\n/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(16)))\n\n/***/ }),\n/* 7 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n\nvar element = document.body || document.documentElement;\nvar e = document.createElement('div');\ne.style.cssText = 'width:10px;padding:2px;box-sizing:border-box;';\nelement.appendChild(e);\n\nvar width = window.getComputedStyle(e, null).width;\nvar ret = width === '10px';\n\nelement.removeChild(e);\n\n/* harmony default export */ __webpack_exports__[\"a\"] = ret;\n\n/***/ }),\n/* 8 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__get_number__ = __webpack_require__(2);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__computed_size__ = __webpack_require__(7);\n/* harmony export (immutable) */ __webpack_exports__[\"a\"] = getNumberStyle;\n\n\n\n\n\n/**\n * Retrieve the computed style for an element, parsed as a float.\n * @param {Element} element Element to get style for.\n * @param {string} style Style property.\n * @param {CSSStyleDeclaration} [styles] Optionally include clean styles to\n * use instead of asking for them again.\n * @return {number} The parsed computed value or zero if that fails because IE\n * will return 'auto' when the element doesn't have margins instead of\n * the computed style.\n */\nfunction getNumberStyle(element, style) {\n var styles = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : window.getComputedStyle(element, null);\n\n var value = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__get_number__[\"a\" /* default */])(styles[style]);\n\n // Support IE<=11 and W3C spec.\n if (!__WEBPACK_IMPORTED_MODULE_1__computed_size__[\"a\" /* default */] && style === 'width') {\n value += __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__get_number__[\"a\" /* default */])(styles.paddingLeft) + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__get_number__[\"a\" /* default */])(styles.paddingRight) + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__get_number__[\"a\" /* default */])(styles.borderLeftWidth) + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__get_number__[\"a\" /* default */])(styles.borderRightWidth);\n } else if (!__WEBPACK_IMPORTED_MODULE_1__computed_size__[\"a\" /* default */] && style === 'height') {\n value += __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__get_number__[\"a\" /* default */])(styles.paddingTop) + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__get_number__[\"a\" /* default */])(styles.paddingBottom) + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__get_number__[\"a\" /* default */])(styles.borderTopWidth) + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__get_number__[\"a\" /* default */])(styles.borderBottomWidth);\n }\n\n return value;\n}\n\n/***/ }),\n/* 9 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__point__ = __webpack_require__(0);\n/* harmony export (immutable) */ __webpack_exports__[\"a\"] = getItemPosition;\n/* harmony export (immutable) */ __webpack_exports__[\"b\"] = getColumnSpan;\n/* harmony export (immutable) */ __webpack_exports__[\"c\"] = getAvailablePositions;\n/* harmony export (immutable) */ __webpack_exports__[\"d\"] = getShortColumn;\n\n\n\n\nfunction arrayMax(array) {\n return Math.max.apply(Math, array);\n}\n\nfunction arrayMin(array) {\n return Math.min.apply(Math, array);\n}\n\n/**\n * Determine the location of the next item, based on its size.\n * @param {Object} itemSize Object with width and height.\n * @param {Array.} positions Positions of the other current items.\n * @param {number} gridSize The column width or row height.\n * @param {number} total The total number of columns or rows.\n * @param {number} threshold Buffer value for the column to fit.\n * @param {number} buffer Vertical buffer for the height of items.\n * @return {Point}\n */\nfunction getItemPosition(_ref) {\n var itemSize = _ref.itemSize,\n positions = _ref.positions,\n gridSize = _ref.gridSize,\n total = _ref.total,\n threshold = _ref.threshold,\n buffer = _ref.buffer;\n\n var span = getColumnSpan(itemSize.width, gridSize, total, threshold);\n var setY = getAvailablePositions(positions, span, total);\n var shortColumnIndex = getShortColumn(setY, buffer);\n\n // Position the item\n var point = new __WEBPACK_IMPORTED_MODULE_0__point__[\"a\" /* default */](Math.round(gridSize * shortColumnIndex), Math.round(setY[shortColumnIndex]));\n\n // Update the columns array with the new values for each column.\n // e.g. before the update the columns could be [250, 0, 0, 0] for an item\n // which spans 2 columns. After it would be [250, itemHeight, itemHeight, 0].\n var setHeight = setY[shortColumnIndex] + itemSize.height;\n for (var i = 0; i < span; i++) {\n positions[shortColumnIndex + i] = setHeight;\n }\n\n return point;\n}\n\n/**\n * Determine the number of columns an items spans.\n * @param {number} itemWidth Width of the item.\n * @param {number} columnWidth Width of the column (includes gutter).\n * @param {number} columns Total number of columns\n * @param {number} threshold A buffer value for the size of the column to fit.\n * @return {number}\n */\nfunction getColumnSpan(itemWidth, columnWidth, columns, threshold) {\n var columnSpan = itemWidth / columnWidth;\n\n // If the difference between the rounded column span number and the\n // calculated column span number is really small, round the number to\n // make it fit.\n if (Math.abs(Math.round(columnSpan) - columnSpan) < threshold) {\n // e.g. columnSpan = 4.0089945390298745\n columnSpan = Math.round(columnSpan);\n }\n\n // Ensure the column span is not more than the amount of columns in the whole layout.\n return Math.min(Math.ceil(columnSpan), columns);\n}\n\n/**\n * Retrieves the column set to use for placement.\n * @param {number} columnSpan The number of columns this current item spans.\n * @param {number} columns The total columns in the grid.\n * @return {Array.} An array of numbers represeting the column set.\n */\nfunction getAvailablePositions(positions, columnSpan, columns) {\n // The item spans only one column.\n if (columnSpan === 1) {\n return positions;\n }\n\n // The item spans more than one column, figure out how many different\n // places it could fit horizontally.\n // The group count is the number of places within the positions this block\n // could fit, ignoring the current positions of items.\n // Imagine a 2 column brick as the second item in a 4 column grid with\n // 10px height each. Find the places it would fit:\n // [20, 10, 10, 0]\n // | | |\n // * * *\n //\n // Then take the places which fit and get the bigger of the two:\n // max([20, 10]), max([10, 10]), max([10, 0]) = [20, 10, 0]\n //\n // Next, find the first smallest number (the short column).\n // [20, 10, 0]\n // |\n // *\n //\n // And that's where it should be placed!\n //\n // Another example where the second column's item extends past the first:\n // [10, 20, 10, 0] => [20, 20, 10] => 10\n var available = [];\n\n // For how many possible positions for this item there are.\n for (var i = 0; i <= columns - columnSpan; i++) {\n // Find the bigger value for each place it could fit.\n available.push(arrayMax(positions.slice(i, i + columnSpan)));\n }\n\n return available;\n}\n\n/**\n * Find index of short column, the first from the left where this item will go.\n *\n * @param {Array.} positions The array to search for the smallest number.\n * @param {number} buffer Optional buffer which is very useful when the height\n * is a percentage of the width.\n * @return {number} Index of the short column.\n */\nfunction getShortColumn(positions, buffer) {\n var minPosition = arrayMin(positions);\n for (var i = 0, len = positions.length; i < len; i++) {\n if (positions[i] >= minPosition - buffer && positions[i] <= minPosition + buffer) {\n return i;\n }\n }\n\n return 0;\n}\n\n/***/ }),\n/* 10 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n/* harmony export (immutable) */ __webpack_exports__[\"a\"] = onTransitionEnd;\n/* harmony export (immutable) */ __webpack_exports__[\"b\"] = cancelTransitionEnd;\n\n\nvar transitions = {};\nvar eventName = 'transitionend';\nvar count = 0;\n\nfunction uniqueId() {\n return eventName + count++;\n}\n\nfunction onTransitionEnd(element, callback) {\n var id = uniqueId();\n var listener = function listener(evt) {\n if (evt.currentTarget === evt.target) {\n cancelTransitionEnd(id);\n callback(evt);\n }\n };\n\n element.addEventListener(eventName, listener);\n\n transitions[id] = { element: element, listener: listener };\n\n return id;\n}\n\nfunction cancelTransitionEnd(id) {\n if (transitions[id]) {\n transitions[id].element.removeEventListener(eventName, transitions[id].listener);\n transitions[id] = null;\n return true;\n }\n\n return false;\n}\n\n/***/ }),\n/* 11 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__point__ = __webpack_require__(0);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__classes__ = __webpack_require__(1);\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n\n\n\nvar id = 0;\n\nvar ShuffleItem = function () {\n function ShuffleItem(element) {\n _classCallCheck(this, ShuffleItem);\n\n this.id = id++;\n this.element = element;\n this.isVisible = true;\n }\n\n _createClass(ShuffleItem, [{\n key: 'show',\n value: function show() {\n this.isVisible = true;\n this.element.classList.remove(__WEBPACK_IMPORTED_MODULE_1__classes__[\"a\" /* default */].HIDDEN);\n this.element.classList.add(__WEBPACK_IMPORTED_MODULE_1__classes__[\"a\" /* default */].VISIBLE);\n }\n }, {\n key: 'hide',\n value: function hide() {\n this.isVisible = false;\n this.element.classList.remove(__WEBPACK_IMPORTED_MODULE_1__classes__[\"a\" /* default */].VISIBLE);\n this.element.classList.add(__WEBPACK_IMPORTED_MODULE_1__classes__[\"a\" /* default */].HIDDEN);\n }\n }, {\n key: 'init',\n value: function init() {\n this.addClasses([__WEBPACK_IMPORTED_MODULE_1__classes__[\"a\" /* default */].SHUFFLE_ITEM, __WEBPACK_IMPORTED_MODULE_1__classes__[\"a\" /* default */].VISIBLE]);\n this.applyCss(ShuffleItem.Css.INITIAL);\n this.scale = ShuffleItem.Scale.VISIBLE;\n this.point = new __WEBPACK_IMPORTED_MODULE_0__point__[\"a\" /* default */]();\n }\n }, {\n key: 'addClasses',\n value: function addClasses(classes) {\n var _this = this;\n\n classes.forEach(function (className) {\n _this.element.classList.add(className);\n });\n }\n }, {\n key: 'removeClasses',\n value: function removeClasses(classes) {\n var _this2 = this;\n\n classes.forEach(function (className) {\n _this2.element.classList.remove(className);\n });\n }\n }, {\n key: 'applyCss',\n value: function applyCss(obj) {\n for (var key in obj) {\n this.element.style[key] = obj[key];\n }\n }\n }, {\n key: 'dispose',\n value: function dispose() {\n this.removeClasses([__WEBPACK_IMPORTED_MODULE_1__classes__[\"a\" /* default */].HIDDEN, __WEBPACK_IMPORTED_MODULE_1__classes__[\"a\" /* default */].VISIBLE, __WEBPACK_IMPORTED_MODULE_1__classes__[\"a\" /* default */].SHUFFLE_ITEM]);\n\n this.element.removeAttribute('style');\n this.element = null;\n }\n }]);\n\n return ShuffleItem;\n}();\n\nShuffleItem.Css = {\n INITIAL: {\n position: 'absolute',\n top: 0,\n left: 0,\n visibility: 'visible',\n 'will-change': 'transform'\n },\n VISIBLE: {\n before: {\n opacity: 1,\n visibility: 'visible'\n },\n after: {}\n },\n HIDDEN: {\n before: {\n opacity: 0\n },\n after: {\n visibility: 'hidden'\n }\n }\n};\n\nShuffleItem.Scale = {\n VISIBLE: 1,\n HIDDEN: 0.001\n};\n\n/* harmony default export */ __webpack_exports__[\"a\"] = ShuffleItem;\n\n/***/ }),\n/* 12 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_xtend__ = __webpack_require__(3);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_xtend___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_xtend__);\n/* harmony export (immutable) */ __webpack_exports__[\"a\"] = sorter;\n\n\n\n\n// http://stackoverflow.com/a/962890/373422\nfunction randomize(array) {\n var tmp;\n var current;\n var top = array.length;\n\n if (!top) {\n return array;\n }\n\n while (--top) {\n current = Math.floor(Math.random() * (top + 1));\n tmp = array[current];\n array[current] = array[top];\n array[top] = tmp;\n }\n\n return array;\n}\n\nvar defaults = {\n // Use array.reverse() to reverse the results\n reverse: false,\n\n // Sorting function\n by: null,\n\n // If true, this will skip the sorting and return a randomized order in the array\n randomize: false,\n\n // Determines which property of each item in the array is passed to the\n // sorting method.\n key: 'element'\n};\n\n// You can return `undefined` from the `by` function to revert to DOM order.\nfunction sorter(arr, options) {\n var opts = __WEBPACK_IMPORTED_MODULE_0_xtend___default()(defaults, options);\n var original = [].slice.call(arr);\n var revert = false;\n\n if (!arr.length) {\n return [];\n }\n\n if (opts.randomize) {\n return randomize(arr);\n }\n\n // Sort the elements by the opts.by function.\n // If we don't have opts.by, default to DOM order\n if (typeof opts.by === 'function') {\n arr.sort(function (a, b) {\n\n // Exit early if we already know we want to revert\n if (revert) {\n return 0;\n }\n\n var valA = opts.by(a[opts.key]);\n var valB = opts.by(b[opts.key]);\n\n // If both values are undefined, use the DOM order\n if (valA === undefined && valB === undefined) {\n revert = true;\n return 0;\n }\n\n if (valA < valB || valA === 'sortFirst' || valB === 'sortLast') {\n return -1;\n }\n\n if (valA > valB || valA === 'sortLast' || valB === 'sortFirst') {\n return 1;\n }\n\n return 0;\n });\n }\n\n // Revert to the original array if necessary\n if (revert) {\n return original;\n }\n\n if (opts.reverse) {\n arr.reverse();\n }\n\n return arr;\n}\n\n/***/ }),\n/* 13 */\n/***/ (function(module, exports) {\n\n// Polyfill for creating CustomEvents on IE9/10/11\n\n// code pulled from:\n// https://github.com/d4tocchini/customevent-polyfill\n// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent#Polyfill\n\ntry {\n var ce = new window.CustomEvent('test');\n ce.preventDefault();\n if (ce.defaultPrevented !== true) {\n // IE has problems with .preventDefault() on custom events\n // http://stackoverflow.com/questions/23349191\n throw new Error('Could not prevent default');\n }\n} catch(e) {\n var CustomEvent = function(event, params) {\n var evt, origPrevent;\n params = params || {\n bubbles: false,\n cancelable: false,\n detail: undefined\n };\n\n evt = document.createEvent(\"CustomEvent\");\n evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);\n origPrevent = evt.preventDefault;\n evt.preventDefault = function () {\n origPrevent.call(this);\n try {\n Object.defineProperty(this, 'defaultPrevented', {\n get: function () {\n return true;\n }\n });\n } catch(e) {\n this.defaultPrevented = true;\n }\n };\n return evt;\n };\n\n CustomEvent.prototype = window.Event.prototype;\n window.CustomEvent = CustomEvent; // expose definition to window\n}\n\n\n/***/ }),\n/* 14 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar proto = Element.prototype;\nvar vendor = proto.matches\n || proto.matchesSelector\n || proto.webkitMatchesSelector\n || proto.mozMatchesSelector\n || proto.msMatchesSelector\n || proto.oMatchesSelector;\n\nmodule.exports = match;\n\n/**\n * Match `el` to `selector`.\n *\n * @param {Element} el\n * @param {String} selector\n * @return {Boolean}\n * @api public\n */\n\nfunction match(el, selector) {\n if (vendor) return vendor.call(el, selector);\n var nodes = el.parentNode.querySelectorAll(selector);\n for (var i = 0; i < nodes.length; i++) {\n if (nodes[i] == el) return true;\n }\n return false;\n}\n\n/***/ }),\n/* 15 */\n/***/ (function(module, exports) {\n\nmodule.exports = throttle;\n\n/**\n * Returns a new function that, when invoked, invokes `func` at most once per `wait` milliseconds.\n *\n * @param {Function} func Function to wrap.\n * @param {Number} wait Number of milliseconds that must elapse between `func` invocations.\n * @return {Function} A new function that wraps the `func` function passed in.\n */\n\nfunction throttle (func, wait) {\n var ctx, args, rtn, timeoutID; // caching\n var last = 0;\n\n return function throttled () {\n ctx = this;\n args = arguments;\n var delta = new Date() - last;\n if (!timeoutID)\n if (delta >= wait) call();\n else timeoutID = setTimeout(call, wait - delta);\n return rtn;\n };\n\n function call () {\n timeoutID = 0;\n last = +new Date();\n rtn = func.apply(ctx, args);\n ctx = null;\n args = null;\n }\n}\n\n\n/***/ }),\n/* 16 */\n/***/ (function(module, exports) {\n\nvar g;\r\n\r\n// This works in non-strict mode\r\ng = (function() {\r\n\treturn this;\r\n})();\r\n\r\ntry {\r\n\t// This works if eval is allowed (see CSP)\r\n\tg = g || Function(\"return this\")() || (1,eval)(\"this\");\r\n} catch(e) {\r\n\t// This works if the window reference is available\r\n\tif(typeof window === \"object\")\r\n\t\tg = window;\r\n}\r\n\r\n// g can still be undefined, but nothing to do about it...\r\n// We return undefined, instead of nothing here, so it's\r\n// easier to handle this case. if(!global) { ...}\r\n\r\nmodule.exports = g;\r\n\n\n/***/ }),\n/* 17 */\n/***/ (function(module, exports, __webpack_require__) {\n\nmodule.exports = __webpack_require__(4).default;\n\n/***/ })\n/******/ ]);\n});\n\n\n// WEBPACK FOOTER //\n// shuffle.min.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 17);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 35a3cfe3322ce6f556df","'use strict';\n\nimport getNumber from './get-number';\n\n/**\n * Represents a coordinate pair.\n * @param {number} [x=0] X.\n * @param {number} [y=0] Y.\n */\nconst Point = function (x, y) {\n this.x = getNumber(x);\n this.y = getNumber(y);\n};\n\n/**\n * Whether two points are equal.\n * @param {Point} a Point A.\n * @param {Point} b Point B.\n * @return {boolean}\n */\nPoint.equals = function (a, b) {\n return a.x === b.x && a.y === b.y;\n};\n\nexport default Point;\n\n\n\n// WEBPACK FOOTER //\n// ./src/point.js","export default {\n BASE: 'shuffle',\n SHUFFLE_ITEM: 'shuffle-item',\n VISIBLE: 'shuffle-item--visible',\n HIDDEN: 'shuffle-item--hidden',\n};\n\n\n\n// WEBPACK FOOTER //\n// ./src/classes.js","'use strict';\n\n/**\n * Always returns a numeric value, given a value. Logic from jQuery's `isNumeric`.\n * @param {*} value Possibly numeric value.\n * @return {number} `value` or zero if `value` isn't numeric.\n */\nexport default function getNumber(value) {\n return parseFloat(value) || 0;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/get-number.js","module.exports = extend\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nfunction extend() {\n var target = {}\n\n for (var i = 0; i < arguments.length; i++) {\n var source = arguments[i]\n\n for (var key in source) {\n if (hasOwnProperty.call(source, key)) {\n target[key] = source[key]\n }\n }\n }\n\n return target\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/xtend/immutable.js\n// module id = 3\n// module chunks = 0","'use strict';\n\nimport 'custom-event-polyfill';\nimport matches from 'matches-selector';\nimport arrayUnique from 'array-uniq';\nimport xtend from 'xtend';\nimport throttle from 'throttleit';\nimport parallel from 'array-parallel';\nimport Point from './point';\nimport ShuffleItem from './shuffle-item';\nimport Classes from './classes';\nimport getNumberStyle from './get-number-style';\nimport sorter from './sorter';\nimport { onTransitionEnd, cancelTransitionEnd } from './on-transition-end';\nimport { getItemPosition, getColumnSpan, getAvailablePositions, getShortColumn } from './layout';\n\nfunction toArray(arrayLike) {\n return Array.prototype.slice.call(arrayLike);\n}\n\nfunction arrayMax(array) {\n return Math.max.apply(Math, array);\n}\n\nfunction arrayIncludes(array, obj) {\n if (arguments.length === 2) {\n return arrayIncludes(array)(obj);\n }\n\n return function (obj) {\n return array.indexOf(obj) > -1;\n };\n}\n\n// Used for unique instance variables\nlet id = 0;\n\nclass Shuffle {\n\n /**\n * Categorize, sort, and filter a responsive grid of items.\n *\n * @param {Element} element An element which is the parent container for the grid items.\n * @param {Object} [options=Shuffle.options] Options object.\n * @constructor\n */\n constructor(element, options = {}) {\n this.options = xtend(Shuffle.options, options);\n\n this.useSizer = false;\n this.lastSort = {};\n this.group = this.lastFilter = Shuffle.ALL_ITEMS;\n this.isEnabled = true;\n this.isDestroyed = false;\n this.isInitialized = false;\n this._transitions = [];\n this.isTransitioning = false;\n this._queue = [];\n\n element = this._getElementOption(element);\n\n if (!element) {\n throw new TypeError('Shuffle needs to be initialized with an element.');\n }\n\n this.element = element;\n this.id = 'shuffle_' + id++;\n\n this._init();\n this.isInitialized = true;\n }\n\n _init() {\n this.items = this._getItems();\n\n this.options.sizer = this._getElementOption(this.options.sizer);\n\n if (this.options.sizer) {\n this.useSizer = true;\n }\n\n // Add class and invalidate styles\n this.element.classList.add(Shuffle.Classes.BASE);\n\n // Set initial css for each item\n this._initItems();\n\n // Bind resize events\n this._onResize = this._getResizeFunction();\n window.addEventListener('resize', this._onResize);\n\n // Get container css all in one request. Causes reflow\n var containerCss = window.getComputedStyle(this.element, null);\n var containerWidth = Shuffle.getSize(this.element).width;\n\n // Add styles to the container if it doesn't have them.\n this._validateStyles(containerCss);\n\n // We already got the container's width above, no need to cause another\n // reflow getting it again... Calculate the number of columns there will be\n this._setColumns(containerWidth);\n\n // Kick off!\n this.filter(this.options.group, this.options.initialSort);\n\n // The shuffle items haven't had transitions set on them yet so the user\n // doesn't see the first layout. Set them now that the first layout is done.\n // First, however, a synchronous layout must be caused for the previous\n // styles to be applied without transitions.\n this.element.offsetWidth; // jshint ignore: line\n this._setTransitions();\n this.element.style.transition = 'height ' + this.options.speed + 'ms ' + this.options.easing;\n }\n\n /**\n * Returns a throttled and proxied function for the resize handler.\n * @return {Function}\n * @private\n */\n _getResizeFunction() {\n var resizeFunction = this._handleResize.bind(this);\n return this.options.throttle ?\n this.options.throttle(resizeFunction, this.options.throttleTime) :\n resizeFunction;\n }\n\n /**\n * Retrieve an element from an option.\n * @param {string|jQuery|Element} option The option to check.\n * @return {?Element} The plain element or null.\n * @private\n */\n _getElementOption(option) {\n // If column width is a string, treat is as a selector and search for the\n // sizer element within the outermost container\n if (typeof option === 'string') {\n return this.element.querySelector(option);\n\n // Check for an element\n } else if (option && option.nodeType && option.nodeType === 1) {\n return option;\n\n // Check for jQuery object\n } else if (option && option.jquery) {\n return option[0];\n }\n\n return null;\n }\n\n /**\n * Ensures the shuffle container has the css styles it needs applied to it.\n * @param {Object} styles Key value pairs for position and overflow.\n * @private\n */\n _validateStyles(styles) {\n // Position cannot be static.\n if (styles.position === 'static') {\n this.element.style.position = 'relative';\n }\n\n // Overflow has to be hidden.\n if (styles.overflow !== 'hidden') {\n this.element.style.overflow = 'hidden';\n }\n }\n\n /**\n * Filter the elements by a category.\n * @param {string} [category] Category to filter by. If it's given, the last\n * category will be used to filter the items.\n * @param {Array} [collection] Optionally filter a collection. Defaults to\n * all the items.\n * @return {!{visible: Array, hidden: Array}}\n * @private\n */\n _filter(category = this.lastFilter, collection = this.items) {\n var set = this._getFilteredSets(category, collection);\n\n // Individually add/remove hidden/visible classes\n this._toggleFilterClasses(set);\n\n // Save the last filter in case elements are appended.\n this.lastFilter = category;\n\n // This is saved mainly because providing a filter function (like searching)\n // will overwrite the `lastFilter` property every time its called.\n if (typeof category === 'string') {\n this.group = category;\n }\n\n return set;\n }\n\n /**\n * Returns an object containing the visible and hidden elements.\n * @param {string|Function} category Category or function to filter by.\n * @param {Array.} items A collection of items to filter.\n * @return {!{visible: Array, hidden: Array}}\n * @private\n */\n _getFilteredSets(category, items) {\n let visible = [];\n let hidden = [];\n\n // category === 'all', add visible class to everything\n if (category === Shuffle.ALL_ITEMS) {\n visible = items;\n\n // Loop through each item and use provided function to determine\n // whether to hide it or not.\n } else {\n items.forEach((item) => {\n if (this._doesPassFilter(category, item.element)) {\n visible.push(item);\n } else {\n hidden.push(item);\n }\n });\n }\n\n return {\n visible,\n hidden,\n };\n }\n\n /**\n * Test an item to see if it passes a category.\n * @param {string|Function} category Category or function to filter by.\n * @param {Element} element An element to test.\n * @return {boolean} Whether it passes the category/filter.\n * @private\n */\n _doesPassFilter(category, element) {\n\n if (typeof category === 'function') {\n return category.call(element, element, this);\n\n // Check each element's data-groups attribute against the given category.\n } else {\n let attr = element.getAttribute('data-' + Shuffle.FILTER_ATTRIBUTE_KEY);\n let keys = this.options.delimeter ?\n attr.split(this.options.delimeter) :\n JSON.parse(attr);\n\n if (Array.isArray(category)) {\n return category.some(arrayIncludes(keys));\n }\n\n return arrayIncludes(keys, category);\n }\n }\n\n /**\n * Toggles the visible and hidden class names.\n * @param {{visible, hidden}} Object with visible and hidden arrays.\n * @private\n */\n _toggleFilterClasses({ visible, hidden }) {\n visible.forEach((item) => {\n item.show();\n });\n\n hidden.forEach((item) => {\n item.hide();\n });\n }\n\n /**\n * Set the initial css for each item\n * @param {Array.} [items] Optionally specifiy at set to initialize.\n * @private\n */\n _initItems(items = this.items) {\n items.forEach((item) => {\n item.init();\n });\n }\n\n /**\n * Remove element reference and styles.\n * @private\n */\n _disposeItems(items = this.items) {\n items.forEach((item) => {\n item.dispose();\n });\n }\n\n /**\n * Updates the visible item count.\n * @private\n */\n _updateItemCount() {\n this.visibleItems = this._getFilteredItems().length;\n }\n\n /**\n * Sets css transform transition on a group of elements. This is not executed\n * at the same time as `item.init` so that transitions don't occur upon\n * initialization of Shuffle.\n * @param {Array.} items Shuffle items to set transitions on.\n * @private\n */\n _setTransitions(items = this.items) {\n let speed = this.options.speed;\n let easing = this.options.easing;\n\n var str;\n if (this.options.useTransforms) {\n str = 'transform ' + speed + 'ms ' + easing +\n ', opacity ' + speed + 'ms ' + easing;\n } else {\n str = 'top ' + speed + 'ms ' + easing +\n ', left ' + speed + 'ms ' + easing +\n ', opacity ' + speed + 'ms ' + easing;\n }\n\n items.forEach((item) => {\n item.element.style.transition = str;\n });\n }\n\n _getItems() {\n return toArray(this.element.children)\n .filter(el => matches(el, this.options.itemSelector))\n .map(el => new ShuffleItem(el));\n }\n\n /**\n * When new elements are added to the shuffle container, update the array of\n * items because that is the order `_layout` calls them.\n */\n _updateItemsOrder() {\n let children = this.element.children;\n this.items = sorter(this.items, {\n by(element) {\n return Array.prototype.indexOf.call(children, element);\n },\n });\n }\n\n _getFilteredItems() {\n return this.items.filter(item => item.isVisible);\n }\n\n _getConcealedItems() {\n return this.items.filter(item => !item.isVisible);\n }\n\n /**\n * Returns the column size, based on column width and sizer options.\n * @param {number} containerWidth Size of the parent container.\n * @param {number} gutterSize Size of the gutters.\n * @return {number}\n * @private\n */\n _getColumnSize(containerWidth, gutterSize) {\n var size;\n\n // If the columnWidth property is a function, then the grid is fluid\n if (typeof this.options.columnWidth === 'function') {\n size = this.options.columnWidth(containerWidth);\n\n // columnWidth option isn't a function, are they using a sizing element?\n } else if (this.useSizer) {\n size = Shuffle.getSize(this.options.sizer).width;\n\n // if not, how about the explicitly set option?\n } else if (this.options.columnWidth) {\n size = this.options.columnWidth;\n\n // or use the size of the first item\n } else if (this.items.length > 0) {\n size = Shuffle.getSize(this.items[0].element, true).width;\n\n // if there's no items, use size of container\n } else {\n size = containerWidth;\n }\n\n // Don't let them set a column width of zero.\n if (size === 0) {\n size = containerWidth;\n }\n\n return size + gutterSize;\n }\n\n /**\n * Returns the gutter size, based on gutter width and sizer options.\n * @param {number} containerWidth Size of the parent container.\n * @return {number}\n * @private\n */\n _getGutterSize(containerWidth) {\n var size;\n if (typeof this.options.gutterWidth === 'function') {\n size = this.options.gutterWidth(containerWidth);\n } else if (this.useSizer) {\n size = getNumberStyle(this.options.sizer, 'marginLeft');\n } else {\n size = this.options.gutterWidth;\n }\n\n return size;\n }\n\n /**\n * Calculate the number of columns to be used. Gets css if using sizer element.\n * @param {number} [containerWidth] Optionally specify a container width if\n * it's already available.\n */\n _setColumns(containerWidth = Shuffle.getSize(this.element).width) {\n var gutter = this._getGutterSize(containerWidth);\n var columnWidth = this._getColumnSize(containerWidth, gutter);\n var calculatedColumns = (containerWidth + gutter) / columnWidth;\n\n // Widths given from getStyles are not precise enough...\n if (Math.abs(Math.round(calculatedColumns) - calculatedColumns) <\n this.options.columnThreshold) {\n // e.g. calculatedColumns = 11.998876\n calculatedColumns = Math.round(calculatedColumns);\n }\n\n this.cols = Math.max(Math.floor(calculatedColumns), 1);\n this.containerWidth = containerWidth;\n this.colWidth = columnWidth;\n }\n\n /**\n * Adjust the height of the grid\n */\n _setContainerSize() {\n this.element.style.height = this._getContainerSize() + 'px';\n }\n\n /**\n * Based on the column heights, it returns the biggest one.\n * @return {number}\n * @private\n */\n _getContainerSize() {\n return arrayMax(this.positions);\n }\n\n /**\n * Get the clamped stagger amount.\n * @param {number} index Index of the item to be staggered.\n * @return {number}\n */\n _getStaggerAmount(index) {\n return Math.min(index * this.options.staggerAmount, this.options.staggerAmountMax);\n }\n\n /**\n * @return {boolean} Whether the event was prevented or not.\n */\n _dispatch(name, details = {}) {\n if (this.isDestroyed) {\n return;\n }\n\n details.shuffle = this;\n return !this.element.dispatchEvent(new CustomEvent(name, {\n bubbles: true,\n cancelable: false,\n detail: details,\n }));\n }\n\n /**\n * Zeros out the y columns array, which is used to determine item placement.\n * @private\n */\n _resetCols() {\n var i = this.cols;\n this.positions = [];\n while (i--) {\n this.positions.push(0);\n }\n }\n\n /**\n * Loops through each item that should be shown and calculates the x, y position.\n * @param {Array.} items Array of items that will be shown/layed\n * out in order in their array.\n */\n _layout(items) {\n let count = 0;\n items.forEach((item) => {\n var currPos = item.point;\n var currScale = item.scale;\n var itemSize = Shuffle.getSize(item.element, true);\n var pos = this._getItemPosition(itemSize);\n\n function callback() {\n item.element.style.transitionDelay = '';\n item.applyCss(ShuffleItem.Css.VISIBLE.after);\n }\n\n // If the item will not change its position, do not add it to the render\n // queue. Transitions don't fire when setting a property to the same value.\n if (Point.equals(currPos, pos) && currScale === ShuffleItem.Scale.VISIBLE) {\n item.applyCss(ShuffleItem.Css.VISIBLE.before);\n callback();\n return;\n }\n\n item.point = pos;\n item.scale = ShuffleItem.Scale.VISIBLE;\n\n // Use xtend here to clone the object so that the `before` object isn't\n // modified when the transition delay is added.\n let styles = xtend(ShuffleItem.Css.VISIBLE.before);\n styles.transitionDelay = this._getStaggerAmount(count) + 'ms';\n\n this._queue.push({\n item,\n styles,\n callback,\n });\n\n count++;\n });\n }\n\n /**\n * Determine the location of the next item, based on its size.\n * @param {{width: number, height: number}} itemSize Object with width and height.\n * @return {Point}\n * @private\n */\n _getItemPosition(itemSize) {\n return getItemPosition({\n itemSize,\n positions: this.positions,\n gridSize: this.colWidth,\n total: this.cols,\n threshold: this.options.columnThreshold,\n buffer: this.options.buffer,\n });\n }\n\n /**\n * Hides the elements that don't match our filter.\n * @param {Array.} collection Collection to shrink.\n * @private\n */\n _shrink(collection = this._getConcealedItems()) {\n let count = 0;\n collection.forEach((item) => {\n function callback() {\n item.applyCss(ShuffleItem.Css.HIDDEN.after);\n }\n\n // Continuing would add a transitionend event listener to the element, but\n // that listener would not execute because the transform and opacity would\n // stay the same.\n // The callback is executed here because it is not guaranteed to be called\n // after the transitionend event because the transitionend could be\n // canceled if another animation starts.\n if (item.scale === ShuffleItem.Scale.HIDDEN) {\n item.applyCss(ShuffleItem.Css.HIDDEN.before);\n callback();\n return;\n }\n\n item.scale = ShuffleItem.Scale.HIDDEN;\n\n let styles = xtend(ShuffleItem.Css.HIDDEN.before);\n styles.transitionDelay = this._getStaggerAmount(count) + 'ms';\n\n this._queue.push({\n item,\n styles,\n callback,\n });\n\n count++;\n });\n }\n\n /**\n * Resize handler.\n * @private\n */\n _handleResize() {\n // If shuffle is disabled, destroyed, don't do anything\n if (!this.isEnabled || this.isDestroyed) {\n return;\n }\n\n // Will need to check height in the future if it's layed out horizontaly\n var containerWidth = Shuffle.getSize(this.element).width;\n\n // containerWidth hasn't changed, don't do anything\n if (containerWidth === this.containerWidth) {\n return;\n }\n\n this.update();\n }\n\n /**\n * Returns styles which will be applied to the an item for a transition.\n * @param {Object} obj Transition options.\n * @return {!Object} Transforms for transitions, left/top for animate.\n * @private\n */\n _getStylesForTransition({ item, styles }) {\n if (!styles.transitionDelay) {\n styles.transitionDelay = '0ms';\n }\n\n let x = item.point.x;\n let y = item.point.y;\n\n if (this.options.useTransforms) {\n styles.transform = `translate(${x}px, ${y}px) scale(${item.scale})`;\n } else {\n styles.left = x + 'px';\n styles.top = y + 'px';\n }\n\n return styles;\n }\n\n /**\n * Listen for the transition end on an element and execute the itemCallback\n * when it finishes.\n * @param {Element} element Element to listen on.\n * @param {Function} itemCallback Callback for the item.\n * @param {Function} done Callback to notify `parallel` that this one is done.\n */\n _whenTransitionDone(element, itemCallback, done) {\n let id = onTransitionEnd(element, (evt) => {\n itemCallback();\n done(null, evt);\n });\n\n this._transitions.push(id);\n }\n\n /**\n * Return a function which will set CSS styles and call the `done` function\n * when (if) the transition finishes.\n * @param {Object} opts Transition object.\n * @return {Function} A function to be called with a `done` function.\n */\n _getTransitionFunction(opts) {\n return (done) => {\n opts.item.applyCss(this._getStylesForTransition(opts));\n this._whenTransitionDone(opts.item.element, opts.callback, done);\n };\n }\n\n /**\n * Execute the styles gathered in the style queue. This applies styles to elements,\n * triggering transitions.\n * @private\n */\n _processQueue() {\n if (this.isTransitioning) {\n this._cancelMovement();\n }\n\n let hasSpeed = this.options.speed > 0;\n let hasQueue = this._queue.length > 0;\n\n if (hasQueue && hasSpeed && this.isInitialized) {\n this._startTransitions(this._queue);\n\n } else if (hasQueue) {\n this._styleImmediately(this._queue);\n this._dispatchLayout();\n\n // A call to layout happened, but none of the newly visible items will\n // change position or the transition duration is zero, which will not trigger\n // the transitionend event.\n } else {\n this._dispatchLayout();\n }\n\n // Remove everything in the style queue\n this._queue.length = 0;\n }\n\n /**\n * Wait for each transition to finish, the emit the layout event.\n * @param {Array.} transitions Array of transition objects.\n */\n _startTransitions(transitions) {\n // Set flag that shuffle is currently in motion.\n this.isTransitioning = true;\n\n // Create an array of functions to be called.\n let callbacks = transitions.map(obj => this._getTransitionFunction(obj));\n\n parallel(callbacks, this._movementFinished.bind(this));\n }\n\n _cancelMovement() {\n // Remove the transition end event for each listener.\n this._transitions.forEach(cancelTransitionEnd);\n\n // Reset the array.\n this._transitions.length = 0;\n\n // Show it's no longer active.\n this.isTransitioning = false;\n }\n\n /**\n * Apply styles without a transition.\n * @param {Array.} objects Array of transition objects.\n * @private\n */\n _styleImmediately(objects) {\n if (objects.length) {\n let elements = objects.map(obj => obj.item.element);\n\n Shuffle._skipTransitions(elements, () => {\n objects.forEach((obj) => {\n obj.item.applyCss(this._getStylesForTransition(obj));\n obj.callback();\n });\n });\n }\n }\n\n _movementFinished() {\n this._transitions.length = 0;\n this.isTransitioning = false;\n this._dispatchLayout();\n }\n\n _dispatchLayout() {\n this._dispatch(Shuffle.EventType.LAYOUT);\n }\n\n /**\n * The magic. This is what makes the plugin 'shuffle'\n * @param {string|Function|Array.} [category] Category to filter by.\n * Can be a function, string, or array of strings.\n * @param {Object} [sortObj] A sort object which can sort the visible set\n */\n filter(category, sortObj) {\n if (!this.isEnabled) {\n return;\n }\n\n if (!category || (category && category.length === 0)) {\n category = Shuffle.ALL_ITEMS;\n }\n\n this._filter(category);\n\n // Shrink each hidden item\n this._shrink();\n\n // How many visible elements?\n this._updateItemCount();\n\n // Update transforms on visible elements so they will animate to their new positions.\n this.sort(sortObj);\n }\n\n /**\n * Gets the visible elements, sorts them, and passes them to layout.\n * @param {Object} opts the options object for the sorted plugin\n */\n sort(opts = this.lastSort) {\n if (!this.isEnabled) {\n return;\n }\n\n this._resetCols();\n\n var items = this._getFilteredItems();\n items = sorter(items, opts);\n\n this._layout(items);\n\n // `_layout` always happens after `_shrink`, so it's safe to process the style\n // queue here with styles from the shrink method.\n this._processQueue();\n\n // Adjust the height of the container.\n this._setContainerSize();\n\n this.lastSort = opts;\n }\n\n /**\n * Reposition everything.\n * @param {boolean} isOnlyLayout If true, column and gutter widths won't be\n * recalculated.\n */\n update(isOnlyLayout) {\n if (this.isEnabled) {\n\n if (!isOnlyLayout) {\n // Get updated colCount\n this._setColumns();\n }\n\n // Layout items\n this.sort();\n }\n }\n\n /**\n * Use this instead of `update()` if you don't need the columns and gutters updated\n * Maybe an image inside `shuffle` loaded (and now has a height), which means calculations\n * could be off.\n */\n layout() {\n this.update(true);\n }\n\n /**\n * New items have been appended to shuffle. Mix them in with the current\n * filter or sort status.\n * @param {Array.} newItems Collection of new items.\n */\n add(newItems) {\n newItems = arrayUnique(newItems).map(el => new ShuffleItem(el));\n\n // Add classes and set initial positions.\n this._initItems(newItems);\n\n // Add transition to each item.\n this._setTransitions(newItems);\n\n // Update the list of items.\n this.items = this.items.concat(newItems);\n this._updateItemsOrder();\n this.filter(this.lastFilter);\n }\n\n /**\n * Disables shuffle from updating dimensions and layout on resize\n */\n disable() {\n this.isEnabled = false;\n }\n\n /**\n * Enables shuffle again\n * @param {boolean} [isUpdateLayout=true] if undefined, shuffle will update columns and gutters\n */\n enable(isUpdateLayout) {\n this.isEnabled = true;\n if (isUpdateLayout !== false) {\n this.update();\n }\n }\n\n /**\n * Remove 1 or more shuffle items\n * @param {Array.} collection An array containing one or more\n * elements in shuffle\n * @return {Shuffle} The shuffle object\n */\n remove(collection) {\n if (!collection.length) {\n return;\n }\n\n collection = arrayUnique(collection);\n\n let oldItems = collection\n .map(element => this.getItemByElement(element))\n .filter(item => !!item);\n\n let handleLayout = () => {\n this.element.removeEventListener(Shuffle.EventType.LAYOUT, handleLayout);\n this._disposeItems(oldItems);\n\n // Remove the collection in the callback\n collection.forEach((element) => {\n element.parentNode.removeChild(element);\n });\n\n this._dispatch(Shuffle.EventType.REMOVED, { collection });\n\n // Let it get garbage collected\n collection = null;\n oldItems = null;\n };\n\n // Hide collection first.\n this._toggleFilterClasses({\n visible: [],\n hidden: oldItems,\n });\n\n this._shrink(oldItems);\n\n this.sort();\n\n // Update the list of items here because `remove` could be called again\n // with an item that is in the process of being removed.\n this.items = this.items.filter(item => !arrayIncludes(oldItems, item));\n this._updateItemCount();\n\n this.element.addEventListener(Shuffle.EventType.LAYOUT, handleLayout);\n }\n\n /**\n * Retrieve a shuffle item by its element.\n * @param {Element} element Element to look for.\n * @return {?ShuffleItem} A shuffle item or null if it's not found.\n */\n getItemByElement(element) {\n for (var i = this.items.length - 1; i >= 0; i--) {\n if (this.items[i].element === element) {\n return this.items[i];\n }\n }\n\n return null;\n }\n\n /**\n * Destroys shuffle, removes events, styles, and classes\n */\n destroy() {\n this._cancelMovement();\n window.removeEventListener('resize', this._onResize);\n\n // Reset container styles\n this.element.classList.remove('shuffle');\n this.element.removeAttribute('style');\n\n // Reset individual item styles\n this._disposeItems();\n\n // Null DOM references\n this.items = null;\n this.options.sizer = null;\n this.element = null;\n this._transitions = null;\n\n // Set a flag so if a debounced resize has been triggered,\n // it can first check if it is actually isDestroyed and not doing anything\n this.isDestroyed = true;\n }\n\n /**\n * Returns the outer width of an element, optionally including its margins.\n *\n * There are a few different methods for getting the width of an element, none of\n * which work perfectly for all Shuffle's use cases.\n *\n * 1. getBoundingClientRect() `left` and `right` properties.\n * - Accounts for transform scaled elements, making it useless for Shuffle\n * elements which have shrunk.\n * 2. The `offsetWidth` property.\n * - This value stays the same regardless of the elements transform property,\n * however, it does not return subpixel values.\n * 3. getComputedStyle()\n * - This works great Chrome, Firefox, Safari, but IE<=11 does not include\n * padding and border when box-sizing: border-box is set, requiring a feature\n * test and extra work to add the padding back for IE and other browsers which\n * follow the W3C spec here.\n *\n * @param {Element} element The element.\n * @param {boolean} [includeMargins] Whether to include margins. Default is false.\n * @return {{width: number, height: number}} The width and height.\n */\n static getSize(element, includeMargins) {\n // Store the styles so that they can be used by others without asking for it again.\n var styles = window.getComputedStyle(element, null);\n var width = getNumberStyle(element, 'width', styles);\n var height = getNumberStyle(element, 'height', styles);\n\n if (includeMargins) {\n var marginLeft = getNumberStyle(element, 'marginLeft', styles);\n var marginRight = getNumberStyle(element, 'marginRight', styles);\n var marginTop = getNumberStyle(element, 'marginTop', styles);\n var marginBottom = getNumberStyle(element, 'marginBottom', styles);\n width += marginLeft + marginRight;\n height += marginTop + marginBottom;\n }\n\n return {\n width,\n height,\n };\n }\n\n /**\n * Change a property or execute a function which will not have a transition\n * @param {Array.} elements DOM elements that won't be transitioned.\n * @param {Function} callback A function which will be called while transition\n * is set to 0ms.\n * @private\n */\n static _skipTransitions(elements, callback) {\n let zero = '0ms';\n\n // Save current duration and delay.\n let data = elements.map((element) => {\n let style = element.style;\n let duration = style.transitionDuration;\n let delay = style.transitionDelay;\n\n // Set the duration to zero so it happens immediately\n style.transitionDuration = zero;\n style.transitionDelay = zero;\n\n return {\n duration,\n delay,\n };\n });\n\n callback();\n\n // Cause reflow.\n elements[0].offsetWidth; // jshint ignore:line\n\n // Put the duration back\n elements.forEach((element, i) => {\n element.style.transitionDuration = data[i].duration;\n element.style.transitionDelay = data[i].delay;\n });\n }\n}\n\nShuffle.ShuffleItem = ShuffleItem;\n\nShuffle.ALL_ITEMS = 'all';\nShuffle.FILTER_ATTRIBUTE_KEY = 'groups';\n\n/**\n * @enum {string}\n */\nShuffle.EventType = {\n LAYOUT: 'shuffle:layout',\n REMOVED: 'shuffle:removed',\n};\n\n/** @enum {string} */\nShuffle.Classes = Classes;\n\n// Overrideable options\nShuffle.options = {\n // Initial filter group.\n group: Shuffle.ALL_ITEMS,\n\n // Transition/animation speed (milliseconds).\n speed: 250,\n\n // CSS easing function to use.\n easing: 'ease',\n\n // e.g. '.picture-item'.\n itemSelector: '*',\n\n // Element or selector string. Use an element to determine the size of columns\n // and gutters.\n sizer: null,\n\n // A static number or function that tells the plugin how wide the gutters\n // between columns are (in pixels).\n gutterWidth: 0,\n\n // A static number or function that returns a number which tells the plugin\n // how wide the columns are (in pixels).\n columnWidth: 0,\n\n // If your group is not json, and is comma delimeted, you could set delimeter\n // to ','.\n delimeter: null,\n\n // Useful for percentage based heights when they might not always be exactly\n // the same (in pixels).\n buffer: 0,\n\n // Reading the width of elements isn't precise enough and can cause columns to\n // jump between values.\n columnThreshold: 0.01,\n\n // Shuffle can be isInitialized with a sort object. It is the same object\n // given to the sort method.\n initialSort: null,\n\n // By default, shuffle will throttle resize events. This can be changed or\n // removed.\n throttle: throttle,\n\n // How often shuffle can be called on resize (in milliseconds).\n throttleTime: 300,\n\n // Transition delay offset for each item in milliseconds.\n staggerAmount: 15,\n\n // Maximum stagger delay in milliseconds.\n staggerAmountMax: 250,\n\n // Whether to use transforms or absolute positioning.\n useTransforms: true,\n};\n\n// Expose for testing. Hack at your own risk.\nShuffle.__Point = Point;\nShuffle.__sorter = sorter;\nShuffle.__getColumnSpan = getColumnSpan;\nShuffle.__getAvailablePositions = getAvailablePositions;\nShuffle.__getShortColumn = getShortColumn;\n\nexport default Shuffle;\n\n\n\n// WEBPACK FOOTER //\n// ./src/shuffle.js","module.exports = function parallel(fns, context, callback) {\n if (!callback) {\n if (typeof context === 'function') {\n callback = context\n context = null\n } else {\n callback = noop\n }\n }\n\n var pending = fns && fns.length\n if (!pending) return callback(null, []);\n\n var finished = false\n var results = new Array(pending)\n\n fns.forEach(context ? function (fn, i) {\n fn.call(context, maybeDone(i))\n } : function (fn, i) {\n fn(maybeDone(i))\n })\n\n function maybeDone(i) {\n return function (err, result) {\n if (finished) return;\n\n if (err) {\n callback(err, results)\n finished = true\n return\n }\n\n results[i] = result\n\n if (!--pending) callback(null, results);\n }\n }\n}\n\nfunction noop() {}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/array-parallel/index.js\n// module id = 5\n// module chunks = 0","'use strict';\n\n// there's 3 implementations written in increasing order of efficiency\n\n// 1 - no Set type is defined\nfunction uniqNoSet(arr) {\n\tvar ret = [];\n\n\tfor (var i = 0; i < arr.length; i++) {\n\t\tif (ret.indexOf(arr[i]) === -1) {\n\t\t\tret.push(arr[i]);\n\t\t}\n\t}\n\n\treturn ret;\n}\n\n// 2 - a simple Set type is defined\nfunction uniqSet(arr) {\n\tvar seen = new Set();\n\treturn arr.filter(function (el) {\n\t\tif (!seen.has(el)) {\n\t\t\tseen.add(el);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t});\n}\n\n// 3 - a standard Set type is defined and it has a forEach method\nfunction uniqSetWithForEach(arr) {\n\tvar ret = [];\n\n\t(new Set(arr)).forEach(function (el) {\n\t\tret.push(el);\n\t});\n\n\treturn ret;\n}\n\n// V8 currently has a broken implementation\n// https://github.com/joyent/node/issues/8449\nfunction doesForEachActuallyWork() {\n\tvar ret = false;\n\n\t(new Set([true])).forEach(function (el) {\n\t\tret = el;\n\t});\n\n\treturn ret === true;\n}\n\nif ('Set' in global) {\n\tif (typeof Set.prototype.forEach === 'function' && doesForEachActuallyWork()) {\n\t\tmodule.exports = uniqSetWithForEach;\n\t} else {\n\t\tmodule.exports = uniqSet;\n\t}\n} else {\n\tmodule.exports = uniqNoSet;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/array-uniq/index.js\n// module id = 6\n// module chunks = 0","\nlet element = document.body || document.documentElement;\nlet e = document.createElement('div');\ne.style.cssText = 'width:10px;padding:2px;box-sizing:border-box;';\nelement.appendChild(e);\n\nlet width = window.getComputedStyle(e, null).width;\nlet ret = width === '10px';\n\nelement.removeChild(e);\n\nexport default ret;\n\n\n\n// WEBPACK FOOTER //\n// ./src/computed-size.js","'use strict';\n\nimport getNumber from './get-number';\nimport COMPUTED_SIZE_INCLUDES_PADDING from './computed-size';\n\n/**\n * Retrieve the computed style for an element, parsed as a float.\n * @param {Element} element Element to get style for.\n * @param {string} style Style property.\n * @param {CSSStyleDeclaration} [styles] Optionally include clean styles to\n * use instead of asking for them again.\n * @return {number} The parsed computed value or zero if that fails because IE\n * will return 'auto' when the element doesn't have margins instead of\n * the computed style.\n */\nexport default function getNumberStyle(element, style,\n styles = window.getComputedStyle(element, null)) {\n var value = getNumber(styles[style]);\n\n // Support IE<=11 and W3C spec.\n if (!COMPUTED_SIZE_INCLUDES_PADDING && style === 'width') {\n value += getNumber(styles.paddingLeft) +\n getNumber(styles.paddingRight) +\n getNumber(styles.borderLeftWidth) +\n getNumber(styles.borderRightWidth);\n } else if (!COMPUTED_SIZE_INCLUDES_PADDING && style === 'height') {\n value += getNumber(styles.paddingTop) +\n getNumber(styles.paddingBottom) +\n getNumber(styles.borderTopWidth) +\n getNumber(styles.borderBottomWidth);\n }\n\n return value;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/get-number-style.js","'use strict';\n\nimport Point from './point';\n\nfunction arrayMax(array) {\n return Math.max.apply(Math, array);\n}\n\nfunction arrayMin(array) {\n return Math.min.apply(Math, array);\n}\n\n/**\n * Determine the location of the next item, based on its size.\n * @param {Object} itemSize Object with width and height.\n * @param {Array.} positions Positions of the other current items.\n * @param {number} gridSize The column width or row height.\n * @param {number} total The total number of columns or rows.\n * @param {number} threshold Buffer value for the column to fit.\n * @param {number} buffer Vertical buffer for the height of items.\n * @return {Point}\n */\nexport function getItemPosition({ itemSize, positions, gridSize, total, threshold, buffer }) {\n var span = getColumnSpan(itemSize.width, gridSize, total, threshold);\n var setY = getAvailablePositions(positions, span, total);\n var shortColumnIndex = getShortColumn(setY, buffer);\n\n // Position the item\n var point = new Point(\n Math.round(gridSize * shortColumnIndex),\n Math.round(setY[shortColumnIndex]));\n\n // Update the columns array with the new values for each column.\n // e.g. before the update the columns could be [250, 0, 0, 0] for an item\n // which spans 2 columns. After it would be [250, itemHeight, itemHeight, 0].\n var setHeight = setY[shortColumnIndex] + itemSize.height;\n for (var i = 0; i < span; i++) {\n positions[shortColumnIndex + i] = setHeight;\n }\n\n return point;\n}\n\n/**\n * Determine the number of columns an items spans.\n * @param {number} itemWidth Width of the item.\n * @param {number} columnWidth Width of the column (includes gutter).\n * @param {number} columns Total number of columns\n * @param {number} threshold A buffer value for the size of the column to fit.\n * @return {number}\n */\nexport function getColumnSpan(itemWidth, columnWidth, columns, threshold) {\n var columnSpan = itemWidth / columnWidth;\n\n // If the difference between the rounded column span number and the\n // calculated column span number is really small, round the number to\n // make it fit.\n if (Math.abs(Math.round(columnSpan) - columnSpan) < threshold) {\n // e.g. columnSpan = 4.0089945390298745\n columnSpan = Math.round(columnSpan);\n }\n\n // Ensure the column span is not more than the amount of columns in the whole layout.\n return Math.min(Math.ceil(columnSpan), columns);\n}\n\n/**\n * Retrieves the column set to use for placement.\n * @param {number} columnSpan The number of columns this current item spans.\n * @param {number} columns The total columns in the grid.\n * @return {Array.} An array of numbers represeting the column set.\n */\nexport function getAvailablePositions(positions, columnSpan, columns) {\n // The item spans only one column.\n if (columnSpan === 1) {\n return positions;\n }\n\n // The item spans more than one column, figure out how many different\n // places it could fit horizontally.\n // The group count is the number of places within the positions this block\n // could fit, ignoring the current positions of items.\n // Imagine a 2 column brick as the second item in a 4 column grid with\n // 10px height each. Find the places it would fit:\n // [20, 10, 10, 0]\n // | | |\n // * * *\n //\n // Then take the places which fit and get the bigger of the two:\n // max([20, 10]), max([10, 10]), max([10, 0]) = [20, 10, 0]\n //\n // Next, find the first smallest number (the short column).\n // [20, 10, 0]\n // |\n // *\n //\n // And that's where it should be placed!\n //\n // Another example where the second column's item extends past the first:\n // [10, 20, 10, 0] => [20, 20, 10] => 10\n var available = [];\n\n // For how many possible positions for this item there are.\n for (var i = 0; i <= columns - columnSpan; i++) {\n // Find the bigger value for each place it could fit.\n available.push(arrayMax(positions.slice(i, i + columnSpan)));\n }\n\n return available;\n}\n\n/**\n * Find index of short column, the first from the left where this item will go.\n *\n * @param {Array.} positions The array to search for the smallest number.\n * @param {number} buffer Optional buffer which is very useful when the height\n * is a percentage of the width.\n * @return {number} Index of the short column.\n */\nexport function getShortColumn(positions, buffer) {\n var minPosition = arrayMin(positions);\n for (var i = 0, len = positions.length; i < len; i++) {\n if (positions[i] >= minPosition - buffer && positions[i] <= minPosition + buffer) {\n return i;\n }\n }\n\n return 0;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/layout.js","'use strict';\n\nlet transitions = {};\nlet eventName = 'transitionend';\nlet count = 0;\n\nfunction uniqueId() {\n return eventName + count++;\n}\n\nexport function onTransitionEnd(element, callback) {\n let id = uniqueId();\n let listener = (evt) => {\n if (evt.currentTarget === evt.target) {\n cancelTransitionEnd(id);\n callback(evt);\n }\n };\n\n element.addEventListener(eventName, listener);\n\n transitions[id] = { element, listener };\n\n return id;\n}\n\nexport function cancelTransitionEnd(id) {\n if (transitions[id]) {\n transitions[id].element.removeEventListener(eventName, transitions[id].listener);\n transitions[id] = null;\n return true;\n }\n\n return false;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/on-transition-end.js","import Point from './point';\nimport Classes from './classes';\n\nlet id = 0;\n\nclass ShuffleItem {\n constructor(element) {\n this.id = id++;\n this.element = element;\n this.isVisible = true;\n }\n\n show() {\n this.isVisible = true;\n this.element.classList.remove(Classes.HIDDEN);\n this.element.classList.add(Classes.VISIBLE);\n }\n\n hide() {\n this.isVisible = false;\n this.element.classList.remove(Classes.VISIBLE);\n this.element.classList.add(Classes.HIDDEN);\n }\n\n init() {\n this.addClasses([Classes.SHUFFLE_ITEM, Classes.VISIBLE]);\n this.applyCss(ShuffleItem.Css.INITIAL);\n this.scale = ShuffleItem.Scale.VISIBLE;\n this.point = new Point();\n }\n\n addClasses(classes) {\n classes.forEach((className) => {\n this.element.classList.add(className);\n });\n }\n\n removeClasses(classes) {\n classes.forEach((className) => {\n this.element.classList.remove(className);\n });\n }\n\n applyCss(obj) {\n for (var key in obj) {\n this.element.style[key] = obj[key];\n }\n }\n\n dispose() {\n this.removeClasses([\n Classes.HIDDEN,\n Classes.VISIBLE,\n Classes.SHUFFLE_ITEM,\n ]);\n\n this.element.removeAttribute('style');\n this.element = null;\n }\n}\n\nShuffleItem.Css = {\n INITIAL: {\n position: 'absolute',\n top: 0,\n left: 0,\n visibility: 'visible',\n 'will-change': 'transform',\n },\n VISIBLE: {\n before: {\n opacity: 1,\n visibility: 'visible',\n },\n after: {},\n },\n HIDDEN: {\n before: {\n opacity: 0,\n },\n after: {\n visibility: 'hidden',\n },\n },\n};\n\nShuffleItem.Scale = {\n VISIBLE: 1,\n HIDDEN: 0.001,\n};\n\nexport default ShuffleItem;\n\n\n\n// WEBPACK FOOTER //\n// ./src/shuffle-item.js","'use strict';\n\nimport xtend from 'xtend';\n\n// http://stackoverflow.com/a/962890/373422\nfunction randomize(array) {\n var tmp;\n var current;\n let top = array.length;\n\n if (!top) {\n return array;\n }\n\n while (--top) {\n current = Math.floor(Math.random() * (top + 1));\n tmp = array[current];\n array[current] = array[top];\n array[top] = tmp;\n }\n\n return array;\n}\n\nlet defaults = {\n // Use array.reverse() to reverse the results\n reverse: false,\n\n // Sorting function\n by: null,\n\n // If true, this will skip the sorting and return a randomized order in the array\n randomize: false,\n\n // Determines which property of each item in the array is passed to the\n // sorting method.\n key: 'element',\n};\n\n// You can return `undefined` from the `by` function to revert to DOM order.\nexport default function sorter(arr, options) {\n let opts = xtend(defaults, options);\n let original = [].slice.call(arr);\n let revert = false;\n\n if (!arr.length) {\n return [];\n }\n\n if (opts.randomize) {\n return randomize(arr);\n }\n\n // Sort the elements by the opts.by function.\n // If we don't have opts.by, default to DOM order\n if (typeof opts.by === 'function') {\n arr.sort(function (a, b) {\n\n // Exit early if we already know we want to revert\n if (revert) {\n return 0;\n }\n\n let valA = opts.by(a[opts.key]);\n let valB = opts.by(b[opts.key]);\n\n // If both values are undefined, use the DOM order\n if (valA === undefined && valB === undefined) {\n revert = true;\n return 0;\n }\n\n if (valA < valB || valA === 'sortFirst' || valB === 'sortLast') {\n return -1;\n }\n\n if (valA > valB || valA === 'sortLast' || valB === 'sortFirst') {\n return 1;\n }\n\n return 0;\n });\n }\n\n // Revert to the original array if necessary\n if (revert) {\n return original;\n }\n\n if (opts.reverse) {\n arr.reverse();\n }\n\n return arr;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/sorter.js","// Polyfill for creating CustomEvents on IE9/10/11\n\n// code pulled from:\n// https://github.com/d4tocchini/customevent-polyfill\n// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent#Polyfill\n\ntry {\n var ce = new window.CustomEvent('test');\n ce.preventDefault();\n if (ce.defaultPrevented !== true) {\n // IE has problems with .preventDefault() on custom events\n // http://stackoverflow.com/questions/23349191\n throw new Error('Could not prevent default');\n }\n} catch(e) {\n var CustomEvent = function(event, params) {\n var evt, origPrevent;\n params = params || {\n bubbles: false,\n cancelable: false,\n detail: undefined\n };\n\n evt = document.createEvent(\"CustomEvent\");\n evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);\n origPrevent = evt.preventDefault;\n evt.preventDefault = function () {\n origPrevent.call(this);\n try {\n Object.defineProperty(this, 'defaultPrevented', {\n get: function () {\n return true;\n }\n });\n } catch(e) {\n this.defaultPrevented = true;\n }\n };\n return evt;\n };\n\n CustomEvent.prototype = window.Event.prototype;\n window.CustomEvent = CustomEvent; // expose definition to window\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/custom-event-polyfill/custom-event-polyfill.js\n// module id = 13\n// module chunks = 0","'use strict';\n\nvar proto = Element.prototype;\nvar vendor = proto.matches\n || proto.matchesSelector\n || proto.webkitMatchesSelector\n || proto.mozMatchesSelector\n || proto.msMatchesSelector\n || proto.oMatchesSelector;\n\nmodule.exports = match;\n\n/**\n * Match `el` to `selector`.\n *\n * @param {Element} el\n * @param {String} selector\n * @return {Boolean}\n * @api public\n */\n\nfunction match(el, selector) {\n if (vendor) return vendor.call(el, selector);\n var nodes = el.parentNode.querySelectorAll(selector);\n for (var i = 0; i < nodes.length; i++) {\n if (nodes[i] == el) return true;\n }\n return false;\n}\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/matches-selector/index.js\n// module id = 14\n// module chunks = 0","module.exports = throttle;\n\n/**\n * Returns a new function that, when invoked, invokes `func` at most once per `wait` milliseconds.\n *\n * @param {Function} func Function to wrap.\n * @param {Number} wait Number of milliseconds that must elapse between `func` invocations.\n * @return {Function} A new function that wraps the `func` function passed in.\n */\n\nfunction throttle (func, wait) {\n var ctx, args, rtn, timeoutID; // caching\n var last = 0;\n\n return function throttled () {\n ctx = this;\n args = arguments;\n var delta = new Date() - last;\n if (!timeoutID)\n if (delta >= wait) call();\n else timeoutID = setTimeout(call, wait - delta);\n return rtn;\n };\n\n function call () {\n timeoutID = 0;\n last = +new Date();\n rtn = func.apply(ctx, args);\n ctx = null;\n args = null;\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/throttleit/index.js\n// module id = 15\n// module chunks = 0","var g;\r\n\r\n// This works in non-strict mode\r\ng = (function() {\r\n\treturn this;\r\n})();\r\n\r\ntry {\r\n\t// This works if eval is allowed (see CSP)\r\n\tg = g || Function(\"return this\")() || (1,eval)(\"this\");\r\n} catch(e) {\r\n\t// This works if the window reference is available\r\n\tif(typeof window === \"object\")\r\n\t\tg = window;\r\n}\r\n\r\n// g can still be undefined, but nothing to do about it...\r\n// We return undefined, instead of nothing here, so it's\r\n// easier to handle this case. if(!global) { ...}\r\n\r\nmodule.exports = g;\r\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/buildin/global.js\n// module id = 16\n// module chunks = 0","module.exports = require('./shuffle').default;\n\n\n\n// WEBPACK FOOTER //\n// ./src/index.js"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"shuffle.min.js","sources":["../node_modules/matches-selector/index.js","../node_modules/xtend/immutable.js","../node_modules/throttleit/index.js","../node_modules/array-parallel/index.js","../src/get-number.js","../src/get-number-style.js","../src/sorter.js","../src/on-transition-end.js","../src/array-max.js","../src/array-min.js","../src/layout.js","../src/shuffle.js","../node_modules/custom-event-polyfill/custom-event-polyfill.js","../node_modules/array-uniq/index.js","../src/point.js","../src/classes.js","../src/shuffle-item.js","../src/computed-size.js"],"sourcesContent":["'use strict';\n\nvar proto = Element.prototype;\nvar vendor = proto.matches\n || proto.matchesSelector\n || proto.webkitMatchesSelector\n || proto.mozMatchesSelector\n || proto.msMatchesSelector\n || proto.oMatchesSelector;\n\nmodule.exports = match;\n\n/**\n * Match `el` to `selector`.\n *\n * @param {Element} el\n * @param {String} selector\n * @return {Boolean}\n * @api public\n */\n\nfunction match(el, selector) {\n if (vendor) return vendor.call(el, selector);\n var nodes = el.parentNode.querySelectorAll(selector);\n for (var i = 0; i < nodes.length; i++) {\n if (nodes[i] == el) return true;\n }\n return false;\n}","module.exports = extend\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nfunction extend() {\n var target = {}\n\n for (var i = 0; i < arguments.length; i++) {\n var source = arguments[i]\n\n for (var key in source) {\n if (hasOwnProperty.call(source, key)) {\n target[key] = source[key]\n }\n }\n }\n\n return target\n}\n","module.exports = throttle;\n\n/**\n * Returns a new function that, when invoked, invokes `func` at most once per `wait` milliseconds.\n *\n * @param {Function} func Function to wrap.\n * @param {Number} wait Number of milliseconds that must elapse between `func` invocations.\n * @return {Function} A new function that wraps the `func` function passed in.\n */\n\nfunction throttle (func, wait) {\n var ctx, args, rtn, timeoutID; // caching\n var last = 0;\n\n return function throttled () {\n ctx = this;\n args = arguments;\n var delta = new Date() - last;\n if (!timeoutID)\n if (delta >= wait) call();\n else timeoutID = setTimeout(call, wait - delta);\n return rtn;\n };\n\n function call () {\n timeoutID = 0;\n last = +new Date();\n rtn = func.apply(ctx, args);\n ctx = null;\n args = null;\n }\n}\n","module.exports = function parallel(fns, context, callback) {\n if (!callback) {\n if (typeof context === 'function') {\n callback = context\n context = null\n } else {\n callback = noop\n }\n }\n\n var pending = fns && fns.length\n if (!pending) return callback(null, []);\n\n var finished = false\n var results = new Array(pending)\n\n fns.forEach(context ? function (fn, i) {\n fn.call(context, maybeDone(i))\n } : function (fn, i) {\n fn(maybeDone(i))\n })\n\n function maybeDone(i) {\n return function (err, result) {\n if (finished) return;\n\n if (err) {\n callback(err, results)\n finished = true\n return\n }\n\n results[i] = result\n\n if (!--pending) callback(null, results);\n }\n }\n}\n\nfunction noop() {}\n","/**\n * Always returns a numeric value, given a value. Logic from jQuery's `isNumeric`.\n * @param {*} value Possibly numeric value.\n * @return {number} `value` or zero if `value` isn't numeric.\n */\nexport default function getNumber(value) {\n return parseFloat(value) || 0;\n}\n","import getNumber from './get-number';\nimport COMPUTED_SIZE_INCLUDES_PADDING from './computed-size';\n\n/**\n * Retrieve the computed style for an element, parsed as a float.\n * @param {Element} element Element to get style for.\n * @param {string} style Style property.\n * @param {CSSStyleDeclaration} [styles] Optionally include clean styles to\n * use instead of asking for them again.\n * @return {number} The parsed computed value or zero if that fails because IE\n * will return 'auto' when the element doesn't have margins instead of\n * the computed style.\n */\nexport default function getNumberStyle(element, style,\n styles = window.getComputedStyle(element, null)) {\n var value = getNumber(styles[style]);\n\n // Support IE<=11 and W3C spec.\n if (!COMPUTED_SIZE_INCLUDES_PADDING && style === 'width') {\n value += getNumber(styles.paddingLeft) +\n getNumber(styles.paddingRight) +\n getNumber(styles.borderLeftWidth) +\n getNumber(styles.borderRightWidth);\n } else if (!COMPUTED_SIZE_INCLUDES_PADDING && style === 'height') {\n value += getNumber(styles.paddingTop) +\n getNumber(styles.paddingBottom) +\n getNumber(styles.borderTopWidth) +\n getNumber(styles.borderBottomWidth);\n }\n\n return value;\n}\n","import xtend from 'xtend';\n\n// http://stackoverflow.com/a/962890/373422\nfunction randomize(array) {\n var tmp;\n var current;\n let top = array.length;\n\n if (!top) {\n return array;\n }\n\n while (--top) {\n current = Math.floor(Math.random() * (top + 1));\n tmp = array[current];\n array[current] = array[top];\n array[top] = tmp;\n }\n\n return array;\n}\n\nlet defaults = {\n // Use array.reverse() to reverse the results\n reverse: false,\n\n // Sorting function\n by: null,\n\n // If true, this will skip the sorting and return a randomized order in the array\n randomize: false,\n\n // Determines which property of each item in the array is passed to the\n // sorting method.\n key: 'element',\n};\n\n// You can return `undefined` from the `by` function to revert to DOM order.\nexport default function sorter(arr, options) {\n let opts = xtend(defaults, options);\n let original = [].slice.call(arr);\n let revert = false;\n\n if (!arr.length) {\n return [];\n }\n\n if (opts.randomize) {\n return randomize(arr);\n }\n\n // Sort the elements by the opts.by function.\n // If we don't have opts.by, default to DOM order\n if (typeof opts.by === 'function') {\n arr.sort(function (a, b) {\n\n // Exit early if we already know we want to revert\n if (revert) {\n return 0;\n }\n\n let valA = opts.by(a[opts.key]);\n let valB = opts.by(b[opts.key]);\n\n // If both values are undefined, use the DOM order\n if (valA === undefined && valB === undefined) {\n revert = true;\n return 0;\n }\n\n if (valA < valB || valA === 'sortFirst' || valB === 'sortLast') {\n return -1;\n }\n\n if (valA > valB || valA === 'sortLast' || valB === 'sortFirst') {\n return 1;\n }\n\n return 0;\n });\n }\n\n // Revert to the original array if necessary\n if (revert) {\n return original;\n }\n\n if (opts.reverse) {\n arr.reverse();\n }\n\n return arr;\n}\n","let transitions = {};\nlet eventName = 'transitionend';\nlet count = 0;\n\nfunction uniqueId() {\n return eventName + count++;\n}\n\nexport function onTransitionEnd(element, callback) {\n let id = uniqueId();\n let listener = (evt) => {\n if (evt.currentTarget === evt.target) {\n cancelTransitionEnd(id);\n callback(evt);\n }\n };\n\n element.addEventListener(eventName, listener);\n\n transitions[id] = { element, listener };\n\n return id;\n}\n\nexport function cancelTransitionEnd(id) {\n if (transitions[id]) {\n transitions[id].element.removeEventListener(eventName, transitions[id].listener);\n transitions[id] = null;\n return true;\n }\n\n return false;\n}\n","export default function arrayMax(array) {\n return Math.max.apply(Math, array);\n}\n","export default function arrayMin(array) {\n return Math.min.apply(Math, array);\n}\n","'use strict';\n\nimport Point from './point';\nimport arrayMax from './array-max';\nimport arrayMin from './array-min';\n\n/**\n * Determine the location of the next item, based on its size.\n * @param {Object} itemSize Object with width and height.\n * @param {Array.} positions Positions of the other current items.\n * @param {number} gridSize The column width or row height.\n * @param {number} total The total number of columns or rows.\n * @param {number} threshold Buffer value for the column to fit.\n * @param {number} buffer Vertical buffer for the height of items.\n * @return {Point}\n */\nexport function getItemPosition({ itemSize, positions, gridSize, total, threshold, buffer }) {\n var span = getColumnSpan(itemSize.width, gridSize, total, threshold);\n var setY = getAvailablePositions(positions, span, total);\n var shortColumnIndex = getShortColumn(setY, buffer);\n\n // Position the item\n var point = new Point(\n Math.round(gridSize * shortColumnIndex),\n Math.round(setY[shortColumnIndex]));\n\n // Update the columns array with the new values for each column.\n // e.g. before the update the columns could be [250, 0, 0, 0] for an item\n // which spans 2 columns. After it would be [250, itemHeight, itemHeight, 0].\n var setHeight = setY[shortColumnIndex] + itemSize.height;\n for (var i = 0; i < span; i++) {\n positions[shortColumnIndex + i] = setHeight;\n }\n\n return point;\n}\n\n/**\n * Determine the number of columns an items spans.\n * @param {number} itemWidth Width of the item.\n * @param {number} columnWidth Width of the column (includes gutter).\n * @param {number} columns Total number of columns\n * @param {number} threshold A buffer value for the size of the column to fit.\n * @return {number}\n */\nexport function getColumnSpan(itemWidth, columnWidth, columns, threshold) {\n var columnSpan = itemWidth / columnWidth;\n\n // If the difference between the rounded column span number and the\n // calculated column span number is really small, round the number to\n // make it fit.\n if (Math.abs(Math.round(columnSpan) - columnSpan) < threshold) {\n // e.g. columnSpan = 4.0089945390298745\n columnSpan = Math.round(columnSpan);\n }\n\n // Ensure the column span is not more than the amount of columns in the whole layout.\n return Math.min(Math.ceil(columnSpan), columns);\n}\n\n/**\n * Retrieves the column set to use for placement.\n * @param {number} columnSpan The number of columns this current item spans.\n * @param {number} columns The total columns in the grid.\n * @return {Array.} An array of numbers represeting the column set.\n */\nexport function getAvailablePositions(positions, columnSpan, columns) {\n // The item spans only one column.\n if (columnSpan === 1) {\n return positions;\n }\n\n // The item spans more than one column, figure out how many different\n // places it could fit horizontally.\n // The group count is the number of places within the positions this block\n // could fit, ignoring the current positions of items.\n // Imagine a 2 column brick as the second item in a 4 column grid with\n // 10px height each. Find the places it would fit:\n // [20, 10, 10, 0]\n // | | |\n // * * *\n //\n // Then take the places which fit and get the bigger of the two:\n // max([20, 10]), max([10, 10]), max([10, 0]) = [20, 10, 0]\n //\n // Next, find the first smallest number (the short column).\n // [20, 10, 0]\n // |\n // *\n //\n // And that's where it should be placed!\n //\n // Another example where the second column's item extends past the first:\n // [10, 20, 10, 0] => [20, 20, 10] => 10\n var available = [];\n\n // For how many possible positions for this item there are.\n for (var i = 0; i <= columns - columnSpan; i++) {\n // Find the bigger value for each place it could fit.\n available.push(arrayMax(positions.slice(i, i + columnSpan)));\n }\n\n return available;\n}\n\n/**\n * Find index of short column, the first from the left where this item will go.\n *\n * @param {Array.} positions The array to search for the smallest number.\n * @param {number} buffer Optional buffer which is very useful when the height\n * is a percentage of the width.\n * @return {number} Index of the short column.\n */\nexport function getShortColumn(positions, buffer) {\n var minPosition = arrayMin(positions);\n for (var i = 0, len = positions.length; i < len; i++) {\n if (positions[i] >= minPosition - buffer && positions[i] <= minPosition + buffer) {\n return i;\n }\n }\n\n return 0;\n}\n","import 'custom-event-polyfill';\nimport matches from 'matches-selector';\nimport arrayUnique from 'array-uniq';\nimport xtend from 'xtend';\nimport throttle from 'throttleit';\nimport parallel from 'array-parallel';\nimport Point from './point';\nimport ShuffleItem from './shuffle-item';\nimport Classes from './classes';\nimport getNumberStyle from './get-number-style';\nimport sorter from './sorter';\nimport { onTransitionEnd, cancelTransitionEnd } from './on-transition-end';\nimport { getItemPosition, getColumnSpan, getAvailablePositions, getShortColumn } from './layout';\nimport arrayMax from './array-max';\n\nfunction toArray(arrayLike) {\n return Array.prototype.slice.call(arrayLike);\n}\n\nfunction arrayIncludes(array, obj) {\n if (arguments.length === 2) {\n return arrayIncludes(array)(obj);\n }\n\n return function (obj) {\n return array.indexOf(obj) > -1;\n };\n}\n\n// Used for unique instance variables\nlet id = 0;\n\nclass Shuffle {\n\n /**\n * Categorize, sort, and filter a responsive grid of items.\n *\n * @param {Element} element An element which is the parent container for the grid items.\n * @param {Object} [options=Shuffle.options] Options object.\n * @constructor\n */\n constructor(element, options = {}) {\n this.options = xtend(Shuffle.options, options);\n\n this.useSizer = false;\n this.lastSort = {};\n this.group = this.lastFilter = Shuffle.ALL_ITEMS;\n this.isEnabled = true;\n this.isDestroyed = false;\n this.isInitialized = false;\n this._transitions = [];\n this.isTransitioning = false;\n this._queue = [];\n\n element = this._getElementOption(element);\n\n if (!element) {\n throw new TypeError('Shuffle needs to be initialized with an element.');\n }\n\n this.element = element;\n this.id = 'shuffle_' + id++;\n\n this._init();\n this.isInitialized = true;\n }\n\n _init() {\n this.items = this._getItems();\n\n this.options.sizer = this._getElementOption(this.options.sizer);\n\n if (this.options.sizer) {\n this.useSizer = true;\n }\n\n // Add class and invalidate styles\n this.element.classList.add(Shuffle.Classes.BASE);\n\n // Set initial css for each item\n this._initItems();\n\n // Bind resize events\n this._onResize = this._getResizeFunction();\n window.addEventListener('resize', this._onResize);\n\n // Get container css all in one request. Causes reflow\n var containerCss = window.getComputedStyle(this.element, null);\n var containerWidth = Shuffle.getSize(this.element).width;\n\n // Add styles to the container if it doesn't have them.\n this._validateStyles(containerCss);\n\n // We already got the container's width above, no need to cause another\n // reflow getting it again... Calculate the number of columns there will be\n this._setColumns(containerWidth);\n\n // Kick off!\n this.filter(this.options.group, this.options.initialSort);\n\n // The shuffle items haven't had transitions set on them yet so the user\n // doesn't see the first layout. Set them now that the first layout is done.\n // First, however, a synchronous layout must be caused for the previous\n // styles to be applied without transitions.\n this.element.offsetWidth; // jshint ignore: line\n this._setTransitions();\n this.element.style.transition = 'height ' + this.options.speed + 'ms ' + this.options.easing;\n }\n\n /**\n * Returns a throttled and proxied function for the resize handler.\n * @return {Function}\n * @private\n */\n _getResizeFunction() {\n var resizeFunction = this._handleResize.bind(this);\n return this.options.throttle ?\n this.options.throttle(resizeFunction, this.options.throttleTime) :\n resizeFunction;\n }\n\n /**\n * Retrieve an element from an option.\n * @param {string|jQuery|Element} option The option to check.\n * @return {?Element} The plain element or null.\n * @private\n */\n _getElementOption(option) {\n // If column width is a string, treat is as a selector and search for the\n // sizer element within the outermost container\n if (typeof option === 'string') {\n return this.element.querySelector(option);\n\n // Check for an element\n } else if (option && option.nodeType && option.nodeType === 1) {\n return option;\n\n // Check for jQuery object\n } else if (option && option.jquery) {\n return option[0];\n }\n\n return null;\n }\n\n /**\n * Ensures the shuffle container has the css styles it needs applied to it.\n * @param {Object} styles Key value pairs for position and overflow.\n * @private\n */\n _validateStyles(styles) {\n // Position cannot be static.\n if (styles.position === 'static') {\n this.element.style.position = 'relative';\n }\n\n // Overflow has to be hidden.\n if (styles.overflow !== 'hidden') {\n this.element.style.overflow = 'hidden';\n }\n }\n\n /**\n * Filter the elements by a category.\n * @param {string} [category] Category to filter by. If it's given, the last\n * category will be used to filter the items.\n * @param {Array} [collection] Optionally filter a collection. Defaults to\n * all the items.\n * @return {!{visible: Array, hidden: Array}}\n * @private\n */\n _filter(category = this.lastFilter, collection = this.items) {\n var set = this._getFilteredSets(category, collection);\n\n // Individually add/remove hidden/visible classes\n this._toggleFilterClasses(set);\n\n // Save the last filter in case elements are appended.\n this.lastFilter = category;\n\n // This is saved mainly because providing a filter function (like searching)\n // will overwrite the `lastFilter` property every time its called.\n if (typeof category === 'string') {\n this.group = category;\n }\n\n return set;\n }\n\n /**\n * Returns an object containing the visible and hidden elements.\n * @param {string|Function} category Category or function to filter by.\n * @param {Array.} items A collection of items to filter.\n * @return {!{visible: Array, hidden: Array}}\n * @private\n */\n _getFilteredSets(category, items) {\n let visible = [];\n let hidden = [];\n\n // category === 'all', add visible class to everything\n if (category === Shuffle.ALL_ITEMS) {\n visible = items;\n\n // Loop through each item and use provided function to determine\n // whether to hide it or not.\n } else {\n items.forEach((item) => {\n if (this._doesPassFilter(category, item.element)) {\n visible.push(item);\n } else {\n hidden.push(item);\n }\n });\n }\n\n return {\n visible,\n hidden,\n };\n }\n\n /**\n * Test an item to see if it passes a category.\n * @param {string|Function} category Category or function to filter by.\n * @param {Element} element An element to test.\n * @return {boolean} Whether it passes the category/filter.\n * @private\n */\n _doesPassFilter(category, element) {\n\n if (typeof category === 'function') {\n return category.call(element, element, this);\n\n // Check each element's data-groups attribute against the given category.\n } else {\n let attr = element.getAttribute('data-' + Shuffle.FILTER_ATTRIBUTE_KEY);\n let keys = this.options.delimeter ?\n attr.split(this.options.delimeter) :\n JSON.parse(attr);\n\n if (Array.isArray(category)) {\n return category.some(arrayIncludes(keys));\n }\n\n return arrayIncludes(keys, category);\n }\n }\n\n /**\n * Toggles the visible and hidden class names.\n * @param {{visible, hidden}} Object with visible and hidden arrays.\n * @private\n */\n _toggleFilterClasses({ visible, hidden }) {\n visible.forEach((item) => {\n item.show();\n });\n\n hidden.forEach((item) => {\n item.hide();\n });\n }\n\n /**\n * Set the initial css for each item\n * @param {Array.} [items] Optionally specifiy at set to initialize.\n * @private\n */\n _initItems(items = this.items) {\n items.forEach((item) => {\n item.init();\n });\n }\n\n /**\n * Remove element reference and styles.\n * @private\n */\n _disposeItems(items = this.items) {\n items.forEach((item) => {\n item.dispose();\n });\n }\n\n /**\n * Updates the visible item count.\n * @private\n */\n _updateItemCount() {\n this.visibleItems = this._getFilteredItems().length;\n }\n\n /**\n * Sets css transform transition on a group of elements. This is not executed\n * at the same time as `item.init` so that transitions don't occur upon\n * initialization of Shuffle.\n * @param {Array.} items Shuffle items to set transitions on.\n * @private\n */\n _setTransitions(items = this.items) {\n let speed = this.options.speed;\n let easing = this.options.easing;\n\n var str;\n if (this.options.useTransforms) {\n str = 'transform ' + speed + 'ms ' + easing +\n ', opacity ' + speed + 'ms ' + easing;\n } else {\n str = 'top ' + speed + 'ms ' + easing +\n ', left ' + speed + 'ms ' + easing +\n ', opacity ' + speed + 'ms ' + easing;\n }\n\n items.forEach((item) => {\n item.element.style.transition = str;\n });\n }\n\n _getItems() {\n return toArray(this.element.children)\n .filter(el => matches(el, this.options.itemSelector))\n .map(el => new ShuffleItem(el));\n }\n\n /**\n * When new elements are added to the shuffle container, update the array of\n * items because that is the order `_layout` calls them.\n */\n _updateItemsOrder() {\n let children = this.element.children;\n this.items = sorter(this.items, {\n by(element) {\n return Array.prototype.indexOf.call(children, element);\n },\n });\n }\n\n _getFilteredItems() {\n return this.items.filter(item => item.isVisible);\n }\n\n _getConcealedItems() {\n return this.items.filter(item => !item.isVisible);\n }\n\n /**\n * Returns the column size, based on column width and sizer options.\n * @param {number} containerWidth Size of the parent container.\n * @param {number} gutterSize Size of the gutters.\n * @return {number}\n * @private\n */\n _getColumnSize(containerWidth, gutterSize) {\n var size;\n\n // If the columnWidth property is a function, then the grid is fluid\n if (typeof this.options.columnWidth === 'function') {\n size = this.options.columnWidth(containerWidth);\n\n // columnWidth option isn't a function, are they using a sizing element?\n } else if (this.useSizer) {\n size = Shuffle.getSize(this.options.sizer).width;\n\n // if not, how about the explicitly set option?\n } else if (this.options.columnWidth) {\n size = this.options.columnWidth;\n\n // or use the size of the first item\n } else if (this.items.length > 0) {\n size = Shuffle.getSize(this.items[0].element, true).width;\n\n // if there's no items, use size of container\n } else {\n size = containerWidth;\n }\n\n // Don't let them set a column width of zero.\n if (size === 0) {\n size = containerWidth;\n }\n\n return size + gutterSize;\n }\n\n /**\n * Returns the gutter size, based on gutter width and sizer options.\n * @param {number} containerWidth Size of the parent container.\n * @return {number}\n * @private\n */\n _getGutterSize(containerWidth) {\n var size;\n if (typeof this.options.gutterWidth === 'function') {\n size = this.options.gutterWidth(containerWidth);\n } else if (this.useSizer) {\n size = getNumberStyle(this.options.sizer, 'marginLeft');\n } else {\n size = this.options.gutterWidth;\n }\n\n return size;\n }\n\n /**\n * Calculate the number of columns to be used. Gets css if using sizer element.\n * @param {number} [containerWidth] Optionally specify a container width if\n * it's already available.\n */\n _setColumns(containerWidth = Shuffle.getSize(this.element).width) {\n var gutter = this._getGutterSize(containerWidth);\n var columnWidth = this._getColumnSize(containerWidth, gutter);\n var calculatedColumns = (containerWidth + gutter) / columnWidth;\n\n // Widths given from getStyles are not precise enough...\n if (Math.abs(Math.round(calculatedColumns) - calculatedColumns) <\n this.options.columnThreshold) {\n // e.g. calculatedColumns = 11.998876\n calculatedColumns = Math.round(calculatedColumns);\n }\n\n this.cols = Math.max(Math.floor(calculatedColumns), 1);\n this.containerWidth = containerWidth;\n this.colWidth = columnWidth;\n }\n\n /**\n * Adjust the height of the grid\n */\n _setContainerSize() {\n this.element.style.height = this._getContainerSize() + 'px';\n }\n\n /**\n * Based on the column heights, it returns the biggest one.\n * @return {number}\n * @private\n */\n _getContainerSize() {\n return arrayMax(this.positions);\n }\n\n /**\n * Get the clamped stagger amount.\n * @param {number} index Index of the item to be staggered.\n * @return {number}\n */\n _getStaggerAmount(index) {\n return Math.min(index * this.options.staggerAmount, this.options.staggerAmountMax);\n }\n\n /**\n * @return {boolean} Whether the event was prevented or not.\n */\n _dispatch(name, details = {}) {\n if (this.isDestroyed) {\n return;\n }\n\n details.shuffle = this;\n return !this.element.dispatchEvent(new CustomEvent(name, {\n bubbles: true,\n cancelable: false,\n detail: details,\n }));\n }\n\n /**\n * Zeros out the y columns array, which is used to determine item placement.\n * @private\n */\n _resetCols() {\n var i = this.cols;\n this.positions = [];\n while (i--) {\n this.positions.push(0);\n }\n }\n\n /**\n * Loops through each item that should be shown and calculates the x, y position.\n * @param {Array.} items Array of items that will be shown/layed\n * out in order in their array.\n */\n _layout(items) {\n let count = 0;\n items.forEach((item) => {\n var currPos = item.point;\n var currScale = item.scale;\n var itemSize = Shuffle.getSize(item.element, true);\n var pos = this._getItemPosition(itemSize);\n\n function callback() {\n item.element.style.transitionDelay = '';\n item.applyCss(ShuffleItem.Css.VISIBLE.after);\n }\n\n // If the item will not change its position, do not add it to the render\n // queue. Transitions don't fire when setting a property to the same value.\n if (Point.equals(currPos, pos) && currScale === ShuffleItem.Scale.VISIBLE) {\n item.applyCss(ShuffleItem.Css.VISIBLE.before);\n callback();\n return;\n }\n\n item.point = pos;\n item.scale = ShuffleItem.Scale.VISIBLE;\n\n // Use xtend here to clone the object so that the `before` object isn't\n // modified when the transition delay is added.\n let styles = xtend(ShuffleItem.Css.VISIBLE.before);\n styles.transitionDelay = this._getStaggerAmount(count) + 'ms';\n\n this._queue.push({\n item,\n styles,\n callback,\n });\n\n count++;\n });\n }\n\n /**\n * Determine the location of the next item, based on its size.\n * @param {{width: number, height: number}} itemSize Object with width and height.\n * @return {Point}\n * @private\n */\n _getItemPosition(itemSize) {\n return getItemPosition({\n itemSize,\n positions: this.positions,\n gridSize: this.colWidth,\n total: this.cols,\n threshold: this.options.columnThreshold,\n buffer: this.options.buffer,\n });\n }\n\n /**\n * Hides the elements that don't match our filter.\n * @param {Array.} collection Collection to shrink.\n * @private\n */\n _shrink(collection = this._getConcealedItems()) {\n let count = 0;\n collection.forEach((item) => {\n function callback() {\n item.applyCss(ShuffleItem.Css.HIDDEN.after);\n }\n\n // Continuing would add a transitionend event listener to the element, but\n // that listener would not execute because the transform and opacity would\n // stay the same.\n // The callback is executed here because it is not guaranteed to be called\n // after the transitionend event because the transitionend could be\n // canceled if another animation starts.\n if (item.scale === ShuffleItem.Scale.HIDDEN) {\n item.applyCss(ShuffleItem.Css.HIDDEN.before);\n callback();\n return;\n }\n\n item.scale = ShuffleItem.Scale.HIDDEN;\n\n let styles = xtend(ShuffleItem.Css.HIDDEN.before);\n styles.transitionDelay = this._getStaggerAmount(count) + 'ms';\n\n this._queue.push({\n item,\n styles,\n callback,\n });\n\n count++;\n });\n }\n\n /**\n * Resize handler.\n * @private\n */\n _handleResize() {\n // If shuffle is disabled, destroyed, don't do anything\n if (!this.isEnabled || this.isDestroyed) {\n return;\n }\n\n // Will need to check height in the future if it's layed out horizontaly\n var containerWidth = Shuffle.getSize(this.element).width;\n\n // containerWidth hasn't changed, don't do anything\n if (containerWidth === this.containerWidth) {\n return;\n }\n\n this.update();\n }\n\n /**\n * Returns styles which will be applied to the an item for a transition.\n * @param {Object} obj Transition options.\n * @return {!Object} Transforms for transitions, left/top for animate.\n * @private\n */\n _getStylesForTransition({ item, styles }) {\n if (!styles.transitionDelay) {\n styles.transitionDelay = '0ms';\n }\n\n let x = item.point.x;\n let y = item.point.y;\n\n if (this.options.useTransforms) {\n styles.transform = `translate(${x}px, ${y}px) scale(${item.scale})`;\n } else {\n styles.left = x + 'px';\n styles.top = y + 'px';\n }\n\n return styles;\n }\n\n /**\n * Listen for the transition end on an element and execute the itemCallback\n * when it finishes.\n * @param {Element} element Element to listen on.\n * @param {Function} itemCallback Callback for the item.\n * @param {Function} done Callback to notify `parallel` that this one is done.\n */\n _whenTransitionDone(element, itemCallback, done) {\n let id = onTransitionEnd(element, (evt) => {\n itemCallback();\n done(null, evt);\n });\n\n this._transitions.push(id);\n }\n\n /**\n * Return a function which will set CSS styles and call the `done` function\n * when (if) the transition finishes.\n * @param {Object} opts Transition object.\n * @return {Function} A function to be called with a `done` function.\n */\n _getTransitionFunction(opts) {\n return (done) => {\n opts.item.applyCss(this._getStylesForTransition(opts));\n this._whenTransitionDone(opts.item.element, opts.callback, done);\n };\n }\n\n /**\n * Execute the styles gathered in the style queue. This applies styles to elements,\n * triggering transitions.\n * @private\n */\n _processQueue() {\n if (this.isTransitioning) {\n this._cancelMovement();\n }\n\n let hasSpeed = this.options.speed > 0;\n let hasQueue = this._queue.length > 0;\n\n if (hasQueue && hasSpeed && this.isInitialized) {\n this._startTransitions(this._queue);\n\n } else if (hasQueue) {\n this._styleImmediately(this._queue);\n this._dispatchLayout();\n\n // A call to layout happened, but none of the newly visible items will\n // change position or the transition duration is zero, which will not trigger\n // the transitionend event.\n } else {\n this._dispatchLayout();\n }\n\n // Remove everything in the style queue\n this._queue.length = 0;\n }\n\n /**\n * Wait for each transition to finish, the emit the layout event.\n * @param {Array.} transitions Array of transition objects.\n */\n _startTransitions(transitions) {\n // Set flag that shuffle is currently in motion.\n this.isTransitioning = true;\n\n // Create an array of functions to be called.\n let callbacks = transitions.map(obj => this._getTransitionFunction(obj));\n\n parallel(callbacks, this._movementFinished.bind(this));\n }\n\n _cancelMovement() {\n // Remove the transition end event for each listener.\n this._transitions.forEach(cancelTransitionEnd);\n\n // Reset the array.\n this._transitions.length = 0;\n\n // Show it's no longer active.\n this.isTransitioning = false;\n }\n\n /**\n * Apply styles without a transition.\n * @param {Array.} objects Array of transition objects.\n * @private\n */\n _styleImmediately(objects) {\n if (objects.length) {\n let elements = objects.map(obj => obj.item.element);\n\n Shuffle._skipTransitions(elements, () => {\n objects.forEach((obj) => {\n obj.item.applyCss(this._getStylesForTransition(obj));\n obj.callback();\n });\n });\n }\n }\n\n _movementFinished() {\n this._transitions.length = 0;\n this.isTransitioning = false;\n this._dispatchLayout();\n }\n\n _dispatchLayout() {\n this._dispatch(Shuffle.EventType.LAYOUT);\n }\n\n /**\n * The magic. This is what makes the plugin 'shuffle'\n * @param {string|Function|Array.} [category] Category to filter by.\n * Can be a function, string, or array of strings.\n * @param {Object} [sortObj] A sort object which can sort the visible set\n */\n filter(category, sortObj) {\n if (!this.isEnabled) {\n return;\n }\n\n if (!category || (category && category.length === 0)) {\n category = Shuffle.ALL_ITEMS;\n }\n\n this._filter(category);\n\n // Shrink each hidden item\n this._shrink();\n\n // How many visible elements?\n this._updateItemCount();\n\n // Update transforms on visible elements so they will animate to their new positions.\n this.sort(sortObj);\n }\n\n /**\n * Gets the visible elements, sorts them, and passes them to layout.\n * @param {Object} opts the options object for the sorted plugin\n */\n sort(opts = this.lastSort) {\n if (!this.isEnabled) {\n return;\n }\n\n this._resetCols();\n\n var items = this._getFilteredItems();\n items = sorter(items, opts);\n\n this._layout(items);\n\n // `_layout` always happens after `_shrink`, so it's safe to process the style\n // queue here with styles from the shrink method.\n this._processQueue();\n\n // Adjust the height of the container.\n this._setContainerSize();\n\n this.lastSort = opts;\n }\n\n /**\n * Reposition everything.\n * @param {boolean} isOnlyLayout If true, column and gutter widths won't be\n * recalculated.\n */\n update(isOnlyLayout) {\n if (this.isEnabled) {\n\n if (!isOnlyLayout) {\n // Get updated colCount\n this._setColumns();\n }\n\n // Layout items\n this.sort();\n }\n }\n\n /**\n * Use this instead of `update()` if you don't need the columns and gutters updated\n * Maybe an image inside `shuffle` loaded (and now has a height), which means calculations\n * could be off.\n */\n layout() {\n this.update(true);\n }\n\n /**\n * New items have been appended to shuffle. Mix them in with the current\n * filter or sort status.\n * @param {Array.} newItems Collection of new items.\n */\n add(newItems) {\n newItems = arrayUnique(newItems).map(el => new ShuffleItem(el));\n\n // Add classes and set initial positions.\n this._initItems(newItems);\n\n // Add transition to each item.\n this._setTransitions(newItems);\n\n // Update the list of items.\n this.items = this.items.concat(newItems);\n this._updateItemsOrder();\n this.filter(this.lastFilter);\n }\n\n /**\n * Disables shuffle from updating dimensions and layout on resize\n */\n disable() {\n this.isEnabled = false;\n }\n\n /**\n * Enables shuffle again\n * @param {boolean} [isUpdateLayout=true] if undefined, shuffle will update columns and gutters\n */\n enable(isUpdateLayout) {\n this.isEnabled = true;\n if (isUpdateLayout !== false) {\n this.update();\n }\n }\n\n /**\n * Remove 1 or more shuffle items\n * @param {Array.} collection An array containing one or more\n * elements in shuffle\n * @return {Shuffle} The shuffle object\n */\n remove(collection) {\n if (!collection.length) {\n return;\n }\n\n collection = arrayUnique(collection);\n\n let oldItems = collection\n .map(element => this.getItemByElement(element))\n .filter(item => !!item);\n\n let handleLayout = () => {\n this.element.removeEventListener(Shuffle.EventType.LAYOUT, handleLayout);\n this._disposeItems(oldItems);\n\n // Remove the collection in the callback\n collection.forEach((element) => {\n element.parentNode.removeChild(element);\n });\n\n this._dispatch(Shuffle.EventType.REMOVED, { collection });\n\n // Let it get garbage collected\n collection = null;\n oldItems = null;\n };\n\n // Hide collection first.\n this._toggleFilterClasses({\n visible: [],\n hidden: oldItems,\n });\n\n this._shrink(oldItems);\n\n this.sort();\n\n // Update the list of items here because `remove` could be called again\n // with an item that is in the process of being removed.\n this.items = this.items.filter(item => !arrayIncludes(oldItems, item));\n this._updateItemCount();\n\n this.element.addEventListener(Shuffle.EventType.LAYOUT, handleLayout);\n }\n\n /**\n * Retrieve a shuffle item by its element.\n * @param {Element} element Element to look for.\n * @return {?ShuffleItem} A shuffle item or null if it's not found.\n */\n getItemByElement(element) {\n for (var i = this.items.length - 1; i >= 0; i--) {\n if (this.items[i].element === element) {\n return this.items[i];\n }\n }\n\n return null;\n }\n\n /**\n * Destroys shuffle, removes events, styles, and classes\n */\n destroy() {\n this._cancelMovement();\n window.removeEventListener('resize', this._onResize);\n\n // Reset container styles\n this.element.classList.remove('shuffle');\n this.element.removeAttribute('style');\n\n // Reset individual item styles\n this._disposeItems();\n\n // Null DOM references\n this.items = null;\n this.options.sizer = null;\n this.element = null;\n this._transitions = null;\n\n // Set a flag so if a debounced resize has been triggered,\n // it can first check if it is actually isDestroyed and not doing anything\n this.isDestroyed = true;\n }\n\n /**\n * Returns the outer width of an element, optionally including its margins.\n *\n * There are a few different methods for getting the width of an element, none of\n * which work perfectly for all Shuffle's use cases.\n *\n * 1. getBoundingClientRect() `left` and `right` properties.\n * - Accounts for transform scaled elements, making it useless for Shuffle\n * elements which have shrunk.\n * 2. The `offsetWidth` property.\n * - This value stays the same regardless of the elements transform property,\n * however, it does not return subpixel values.\n * 3. getComputedStyle()\n * - This works great Chrome, Firefox, Safari, but IE<=11 does not include\n * padding and border when box-sizing: border-box is set, requiring a feature\n * test and extra work to add the padding back for IE and other browsers which\n * follow the W3C spec here.\n *\n * @param {Element} element The element.\n * @param {boolean} [includeMargins] Whether to include margins. Default is false.\n * @return {{width: number, height: number}} The width and height.\n */\n static getSize(element, includeMargins) {\n // Store the styles so that they can be used by others without asking for it again.\n var styles = window.getComputedStyle(element, null);\n var width = getNumberStyle(element, 'width', styles);\n var height = getNumberStyle(element, 'height', styles);\n\n if (includeMargins) {\n var marginLeft = getNumberStyle(element, 'marginLeft', styles);\n var marginRight = getNumberStyle(element, 'marginRight', styles);\n var marginTop = getNumberStyle(element, 'marginTop', styles);\n var marginBottom = getNumberStyle(element, 'marginBottom', styles);\n width += marginLeft + marginRight;\n height += marginTop + marginBottom;\n }\n\n return {\n width,\n height,\n };\n }\n\n /**\n * Change a property or execute a function which will not have a transition\n * @param {Array.} elements DOM elements that won't be transitioned.\n * @param {Function} callback A function which will be called while transition\n * is set to 0ms.\n * @private\n */\n static _skipTransitions(elements, callback) {\n let zero = '0ms';\n\n // Save current duration and delay.\n let data = elements.map((element) => {\n let style = element.style;\n let duration = style.transitionDuration;\n let delay = style.transitionDelay;\n\n // Set the duration to zero so it happens immediately\n style.transitionDuration = zero;\n style.transitionDelay = zero;\n\n return {\n duration,\n delay,\n };\n });\n\n callback();\n\n // Cause reflow.\n elements[0].offsetWidth; // jshint ignore:line\n\n // Put the duration back\n elements.forEach((element, i) => {\n element.style.transitionDuration = data[i].duration;\n element.style.transitionDelay = data[i].delay;\n });\n }\n}\n\nShuffle.ShuffleItem = ShuffleItem;\n\nShuffle.ALL_ITEMS = 'all';\nShuffle.FILTER_ATTRIBUTE_KEY = 'groups';\n\n/**\n * @enum {string}\n */\nShuffle.EventType = {\n LAYOUT: 'shuffle:layout',\n REMOVED: 'shuffle:removed',\n};\n\n/** @enum {string} */\nShuffle.Classes = Classes;\n\n// Overrideable options\nShuffle.options = {\n // Initial filter group.\n group: Shuffle.ALL_ITEMS,\n\n // Transition/animation speed (milliseconds).\n speed: 250,\n\n // CSS easing function to use.\n easing: 'ease',\n\n // e.g. '.picture-item'.\n itemSelector: '*',\n\n // Element or selector string. Use an element to determine the size of columns\n // and gutters.\n sizer: null,\n\n // A static number or function that tells the plugin how wide the gutters\n // between columns are (in pixels).\n gutterWidth: 0,\n\n // A static number or function that returns a number which tells the plugin\n // how wide the columns are (in pixels).\n columnWidth: 0,\n\n // If your group is not json, and is comma delimeted, you could set delimeter\n // to ','.\n delimeter: null,\n\n // Useful for percentage based heights when they might not always be exactly\n // the same (in pixels).\n buffer: 0,\n\n // Reading the width of elements isn't precise enough and can cause columns to\n // jump between values.\n columnThreshold: 0.01,\n\n // Shuffle can be isInitialized with a sort object. It is the same object\n // given to the sort method.\n initialSort: null,\n\n // By default, shuffle will throttle resize events. This can be changed or\n // removed.\n throttle: throttle,\n\n // How often shuffle can be called on resize (in milliseconds).\n throttleTime: 300,\n\n // Transition delay offset for each item in milliseconds.\n staggerAmount: 15,\n\n // Maximum stagger delay in milliseconds.\n staggerAmountMax: 250,\n\n // Whether to use transforms or absolute positioning.\n useTransforms: true,\n};\n\n// Expose for testing. Hack at your own risk.\nShuffle.__Point = Point;\nShuffle.__sorter = sorter;\nShuffle.__getColumnSpan = getColumnSpan;\nShuffle.__getAvailablePositions = getAvailablePositions;\nShuffle.__getShortColumn = getShortColumn;\n\nexport default Shuffle;\n","// Polyfill for creating CustomEvents on IE9/10/11\n\n// code pulled from:\n// https://github.com/d4tocchini/customevent-polyfill\n// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent#Polyfill\n\ntry {\n var ce = new window.CustomEvent('test');\n ce.preventDefault();\n if (ce.defaultPrevented !== true) {\n // IE has problems with .preventDefault() on custom events\n // http://stackoverflow.com/questions/23349191\n throw new Error('Could not prevent default');\n }\n} catch(e) {\n var CustomEvent = function(event, params) {\n var evt, origPrevent;\n params = params || {\n bubbles: false,\n cancelable: false,\n detail: undefined\n };\n\n evt = document.createEvent(\"CustomEvent\");\n evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);\n origPrevent = evt.preventDefault;\n evt.preventDefault = function () {\n origPrevent.call(this);\n try {\n Object.defineProperty(this, 'defaultPrevented', {\n get: function () {\n return true;\n }\n });\n } catch(e) {\n this.defaultPrevented = true;\n }\n };\n return evt;\n };\n\n CustomEvent.prototype = window.Event.prototype;\n window.CustomEvent = CustomEvent; // expose definition to window\n}\n","'use strict';\n\n// there's 3 implementations written in increasing order of efficiency\n\n// 1 - no Set type is defined\nfunction uniqNoSet(arr) {\n\tvar ret = [];\n\n\tfor (var i = 0; i < arr.length; i++) {\n\t\tif (ret.indexOf(arr[i]) === -1) {\n\t\t\tret.push(arr[i]);\n\t\t}\n\t}\n\n\treturn ret;\n}\n\n// 2 - a simple Set type is defined\nfunction uniqSet(arr) {\n\tvar seen = new Set();\n\treturn arr.filter(function (el) {\n\t\tif (!seen.has(el)) {\n\t\t\tseen.add(el);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t});\n}\n\n// 3 - a standard Set type is defined and it has a forEach method\nfunction uniqSetWithForEach(arr) {\n\tvar ret = [];\n\n\t(new Set(arr)).forEach(function (el) {\n\t\tret.push(el);\n\t});\n\n\treturn ret;\n}\n\n// V8 currently has a broken implementation\n// https://github.com/joyent/node/issues/8449\nfunction doesForEachActuallyWork() {\n\tvar ret = false;\n\n\t(new Set([true])).forEach(function (el) {\n\t\tret = el;\n\t});\n\n\treturn ret === true;\n}\n\nif ('Set' in global) {\n\tif (typeof Set.prototype.forEach === 'function' && doesForEachActuallyWork()) {\n\t\tmodule.exports = uniqSetWithForEach;\n\t} else {\n\t\tmodule.exports = uniqSet;\n\t}\n} else {\n\tmodule.exports = uniqNoSet;\n}\n","import getNumber from './get-number';\n\n/**\n * Represents a coordinate pair.\n * @param {number} [x=0] X.\n * @param {number} [y=0] Y.\n */\nconst Point = function (x, y) {\n this.x = getNumber(x);\n this.y = getNumber(y);\n};\n\n/**\n * Whether two points are equal.\n * @param {Point} a Point A.\n * @param {Point} b Point B.\n * @return {boolean}\n */\nPoint.equals = function (a, b) {\n return a.x === b.x && a.y === b.y;\n};\n\nexport default Point;\n","export default {\n BASE: 'shuffle',\n SHUFFLE_ITEM: 'shuffle-item',\n VISIBLE: 'shuffle-item--visible',\n HIDDEN: 'shuffle-item--hidden',\n};\n","import Point from './point';\nimport Classes from './classes';\n\nlet id = 0;\n\nclass ShuffleItem {\n constructor(element) {\n this.id = id++;\n this.element = element;\n this.isVisible = true;\n }\n\n show() {\n this.isVisible = true;\n this.element.classList.remove(Classes.HIDDEN);\n this.element.classList.add(Classes.VISIBLE);\n }\n\n hide() {\n this.isVisible = false;\n this.element.classList.remove(Classes.VISIBLE);\n this.element.classList.add(Classes.HIDDEN);\n }\n\n init() {\n this.addClasses([Classes.SHUFFLE_ITEM, Classes.VISIBLE]);\n this.applyCss(ShuffleItem.Css.INITIAL);\n this.scale = ShuffleItem.Scale.VISIBLE;\n this.point = new Point();\n }\n\n addClasses(classes) {\n classes.forEach((className) => {\n this.element.classList.add(className);\n });\n }\n\n removeClasses(classes) {\n classes.forEach((className) => {\n this.element.classList.remove(className);\n });\n }\n\n applyCss(obj) {\n for (var key in obj) {\n this.element.style[key] = obj[key];\n }\n }\n\n dispose() {\n this.removeClasses([\n Classes.HIDDEN,\n Classes.VISIBLE,\n Classes.SHUFFLE_ITEM,\n ]);\n\n this.element.removeAttribute('style');\n this.element = null;\n }\n}\n\nShuffleItem.Css = {\n INITIAL: {\n position: 'absolute',\n top: 0,\n left: 0,\n visibility: 'visible',\n 'will-change': 'transform',\n },\n VISIBLE: {\n before: {\n opacity: 1,\n visibility: 'visible',\n },\n after: {},\n },\n HIDDEN: {\n before: {\n opacity: 0,\n },\n after: {\n visibility: 'hidden',\n },\n },\n};\n\nShuffleItem.Scale = {\n VISIBLE: 1,\n HIDDEN: 0.001,\n};\n\nexport default ShuffleItem;\n","let element = document.body || document.documentElement;\nlet e = document.createElement('div');\ne.style.cssText = 'width:10px;padding:2px;box-sizing:border-box;';\nelement.appendChild(e);\n\nlet width = window.getComputedStyle(e, null).width;\nlet ret = width === '10px';\n\nelement.removeChild(e);\n\nexport default ret;\n"],"names":["match","el","selector","vendor","call","nodes","parentNode","querySelectorAll","i","length","extend","target","arguments","source","key","hasOwnProperty","throttle","func","wait","timeoutID","last","Date","rtn","apply","ctx","args","this","delta","setTimeout","noop","getNumber","value","parseFloat","getNumberStyle","element","style","styles","window","getComputedStyle","COMPUTED_SIZE_INCLUDES_PADDING","paddingTop","paddingBottom","borderTopWidth","borderBottomWidth","paddingLeft","paddingRight","borderLeftWidth","borderRightWidth","randomize","array","tmp","current","top","Math","floor","random","sorter","arr","options","opts","xtend","defaults","original","slice","revert","by","sort","a","b","valA","valB","undefined","reverse","uniqueId","eventName","count","onTransitionEnd","callback","id","listener","evt","currentTarget","addEventListener","cancelTransitionEnd","transitions","removeEventListener","arrayMax","max","arrayMin","min","getItemPosition","itemSize","positions","gridSize","total","threshold","buffer","span","getColumnSpan","width","setY","getAvailablePositions","shortColumnIndex","getShortColumn","point","Point","round","setHeight","height","itemWidth","columnWidth","columns","columnSpan","abs","ceil","available","push","minPosition","len","toArray","arrayLike","Array","prototype","arrayIncludes","obj","indexOf","ce","CustomEvent","preventDefault","defaultPrevented","Error","e","event","params","origPrevent","bubbles","cancelable","detail","document","createEvent","initCustomEvent","Object","defineProperty","get","Event","proto","Element","matches","matchesSelector","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector","uniqNoSet","ret","uniqSet","seen","Set","filter","has","add","uniqSetWithForEach","forEach","global","module","fns","context","maybeDone","err","result","finished","results","pending","fn","x","y","equals","ShuffleItem","isVisible","classList","remove","Classes","HIDDEN","VISIBLE","addClasses","SHUFFLE_ITEM","applyCss","Css","INITIAL","scale","Scale","classes","className","removeClasses","removeAttribute","body","documentElement","createElement","cssText","appendChild","removeChild","Shuffle","useSizer","lastSort","group","lastFilter","ALL_ITEMS","isEnabled","isDestroyed","isInitialized","_transitions","isTransitioning","_queue","_getElementOption","TypeError","_init","items","_getItems","sizer","BASE","_initItems","_onResize","_getResizeFunction","containerCss","containerWidth","getSize","_validateStyles","_setColumns","initialSort","offsetWidth","_setTransitions","transition","speed","easing","resizeFunction","_handleResize","bind","throttleTime","option","querySelector","nodeType","jquery","position","overflow","category","collection","set","_getFilteredSets","_toggleFilterClasses","visible","hidden","item","_this","_doesPassFilter","attr","getAttribute","FILTER_ATTRIBUTE_KEY","keys","delimeter","split","JSON","parse","isArray","some","show","hide","init","dispose","visibleItems","_getFilteredItems","str","useTransforms","children","_this2","itemSelector","map","gutterSize","size","gutterWidth","gutter","_getGutterSize","_getColumnSize","calculatedColumns","columnThreshold","cols","colWidth","_getContainerSize","index","staggerAmount","staggerAmountMax","name","details","shuffle","dispatchEvent","transitionDelay","after","currPos","currScale","pos","_this3","_getItemPosition","before","_getStaggerAmount","_getConcealedItems","_this4","update","transform","left","itemCallback","done","_this5","_getStylesForTransition","_whenTransitionDone","_cancelMovement","hasSpeed","hasQueue","_startTransitions","_styleImmediately","_dispatchLayout","callbacks","_this6","_getTransitionFunction","_movementFinished","objects","elements","_skipTransitions","_this7","_dispatch","EventType","LAYOUT","sortObj","_filter","_shrink","_updateItemCount","_resetCols","_layout","_processQueue","_setContainerSize","isOnlyLayout","newItems","arrayUnique","concat","_updateItemsOrder","isUpdateLayout","oldItems","_this8","getItemByElement","handleLayout","_disposeItems","REMOVED","includeMargins","marginLeft","marginRight","marginTop","marginBottom","data","duration","transitionDuration","delay","__Point","__sorter","__getColumnSpan","__getAvailablePositions","__getShortColumn"],"mappings":"kLAqBA,SAASA,GAAMC,EAAIC,GACjB,GAAIC,EAAQ,MAAOA,GAAOC,KAAKH,EAAIC,EAEnC,KAAK,GADDG,GAAQJ,EAAGK,WAAWC,iBAAiBL,GAClCM,EAAI,EAAGA,EAAIH,EAAMI,OAAQD,IAChC,GAAIH,EAAMG,IAAMP,EAAI,OAAO,CAE7B,QAAO,ECvBT,QAASS,KAGL,IAAK,GAFDC,MAEKH,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,WACnCjU,MAAMmQ,gBAAkB6D,EAAK3V,GAAG8V,uBAK9C7J,GAAQxB,YAAcA,EAEtBwB,EAAQK,UAAY,MACpBL,EAAQuD,qBAAuB,SAK/BvD,EAAQ+H,kBACE,yBACC,mBAIX/H,EAAQpB,QAAUA,EAGlBoB,EAAQ/I,eAEC+I,EAAQK,gBAGR,WAGC,oBAGM,UAIP,iBAIM,cAIA,YAIF,YAIH,kBAIS,gBAIJ,cAIH9L,eAGI,kBAGC,oBAGG,mBAGH,GAIjByL,EAAQ8J,QAAU9P,EAClBgG,EAAQ+J,SAAWhT,EACnBiJ,EAAQgK,gBAAkBvQ,EAC1BuG,EAAQiK,wBAA0BrQ,EAClCoG,EAAQkK,iBAAmBpQ"} \ No newline at end of file diff --git a/gulp/config.js b/gulp/config.js index edd927e..30bb0ed 100644 --- a/gulp/config.js +++ b/gulp/config.js @@ -1,4 +1,61 @@ +const babel = require('rollup-plugin-babel'); +const resolve = require('rollup-plugin-node-resolve'); +const commonjs = require('rollup-plugin-commonjs'); +const uglify = require('rollup-plugin-uglify'); -module.exports = { - watch: false, +const commonjsOptions = { + include: 'node_modules/**', }; + +const babelOptions = { + exclude: 'node_modules/**', +}; + +const uglifyOptions = { + sourceMap: true, + comments: false, + screw_ie8: true, + compress: { + warnings: true, + drop_console: true, + }, + mangle: true, +}; + +const entry = './src/shuffle.js'; +const moduleName = 'shuffle'; +const format = 'umd'; +const sourceMap = true; + +module.exports.configs = [ + { + entry, + cache: undefined, + plugins: [ + resolve(), + commonjs(commonjsOptions), + babel(babelOptions), + ], + dest: './dist/shuffle.js', + sourceMap, + moduleName, + format, + }, + + { + entry, + cache: undefined, + plugins: [ + resolve(), + commonjs(commonjsOptions), + babel(babelOptions), + uglify(uglifyOptions), + ], + dest: './dist/shuffle.min.js', + sourceMap, + moduleName, + format, + }, +]; + +module.exports.watch = false; diff --git a/gulp/tasks/compile.js b/gulp/tasks/compile.js deleted file mode 100644 index adfdb1f..0000000 --- a/gulp/tasks/compile.js +++ /dev/null @@ -1,31 +0,0 @@ -'use strict'; - -const gutil = require('gulp-util'); -const webpack = require('webpack'); -const config = require('../config'); - -module.exports = function compile(done) { - let main = Object.assign({}, require('../../webpack.config.js')); - let min = Object.assign({}, require('../../webpack.config.min.js')); - let compiler = webpack([main, min]); - - let isDone = false; - function callback(err, stats) { - if (err) { - throw new Error(err); - } - - gutil.log(stats.toString({ colors: true })); - - if (!isDone) { - isDone = true; - done(); - } - } - - if (config.watch) { - compiler.watch({}, callback); - } else { - compiler.run(callback); - } -}; diff --git a/gulp/tasks/scripts.js b/gulp/tasks/scripts.js new file mode 100644 index 0000000..841bd07 --- /dev/null +++ b/gulp/tasks/scripts.js @@ -0,0 +1,11 @@ +const rollup = require('rollup').rollup; +const configs = require('../config').configs; + +module.exports = function scripts() { + const bundles = configs.map(config => rollup(config).then((bundle) => { + config.cache = bundle; + return bundle.write(config); + })); + + return Promise.all(bundles); +}; diff --git a/gulp/tasks/set-watching.js b/gulp/tasks/set-watching.js index 7b4397a..d224e1b 100644 --- a/gulp/tasks/set-watching.js +++ b/gulp/tasks/set-watching.js @@ -1,13 +1,13 @@ -'use strict'; - const gulp = require('gulp'); const config = require('../config'); const cssTask = require('./css'); const testTask = require('./test'); +const scriptsTask = require('./scripts'); module.exports = function setWatching(done) { config.watch = true; gulp.watch('_scss/*.scss', cssTask); gulp.watch('test/*', testTask); + gulp.watch('src/*', scriptsTask); done(); }; diff --git a/gulp/tasks/test.js b/gulp/tasks/test.js index 38cfaa0..81b3895 100644 --- a/gulp/tasks/test.js +++ b/gulp/tasks/test.js @@ -1,5 +1,3 @@ -'use strict'; - const gulp = require('gulp'); const mochaPhantomJS = require('gulp-mocha-phantomjs'); const config = require('../config'); diff --git a/gulpfile.js b/gulpfile.js index 0c75a41..ad6fb3b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -2,7 +2,7 @@ const gulp = require('gulp'); -gulp.task('scripts', require('./gulp/tasks/compile')); +gulp.task('scripts', require('./gulp/tasks/scripts')); gulp.task('set-watching', require('./gulp/tasks/set-watching')); gulp.task('css', require('./gulp/tasks/css')); gulp.task('jekyll', require('./gulp/tasks/jekyll')); diff --git a/package.json b/package.json index cdf0b0b..81a73cd 100644 --- a/package.json +++ b/package.json @@ -48,10 +48,8 @@ }, "devDependencies": { "autoprefixer": "^6.3.4", - "babel-core": "^6.5.2", - "babel-loader": "^6.2.2", - "babel-preset-es2015": "^6.5.0", - "babel-register": "^6.5.2", + "babel-plugin-external-helpers": "^6.22.0", + "babel-preset-es2015": "^6.24.1", "chai": "^3.5.0", "chai-dom": "^1.4.0", "es6-promise": "^4.0.5", @@ -62,7 +60,11 @@ "gulp-shell": "^0.6.1", "gulp-util": "^3.0.7", "mocha": "^3.0.0", - "sinon": "^2.1.0", - "webpack": "^2.2.1" + "rollup": "^0.41.6", + "rollup-plugin-babel": "^2.7.1", + "rollup-plugin-commonjs": "^8.0.2", + "rollup-plugin-node-resolve": "^3.0.0", + "rollup-plugin-uglify": "^1.0.1", + "sinon": "^2.1.0" } } diff --git a/src/array-max.js b/src/array-max.js new file mode 100644 index 0000000..d39f279 --- /dev/null +++ b/src/array-max.js @@ -0,0 +1,3 @@ +export default function arrayMax(array) { + return Math.max.apply(Math, array); +} diff --git a/src/array-min.js b/src/array-min.js new file mode 100644 index 0000000..e5136b4 --- /dev/null +++ b/src/array-min.js @@ -0,0 +1,3 @@ +export default function arrayMin(array) { + return Math.min.apply(Math, array); +} diff --git a/src/computed-size.js b/src/computed-size.js index f940a53..247df78 100644 --- a/src/computed-size.js +++ b/src/computed-size.js @@ -1,4 +1,3 @@ - let element = document.body || document.documentElement; let e = document.createElement('div'); e.style.cssText = 'width:10px;padding:2px;box-sizing:border-box;'; diff --git a/src/get-number-style.js b/src/get-number-style.js index 5142c1c..ee7688f 100644 --- a/src/get-number-style.js +++ b/src/get-number-style.js @@ -1,5 +1,3 @@ -'use strict'; - import getNumber from './get-number'; import COMPUTED_SIZE_INCLUDES_PADDING from './computed-size'; diff --git a/src/get-number.js b/src/get-number.js index 4c0006d..9151c6c 100644 --- a/src/get-number.js +++ b/src/get-number.js @@ -1,5 +1,3 @@ -'use strict'; - /** * Always returns a numeric value, given a value. Logic from jQuery's `isNumeric`. * @param {*} value Possibly numeric value. diff --git a/src/index.js b/src/index.js deleted file mode 100644 index 5a54e4c..0000000 --- a/src/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./shuffle').default; diff --git a/src/layout.js b/src/layout.js index 371acab..40234b5 100644 --- a/src/layout.js +++ b/src/layout.js @@ -1,14 +1,8 @@ 'use strict'; import Point from './point'; - -function arrayMax(array) { - return Math.max.apply(Math, array); -} - -function arrayMin(array) { - return Math.min.apply(Math, array); -} +import arrayMax from './array-max'; +import arrayMin from './array-min'; /** * Determine the location of the next item, based on its size. diff --git a/src/on-transition-end.js b/src/on-transition-end.js index c12829a..31138ea 100644 --- a/src/on-transition-end.js +++ b/src/on-transition-end.js @@ -1,5 +1,3 @@ -'use strict'; - let transitions = {}; let eventName = 'transitionend'; let count = 0; diff --git a/src/point.js b/src/point.js index 6e4bd19..20e846e 100644 --- a/src/point.js +++ b/src/point.js @@ -1,5 +1,3 @@ -'use strict'; - import getNumber from './get-number'; /** diff --git a/src/shuffle.js b/src/shuffle.js index 4df14db..835fb63 100644 --- a/src/shuffle.js +++ b/src/shuffle.js @@ -1,5 +1,3 @@ -'use strict'; - import 'custom-event-polyfill'; import matches from 'matches-selector'; import arrayUnique from 'array-uniq'; @@ -13,15 +11,12 @@ import getNumberStyle from './get-number-style'; import sorter from './sorter'; import { onTransitionEnd, cancelTransitionEnd } from './on-transition-end'; import { getItemPosition, getColumnSpan, getAvailablePositions, getShortColumn } from './layout'; +import arrayMax from './array-max'; function toArray(arrayLike) { return Array.prototype.slice.call(arrayLike); } -function arrayMax(array) { - return Math.max.apply(Math, array); -} - function arrayIncludes(array, obj) { if (arguments.length === 2) { return arrayIncludes(array)(obj); diff --git a/src/sorter.js b/src/sorter.js index e9252a7..75edd16 100644 --- a/src/sorter.js +++ b/src/sorter.js @@ -1,5 +1,3 @@ -'use strict'; - import xtend from 'xtend'; // http://stackoverflow.com/a/962890/373422 diff --git a/webpack.config.js b/webpack.config.js deleted file mode 100644 index 331deed..0000000 --- a/webpack.config.js +++ /dev/null @@ -1,29 +0,0 @@ -const path = require('path'); - -module.exports = { - name: 'build', - devtool: 'source-map', - entry: './src/index.js', - output: { - filename: 'shuffle.js', - path: './dist', - library: 'shuffle', - libraryTarget: 'umd', - }, - resolve: { - modules: [ - path.resolve('./src'), - 'node_modules', - ], - }, - module: { - rules: [ - { - test: /\.js$/, - exclude: /node_modules/, - loader: 'babel-loader', - }, - ], - }, - plugins: [], -}; diff --git a/webpack.config.min.js b/webpack.config.min.js deleted file mode 100644 index 06fbf23..0000000 --- a/webpack.config.min.js +++ /dev/null @@ -1,41 +0,0 @@ -const path = require('path'); -const webpack = require('webpack'); - -module.exports = { - name: 'minified', - devtool: 'source-map', - entry: './src/index.js', - output: { - filename: 'shuffle.min.js', - path: './dist', - library: 'shuffle', - libraryTarget: 'umd', - }, - resolve: { - modules: [ - path.resolve('./src'), - 'node_modules', - ], - }, - module: { - rules: [ - { - test: /\.js$/, - exclude: /node_modules/, - loader: 'babel-loader', - }, - ], - }, - plugins: [ - new webpack.optimize.UglifyJsPlugin({ - sourceMap: true, - comments: false, - screw_ie8: true, - compress: { - warnings: true, - drop_console: true, - }, - mangle: true, - }), - ], -};