/* ----------------------------------------------------------
* Plugins
* ---------------------------------------------------------- */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.window = global.window || {}));
}(this, (function (exports) { 'use strict';
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
/*!
* GSAP 3.6.1
* https://greensock.com
*
* @license Copyright 2008-2021, GreenSock. All rights reserved.
* Subject to the terms at https://greensock.com/standard-license or for
* Club GreenSock members, the agreement issued with that membership.
* @author: Jack Doyle, jack@greensock.com
*/
var _config = {
autoSleep: 120,
force3D: "auto",
nullTargetWarn: 1,
units: {
lineHeight: ""
}
},
_defaults = {
duration: .5,
overwrite: false,
delay: 0
},
_suppressOverwrites,
_bigNum = 1e8,
_tinyNum = 1 / _bigNum,
_2PI = Math.PI * 2,
_HALF_PI = _2PI / 4,
_gsID = 0,
_sqrt = Math.sqrt,
_cos = Math.cos,
_sin = Math.sin,
_isString = function _isString(value) {
return typeof value === "string";
},
_isFunction = function _isFunction(value) {
return typeof value === "function";
},
_isNumber = function _isNumber(value) {
return typeof value === "number";
},
_isUndefined = function _isUndefined(value) {
return typeof value === "undefined";
},
_isObject = function _isObject(value) {
return typeof value === "object";
},
_isNotFalse = function _isNotFalse(value) {
return value !== false;
},
_windowExists = function _windowExists() {
return typeof window !== "undefined";
},
_isFuncOrString = function _isFuncOrString(value) {
return _isFunction(value) || _isString(value);
},
_isTypedArray = typeof ArrayBuffer === "function" && ArrayBuffer.isView || function () {},
_isArray = Array.isArray,
_strictNumExp = /(?:-?\.?\d|\.)+/gi,
_numExp = /[-+=.]*\d+[.e\-+]*\d*[e\-+]*\d*/g,
_numWithUnitExp = /[-+=.]*\d+[.e-]*\d*[a-z%]*/g,
_complexStringNumExp = /[-+=.]*\d+\.?\d*(?:e-|e\+)?\d*/gi,
_relExp = /[+-]=-?[.\d]+/,
_delimitedValueExp = /[#\-+.]*\b[a-z\d-=+%.]+/gi,
_unitExp = /[\d.+\-=]+(?:e[-+]\d*)*/i,
_globalTimeline,
_win,
_coreInitted,
_doc,
_globals = {},
_installScope = {},
_coreReady,
_install = function _install(scope) {
return (_installScope = _merge(scope, _globals)) && gsap;
},
_missingPlugin = function _missingPlugin(property, value) {
return console.warn("Invalid property", property, "set to", value, "Missing plugin? gsap.registerPlugin()");
},
_warn = function _warn(message, suppress) {
return !suppress && console.warn(message);
},
_addGlobal = function _addGlobal(name, obj) {
return name && (_globals[name] = obj) && _installScope && (_installScope[name] = obj) || _globals;
},
_emptyFunc = function _emptyFunc() {
return 0;
},
_reservedProps = {},
_lazyTweens = [],
_lazyLookup = {},
_lastRenderedFrame,
_plugins = {},
_effects = {},
_nextGCFrame = 30,
_harnessPlugins = [],
_callbackNames = "",
_harness = function _harness(targets) {
var target = targets[0],
harnessPlugin,
i;
_isObject(target) || _isFunction(target) || (targets = [targets]);
if (!(harnessPlugin = (target._gsap || {}).harness)) {
i = _harnessPlugins.length;
while (i-- && !_harnessPlugins[i].targetTest(target)) {}
harnessPlugin = _harnessPlugins[i];
}
i = targets.length;
while (i--) {
targets[i] && (targets[i]._gsap || (targets[i]._gsap = new GSCache(targets[i], harnessPlugin))) || targets.splice(i, 1);
}
return targets;
},
_getCache = function _getCache(target) {
return target._gsap || _harness(toArray(target))[0]._gsap;
},
_getProperty = function _getProperty(target, property, v) {
return (v = target[property]) && _isFunction(v) ? target[property]() : _isUndefined(v) && target.getAttribute && target.getAttribute(property) || v;
},
_forEachName = function _forEachName(names, func) {
return (names = names.split(",")).forEach(func) || names;
},
_round = function _round(value) {
return Math.round(value * 100000) / 100000 || 0;
},
_arrayContainsAny = function _arrayContainsAny(toSearch, toFind) {
var l = toFind.length,
i = 0;
for (; toSearch.indexOf(toFind[i]) < 0 && ++i < l;) {}
return i < l;
},
_parseVars = function _parseVars(params, type, parent) {
var isLegacy = _isNumber(params[1]),
varsIndex = (isLegacy ? 2 : 1) + (type < 2 ? 0 : 1),
vars = params[varsIndex],
irVars;
isLegacy && (vars.duration = params[1]);
vars.parent = parent;
if (type) {
irVars = vars;
while (parent && !("immediateRender" in irVars)) {
irVars = parent.vars.defaults || {};
parent = _isNotFalse(parent.vars.inherit) && parent.parent;
}
vars.immediateRender = _isNotFalse(irVars.immediateRender);
type < 2 ? vars.runBackwards = 1 : vars.startAt = params[varsIndex - 1];
}
return vars;
},
_lazyRender = function _lazyRender() {
var l = _lazyTweens.length,
a = _lazyTweens.slice(0),
i,
tween;
_lazyLookup = {};
_lazyTweens.length = 0;
for (i = 0; i < l; i++) {
tween = a[i];
tween && tween._lazy && (tween.render(tween._lazy[0], tween._lazy[1], true)._lazy = 0);
}
},
_lazySafeRender = function _lazySafeRender(animation, time, suppressEvents, force) {
_lazyTweens.length && _lazyRender();
animation.render(time, suppressEvents, force);
_lazyTweens.length && _lazyRender();
},
_numericIfPossible = function _numericIfPossible(value) {
var n = parseFloat(value);
return (n || n === 0) && (value + "").match(_delimitedValueExp).length < 2 ? n : _isString(value) ? value.trim() : value;
},
_passThrough = function _passThrough(p) {
return p;
},
_setDefaults = function _setDefaults(obj, defaults) {
for (var p in defaults) {
p in obj || (obj[p] = defaults[p]);
}
return obj;
},
_setKeyframeDefaults = function _setKeyframeDefaults(obj, defaults) {
for (var p in defaults) {
p in obj || p === "duration" || p === "ease" || (obj[p] = defaults[p]);
}
},
_merge = function _merge(base, toMerge) {
for (var p in toMerge) {
base[p] = toMerge[p];
}
return base;
},
_mergeDeep = function _mergeDeep(base, toMerge) {
for (var p in toMerge) {
p !== "__proto__" && p !== "constructor" && p !== "prototype" && (base[p] = _isObject(toMerge[p]) ? _mergeDeep(base[p] || (base[p] = {}), toMerge[p]) : toMerge[p]);
}
return base;
},
_copyExcluding = function _copyExcluding(obj, excluding) {
var copy = {},
p;
for (p in obj) {
p in excluding || (copy[p] = obj[p]);
}
return copy;
},
_inheritDefaults = function _inheritDefaults(vars) {
var parent = vars.parent || _globalTimeline,
func = vars.keyframes ? _setKeyframeDefaults : _setDefaults;
if (_isNotFalse(vars.inherit)) {
while (parent) {
func(vars, parent.vars.defaults);
parent = parent.parent || parent._dp;
}
}
return vars;
},
_arraysMatch = function _arraysMatch(a1, a2) {
var i = a1.length,
match = i === a2.length;
while (match && i-- && a1[i] === a2[i]) {}
return i < 0;
},
_addLinkedListItem = function _addLinkedListItem(parent, child, firstProp, lastProp, sortBy) {
if (firstProp === void 0) {
firstProp = "_first";
}
if (lastProp === void 0) {
lastProp = "_last";
}
var prev = parent[lastProp],
t;
if (sortBy) {
t = child[sortBy];
while (prev && prev[sortBy] > t) {
prev = prev._prev;
}
}
if (prev) {
child._next = prev._next;
prev._next = child;
} else {
child._next = parent[firstProp];
parent[firstProp] = child;
}
if (child._next) {
child._next._prev = child;
} else {
parent[lastProp] = child;
}
child._prev = prev;
child.parent = child._dp = parent;
return child;
},
_removeLinkedListItem = function _removeLinkedListItem(parent, child, firstProp, lastProp) {
if (firstProp === void 0) {
firstProp = "_first";
}
if (lastProp === void 0) {
lastProp = "_last";
}
var prev = child._prev,
next = child._next;
if (prev) {
prev._next = next;
} else if (parent[firstProp] === child) {
parent[firstProp] = next;
}
if (next) {
next._prev = prev;
} else if (parent[lastProp] === child) {
parent[lastProp] = prev;
}
child._next = child._prev = child.parent = null;
},
_removeFromParent = function _removeFromParent(child, onlyIfParentHasAutoRemove) {
child.parent && (!onlyIfParentHasAutoRemove || child.parent.autoRemoveChildren) && child.parent.remove(child);
child._act = 0;
},
_uncache = function _uncache(animation, child) {
if (animation && (!child || child._end > animation._dur || child._start < 0)) {
var a = animation;
while (a) {
a._dirty = 1;
a = a.parent;
}
}
return animation;
},
_recacheAncestors = function _recacheAncestors(animation) {
var parent = animation.parent;
while (parent && parent.parent) {
parent._dirty = 1;
parent.totalDuration();
parent = parent.parent;
}
return animation;
},
_hasNoPausedAncestors = function _hasNoPausedAncestors(animation) {
return !animation || animation._ts && _hasNoPausedAncestors(animation.parent);
},
_elapsedCycleDuration = function _elapsedCycleDuration(animation) {
return animation._repeat ? _animationCycle(animation._tTime, animation = animation.duration() + animation._rDelay) * animation : 0;
},
_animationCycle = function _animationCycle(tTime, cycleDuration) {
var whole = Math.floor(tTime /= cycleDuration);
return tTime && whole === tTime ? whole - 1 : whole;
},
_parentToChildTotalTime = function _parentToChildTotalTime(parentTime, child) {
return (parentTime - child._start) * child._ts + (child._ts >= 0 ? 0 : child._dirty ? child.totalDuration() : child._tDur);
},
_setEnd = function _setEnd(animation) {
return animation._end = _round(animation._start + (animation._tDur / Math.abs(animation._ts || animation._rts || _tinyNum) || 0));
},
_alignPlayhead = function _alignPlayhead(animation, totalTime) {
var parent = animation._dp;
if (parent && parent.smoothChildTiming && animation._ts) {
animation._start = _round(parent._time - (animation._ts > 0 ? totalTime / animation._ts : ((animation._dirty ? animation.totalDuration() : animation._tDur) - totalTime) / -animation._ts));
_setEnd(animation);
parent._dirty || _uncache(parent, animation);
}
return animation;
},
_postAddChecks = function _postAddChecks(timeline, child) {
var t;
if (child._time || child._initted && !child._dur) {
t = _parentToChildTotalTime(timeline.rawTime(), child);
if (!child._dur || _clamp(0, child.totalDuration(), t) - child._tTime > _tinyNum) {
child.render(t, true);
}
}
if (_uncache(timeline, child)._dp && timeline._initted && timeline._time >= timeline._dur && timeline._ts) {
if (timeline._dur < timeline.duration()) {
t = timeline;
while (t._dp) {
t.rawTime() >= 0 && t.totalTime(t._tTime);
t = t._dp;
}
}
timeline._zTime = -_tinyNum;
}
},
_addToTimeline = function _addToTimeline(timeline, child, position, skipChecks) {
child.parent && _removeFromParent(child);
child._start = _round(position + child._delay);
child._end = _round(child._start + (child.totalDuration() / Math.abs(child.timeScale()) || 0));
_addLinkedListItem(timeline, child, "_first", "_last", timeline._sort ? "_start" : 0);
timeline._recent = child;
skipChecks || _postAddChecks(timeline, child);
return timeline;
},
_scrollTrigger = function _scrollTrigger(animation, trigger) {
return (_globals.ScrollTrigger || _missingPlugin("scrollTrigger", trigger)) && _globals.ScrollTrigger.create(trigger, animation);
},
_attemptInitTween = function _attemptInitTween(tween, totalTime, force, suppressEvents) {
_initTween(tween, totalTime);
if (!tween._initted) {
return 1;
}
if (!force && tween._pt && (tween._dur && tween.vars.lazy !== false || !tween._dur && tween.vars.lazy) && _lastRenderedFrame !== _ticker.frame) {
_lazyTweens.push(tween);
tween._lazy = [totalTime, suppressEvents];
return 1;
}
},
_parentPlayheadIsBeforeStart = function _parentPlayheadIsBeforeStart(_ref) {
var parent = _ref.parent;
return parent && parent._ts && parent._initted && !parent._lock && (parent.rawTime() < 0 || _parentPlayheadIsBeforeStart(parent));
},
_renderZeroDurationTween = function _renderZeroDurationTween(tween, totalTime, suppressEvents, force) {
var prevRatio = tween.ratio,
ratio = totalTime < 0 || !totalTime && (!tween._start && _parentPlayheadIsBeforeStart(tween) || (tween._ts < 0 || tween._dp._ts < 0) && tween.data !== "isFromStart" && tween.data !== "isStart") ? 0 : 1,
repeatDelay = tween._rDelay,
tTime = 0,
pt,
iteration,
prevIteration;
if (repeatDelay && tween._repeat) {
tTime = _clamp(0, tween._tDur, totalTime);
iteration = _animationCycle(tTime, repeatDelay);
prevIteration = _animationCycle(tween._tTime, repeatDelay);
tween._yoyo && iteration & 1 && (ratio = 1 - ratio);
if (iteration !== prevIteration) {
prevRatio = 1 - ratio;
tween.vars.repeatRefresh && tween._initted && tween.invalidate();
}
}
if (ratio !== prevRatio || force || tween._zTime === _tinyNum || !totalTime && tween._zTime) {
if (!tween._initted && _attemptInitTween(tween, totalTime, force, suppressEvents)) {
return;
}
prevIteration = tween._zTime;
tween._zTime = totalTime || (suppressEvents ? _tinyNum : 0);
suppressEvents || (suppressEvents = totalTime && !prevIteration);
tween.ratio = ratio;
tween._from && (ratio = 1 - ratio);
tween._time = 0;
tween._tTime = tTime;
pt = tween._pt;
while (pt) {
pt.r(ratio, pt.d);
pt = pt._next;
}
tween._startAt && totalTime < 0 && tween._startAt.render(totalTime, true, true);
tween._onUpdate && !suppressEvents && _callback(tween, "onUpdate");
tTime && tween._repeat && !suppressEvents && tween.parent && _callback(tween, "onRepeat");
if ((totalTime >= tween._tDur || totalTime < 0) && tween.ratio === ratio) {
ratio && _removeFromParent(tween, 1);
if (!suppressEvents) {
_callback(tween, ratio ? "onComplete" : "onReverseComplete", true);
tween._prom && tween._prom();
}
}
} else if (!tween._zTime) {
tween._zTime = totalTime;
}
},
_findNextPauseTween = function _findNextPauseTween(animation, prevTime, time) {
var child;
if (time > prevTime) {
child = animation._first;
while (child && child._start <= time) {
if (!child._dur && child.data === "isPause" && child._start > prevTime) {
return child;
}
child = child._next;
}
} else {
child = animation._last;
while (child && child._start >= time) {
if (!child._dur && child.data === "isPause" && child._start < prevTime) {
return child;
}
child = child._prev;
}
}
},
_setDuration = function _setDuration(animation, duration, skipUncache, leavePlayhead) {
var repeat = animation._repeat,
dur = _round(duration) || 0,
totalProgress = animation._tTime / animation._tDur;
totalProgress && !leavePlayhead && (animation._time *= dur / animation._dur);
animation._dur = dur;
animation._tDur = !repeat ? dur : repeat < 0 ? 1e10 : _round(dur * (repeat + 1) + animation._rDelay * repeat);
totalProgress && !leavePlayhead ? _alignPlayhead(animation, animation._tTime = animation._tDur * totalProgress) : animation.parent && _setEnd(animation);
skipUncache || _uncache(animation.parent, animation);
return animation;
},
_onUpdateTotalDuration = function _onUpdateTotalDuration(animation) {
return animation instanceof Timeline ? _uncache(animation) : _setDuration(animation, animation._dur);
},
_zeroPosition = {
_start: 0,
endTime: _emptyFunc
},
_parsePosition = function _parsePosition(animation, position) {
var labels = animation.labels,
recent = animation._recent || _zeroPosition,
clippedDuration = animation.duration() >= _bigNum ? recent.endTime(false) : animation._dur,
i,
offset;
if (_isString(position) && (isNaN(position) || position in labels)) {
i = position.charAt(0);
if (i === "<" || i === ">") {
return (i === "<" ? recent._start : recent.endTime(recent._repeat >= 0)) + (parseFloat(position.substr(1)) || 0);
}
i = position.indexOf("=");
if (i < 0) {
position in labels || (labels[position] = clippedDuration);
return labels[position];
}
offset = +(position.charAt(i - 1) + position.substr(i + 1));
return i > 1 ? _parsePosition(animation, position.substr(0, i - 1)) + offset : clippedDuration + offset;
}
return position == null ? clippedDuration : +position;
},
_conditionalReturn = function _conditionalReturn(value, func) {
return value || value === 0 ? func(value) : func;
},
_clamp = function _clamp(min, max, value) {
return value < min ? min : value > max ? max : value;
},
getUnit = function getUnit(value) {
if (typeof value !== "string") {
return "";
}
var v = _unitExp.exec(value);
return v ? value.substr(v.index + v[0].length) : "";
},
clamp = function clamp(min, max, value) {
return _conditionalReturn(value, function (v) {
return _clamp(min, max, v);
});
},
_slice = [].slice,
_isArrayLike = function _isArrayLike(value, nonEmpty) {
return value && _isObject(value) && "length" in value && (!nonEmpty && !value.length || value.length - 1 in value && _isObject(value[0])) && !value.nodeType && value !== _win;
},
_flatten = function _flatten(ar, leaveStrings, accumulator) {
if (accumulator === void 0) {
accumulator = [];
}
return ar.forEach(function (value) {
var _accumulator;
return _isString(value) && !leaveStrings || _isArrayLike(value, 1) ? (_accumulator = accumulator).push.apply(_accumulator, toArray(value)) : accumulator.push(value);
}) || accumulator;
},
toArray = function toArray(value, leaveStrings) {
return _isString(value) && !leaveStrings && (_coreInitted || !_wake()) ? _slice.call(_doc.querySelectorAll(value), 0) : _isArray(value) ? _flatten(value, leaveStrings) : _isArrayLike(value) ? _slice.call(value, 0) : value ? [value] : [];
},
shuffle = function shuffle(a) {
return a.sort(function () {
return .5 - Math.random();
});
},
distribute = function distribute(v) {
if (_isFunction(v)) {
return v;
}
var vars = _isObject(v) ? v : {
each: v
},
ease = _parseEase(vars.ease),
from = vars.from || 0,
base = parseFloat(vars.base) || 0,
cache = {},
isDecimal = from > 0 && from < 1,
ratios = isNaN(from) || isDecimal,
axis = vars.axis,
ratioX = from,
ratioY = from;
if (_isString(from)) {
ratioX = ratioY = {
center: .5,
edges: .5,
end: 1
}[from] || 0;
} else if (!isDecimal && ratios) {
ratioX = from[0];
ratioY = from[1];
}
return function (i, target, a) {
var l = (a || vars).length,
distances = cache[l],
originX,
originY,
x,
y,
d,
j,
max,
min,
wrapAt;
if (!distances) {
wrapAt = vars.grid === "auto" ? 0 : (vars.grid || [1, _bigNum])[1];
if (!wrapAt) {
max = -_bigNum;
while (max < (max = a[wrapAt++].getBoundingClientRect().left) && wrapAt < l) {}
wrapAt--;
}
distances = cache[l] = [];
originX = ratios ? Math.min(wrapAt, l) * ratioX - .5 : from % wrapAt;
originY = ratios ? l * ratioY / wrapAt - .5 : from / wrapAt | 0;
max = 0;
min = _bigNum;
for (j = 0; j < l; j++) {
x = j % wrapAt - originX;
y = originY - (j / wrapAt | 0);
distances[j] = d = !axis ? _sqrt(x * x + y * y) : Math.abs(axis === "y" ? y : x);
d > max && (max = d);
d < min && (min = d);
}
from === "random" && shuffle(distances);
distances.max = max - min;
distances.min = min;
distances.v = l = (parseFloat(vars.amount) || parseFloat(vars.each) * (wrapAt > l ? l - 1 : !axis ? Math.max(wrapAt, l / wrapAt) : axis === "y" ? l / wrapAt : wrapAt) || 0) * (from === "edges" ? -1 : 1);
distances.b = l < 0 ? base - l : base;
distances.u = getUnit(vars.amount || vars.each) || 0;
ease = ease && l < 0 ? _invertEase(ease) : ease;
}
l = (distances[i] - distances.min) / distances.max || 0;
return _round(distances.b + (ease ? ease(l) : l) * distances.v) + distances.u;
};
},
_roundModifier = function _roundModifier(v) {
var p = v < 1 ? Math.pow(10, (v + "").length - 2) : 1;
return function (raw) {
var n = Math.round(parseFloat(raw) / v) * v * p;
return (n - n % 1) / p + (_isNumber(raw) ? 0 : getUnit(raw));
};
},
snap = function snap(snapTo, value) {
var isArray = _isArray(snapTo),
radius,
is2D;
if (!isArray && _isObject(snapTo)) {
radius = isArray = snapTo.radius || _bigNum;
if (snapTo.values) {
snapTo = toArray(snapTo.values);
if (is2D = !_isNumber(snapTo[0])) {
radius *= radius;
}
} else {
snapTo = _roundModifier(snapTo.increment);
}
}
return _conditionalReturn(value, !isArray ? _roundModifier(snapTo) : _isFunction(snapTo) ? function (raw) {
is2D = snapTo(raw);
return Math.abs(is2D - raw) <= radius ? is2D : raw;
} : function (raw) {
var x = parseFloat(is2D ? raw.x : raw),
y = parseFloat(is2D ? raw.y : 0),
min = _bigNum,
closest = 0,
i = snapTo.length,
dx,
dy;
while (i--) {
if (is2D) {
dx = snapTo[i].x - x;
dy = snapTo[i].y - y;
dx = dx * dx + dy * dy;
} else {
dx = Math.abs(snapTo[i] - x);
}
if (dx < min) {
min = dx;
closest = i;
}
}
closest = !radius || min <= radius ? snapTo[closest] : raw;
return is2D || closest === raw || _isNumber(raw) ? closest : closest + getUnit(raw);
});
},
random = function random(min, max, roundingIncrement, returnFunction) {
return _conditionalReturn(_isArray(min) ? !max : roundingIncrement === true ? !!(roundingIncrement = 0) : !returnFunction, function () {
return _isArray(min) ? min[~~(Math.random() * min.length)] : (roundingIncrement = roundingIncrement || 1e-5) && (returnFunction = roundingIncrement < 1 ? Math.pow(10, (roundingIncrement + "").length - 2) : 1) && Math.floor(Math.round((min - roundingIncrement / 2 + Math.random() * (max - min + roundingIncrement * .99)) / roundingIncrement) * roundingIncrement * returnFunction) / returnFunction;
});
},
pipe = function pipe() {
for (var _len = arguments.length, functions = new Array(_len), _key = 0; _key < _len; _key++) {
functions[_key] = arguments[_key];
}
return function (value) {
return functions.reduce(function (v, f) {
return f(v);
}, value);
};
},
unitize = function unitize(func, unit) {
return function (value) {
return func(parseFloat(value)) + (unit || getUnit(value));
};
},
normalize = function normalize(min, max, value) {
return mapRange(min, max, 0, 1, value);
},
_wrapArray = function _wrapArray(a, wrapper, value) {
return _conditionalReturn(value, function (index) {
return a[~~wrapper(index)];
});
},
wrap = function wrap(min, max, value) {
var range = max - min;
return _isArray(min) ? _wrapArray(min, wrap(0, min.length), max) : _conditionalReturn(value, function (value) {
return (range + (value - min) % range) % range + min;
});
},
wrapYoyo = function wrapYoyo(min, max, value) {
var range = max - min,
total = range * 2;
return _isArray(min) ? _wrapArray(min, wrapYoyo(0, min.length - 1), max) : _conditionalReturn(value, function (value) {
value = (total + (value - min) % total) % total || 0;
return min + (value > range ? total - value : value);
});
},
_replaceRandom = function _replaceRandom(value) {
var prev = 0,
s = "",
i,
nums,
end,
isArray;
while (~(i = value.indexOf("random(", prev))) {
end = value.indexOf(")", i);
isArray = value.charAt(i + 7) === "[";
nums = value.substr(i + 7, end - i - 7).match(isArray ? _delimitedValueExp : _strictNumExp);
s += value.substr(prev, i - prev) + random(isArray ? nums : +nums[0], isArray ? 0 : +nums[1], +nums[2] || 1e-5);
prev = end + 1;
}
return s + value.substr(prev, value.length - prev);
},
mapRange = function mapRange(inMin, inMax, outMin, outMax, value) {
var inRange = inMax - inMin,
outRange = outMax - outMin;
return _conditionalReturn(value, function (value) {
return outMin + ((value - inMin) / inRange * outRange || 0);
});
},
interpolate = function interpolate(start, end, progress, mutate) {
var func = isNaN(start + end) ? 0 : function (p) {
return (1 - p) * start + p * end;
};
if (!func) {
var isString = _isString(start),
master = {},
p,
i,
interpolators,
l,
il;
progress === true && (mutate = 1) && (progress = null);
if (isString) {
start = {
p: start
};
end = {
p: end
};
} else if (_isArray(start) && !_isArray(end)) {
interpolators = [];
l = start.length;
il = l - 2;
for (i = 1; i < l; i++) {
interpolators.push(interpolate(start[i - 1], start[i]));
}
l--;
func = function func(p) {
p *= l;
var i = Math.min(il, ~~p);
return interpolators[i](p - i);
};
progress = end;
} else if (!mutate) {
start = _merge(_isArray(start) ? [] : {}, start);
}
if (!interpolators) {
for (p in end) {
_addPropTween.call(master, start, p, "get", end[p]);
}
func = function func(p) {
return _renderPropTweens(p, master) || (isString ? start.p : start);
};
}
}
return _conditionalReturn(progress, func);
},
_getLabelInDirection = function _getLabelInDirection(timeline, fromTime, backward) {
var labels = timeline.labels,
min = _bigNum,
p,
distance,
label;
for (p in labels) {
distance = labels[p] - fromTime;
if (distance < 0 === !!backward && distance && min > (distance = Math.abs(distance))) {
label = p;
min = distance;
}
}
return label;
},
_callback = function _callback(animation, type, executeLazyFirst) {
var v = animation.vars,
callback = v[type],
params,
scope;
if (!callback) {
return;
}
params = v[type + "Params"];
scope = v.callbackScope || animation;
executeLazyFirst && _lazyTweens.length && _lazyRender();
return params ? callback.apply(scope, params) : callback.call(scope);
},
_interrupt = function _interrupt(animation) {
_removeFromParent(animation);
animation.scrollTrigger && animation.scrollTrigger.kill(false);
animation.progress() < 1 && _callback(animation, "onInterrupt");
return animation;
},
_quickTween,
_createPlugin = function _createPlugin(config) {
config = !config.name && config["default"] || config;
var name = config.name,
isFunc = _isFunction(config),
Plugin = name && !isFunc && config.init ? function () {
this._props = [];
} : config,
instanceDefaults = {
init: _emptyFunc,
render: _renderPropTweens,
add: _addPropTween,
kill: _killPropTweensOf,
modifier: _addPluginModifier,
rawVars: 0
},
statics = {
targetTest: 0,
get: 0,
getSetter: _getSetter,
aliases: {},
register: 0
};
_wake();
if (config !== Plugin) {
if (_plugins[name]) {
return;
}
_setDefaults(Plugin, _setDefaults(_copyExcluding(config, instanceDefaults), statics));
_merge(Plugin.prototype, _merge(instanceDefaults, _copyExcluding(config, statics)));
_plugins[Plugin.prop = name] = Plugin;
if (config.targetTest) {
_harnessPlugins.push(Plugin);
_reservedProps[name] = 1;
}
name = (name === "css" ? "CSS" : name.charAt(0).toUpperCase() + name.substr(1)) + "Plugin";
}
_addGlobal(name, Plugin);
config.register && config.register(gsap, Plugin, PropTween);
},
_255 = 255,
_colorLookup = {
aqua: [0, _255, _255],
lime: [0, _255, 0],
silver: [192, 192, 192],
black: [0, 0, 0],
maroon: [128, 0, 0],
teal: [0, 128, 128],
blue: [0, 0, _255],
navy: [0, 0, 128],
white: [_255, _255, _255],
olive: [128, 128, 0],
yellow: [_255, _255, 0],
orange: [_255, 165, 0],
gray: [128, 128, 128],
purple: [128, 0, 128],
green: [0, 128, 0],
red: [_255, 0, 0],
pink: [_255, 192, 203],
cyan: [0, _255, _255],
transparent: [_255, _255, _255, 0]
},
_hue = function _hue(h, m1, m2) {
h = h < 0 ? h + 1 : h > 1 ? h - 1 : h;
return (h * 6 < 1 ? m1 + (m2 - m1) * h * 6 : h < .5 ? m2 : h * 3 < 2 ? m1 + (m2 - m1) * (2 / 3 - h) * 6 : m1) * _255 + .5 | 0;
},
splitColor = function splitColor(v, toHSL, forceAlpha) {
var a = !v ? _colorLookup.black : _isNumber(v) ? [v >> 16, v >> 8 & _255, v & _255] : 0,
r,
g,
b,
h,
s,
l,
max,
min,
d,
wasHSL;
if (!a) {
if (v.substr(-1) === ",") {
v = v.substr(0, v.length - 1);
}
if (_colorLookup[v]) {
a = _colorLookup[v];
} else if (v.charAt(0) === "#") {
if (v.length < 6) {
r = v.charAt(1);
g = v.charAt(2);
b = v.charAt(3);
v = "#" + r + r + g + g + b + b + (v.length === 5 ? v.charAt(4) + v.charAt(4) : "");
}
if (v.length === 9) {
a = parseInt(v.substr(1, 6), 16);
return [a >> 16, a >> 8 & _255, a & _255, parseInt(v.substr(7), 16) / 255];
}
v = parseInt(v.substr(1), 16);
a = [v >> 16, v >> 8 & _255, v & _255];
} else if (v.substr(0, 3) === "hsl") {
a = wasHSL = v.match(_strictNumExp);
if (!toHSL) {
h = +a[0] % 360 / 360;
s = +a[1] / 100;
l = +a[2] / 100;
g = l <= .5 ? l * (s + 1) : l + s - l * s;
r = l * 2 - g;
a.length > 3 && (a[3] *= 1);
a[0] = _hue(h + 1 / 3, r, g);
a[1] = _hue(h, r, g);
a[2] = _hue(h - 1 / 3, r, g);
} else if (~v.indexOf("=")) {
a = v.match(_numExp);
forceAlpha && a.length < 4 && (a[3] = 1);
return a;
}
} else {
a = v.match(_strictNumExp) || _colorLookup.transparent;
}
a = a.map(Number);
}
if (toHSL && !wasHSL) {
r = a[0] / _255;
g = a[1] / _255;
b = a[2] / _255;
max = Math.max(r, g, b);
min = Math.min(r, g, b);
l = (max + min) / 2;
if (max === min) {
h = s = 0;
} else {
d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
h = max === r ? (g - b) / d + (g < b ? 6 : 0) : max === g ? (b - r) / d + 2 : (r - g) / d + 4;
h *= 60;
}
a[0] = ~~(h + .5);
a[1] = ~~(s * 100 + .5);
a[2] = ~~(l * 100 + .5);
}
forceAlpha && a.length < 4 && (a[3] = 1);
return a;
},
_colorOrderData = function _colorOrderData(v) {
var values = [],
c = [],
i = -1;
v.split(_colorExp).forEach(function (v) {
var a = v.match(_numWithUnitExp) || [];
values.push.apply(values, a);
c.push(i += a.length + 1);
});
values.c = c;
return values;
},
_formatColors = function _formatColors(s, toHSL, orderMatchData) {
var result = "",
colors = (s + result).match(_colorExp),
type = toHSL ? "hsla(" : "rgba(",
i = 0,
c,
shell,
d,
l;
if (!colors) {
return s;
}
colors = colors.map(function (color) {
return (color = splitColor(color, toHSL, 1)) && type + (toHSL ? color[0] + "," + color[1] + "%," + color[2] + "%," + color[3] : color.join(",")) + ")";
});
if (orderMatchData) {
d = _colorOrderData(s);
c = orderMatchData.c;
if (c.join(result) !== d.c.join(result)) {
shell = s.replace(_colorExp, "1").split(_numWithUnitExp);
l = shell.length - 1;
for (; i < l; i++) {
result += shell[i] + (~c.indexOf(i) ? colors.shift() || type + "0,0,0,0)" : (d.length ? d : colors.length ? colors : orderMatchData).shift());
}
}
}
if (!shell) {
shell = s.split(_colorExp);
l = shell.length - 1;
for (; i < l; i++) {
result += shell[i] + colors[i];
}
}
return result + shell[l];
},
_colorExp = function () {
var s = "(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3,4}){1,2}\\b",
p;
for (p in _colorLookup) {
s += "|" + p + "\\b";
}
return new RegExp(s + ")", "gi");
}(),
_hslExp = /hsl[a]?\(/,
_colorStringFilter = function _colorStringFilter(a) {
var combined = a.join(" "),
toHSL;
_colorExp.lastIndex = 0;
if (_colorExp.test(combined)) {
toHSL = _hslExp.test(combined);
a[1] = _formatColors(a[1], toHSL);
a[0] = _formatColors(a[0], toHSL, _colorOrderData(a[1]));
return true;
}
},
_tickerActive,
_ticker = function () {
var _getTime = Date.now,
_lagThreshold = 500,
_adjustedLag = 33,
_startTime = _getTime(),
_lastUpdate = _startTime,
_gap = 1000 / 240,
_nextTime = _gap,
_listeners = [],
_id,
_req,
_raf,
_self,
_delta,
_i,
_tick = function _tick(v) {
var elapsed = _getTime() - _lastUpdate,
manual = v === true,
overlap,
dispatch,
time,
frame;
elapsed > _lagThreshold && (_startTime += elapsed - _adjustedLag);
_lastUpdate += elapsed;
time = _lastUpdate - _startTime;
overlap = time - _nextTime;
if (overlap > 0 || manual) {
frame = ++_self.frame;
_delta = time - _self.time * 1000;
_self.time = time = time / 1000;
_nextTime += overlap + (overlap >= _gap ? 4 : _gap - overlap);
dispatch = 1;
}
manual || (_id = _req(_tick));
if (dispatch) {
for (_i = 0; _i < _listeners.length; _i++) {
_listeners[_i](time, _delta, frame, v);
}
}
};
_self = {
time: 0,
frame: 0,
tick: function tick() {
_tick(true);
},
deltaRatio: function deltaRatio(fps) {
return _delta / (1000 / (fps || 60));
},
wake: function wake() {
if (_coreReady) {
if (!_coreInitted && _windowExists()) {
_win = _coreInitted = window;
_doc = _win.document || {};
_globals.gsap = gsap;
(_win.gsapVersions || (_win.gsapVersions = [])).push(gsap.version);
_install(_installScope || _win.GreenSockGlobals || !_win.gsap && _win || {});
_raf = _win.requestAnimationFrame;
}
_id && _self.sleep();
_req = _raf || function (f) {
return setTimeout(f, _nextTime - _self.time * 1000 + 1 | 0);
};
_tickerActive = 1;
_tick(2);
}
},
sleep: function sleep() {
(_raf ? _win.cancelAnimationFrame : clearTimeout)(_id);
_tickerActive = 0;
_req = _emptyFunc;
},
lagSmoothing: function lagSmoothing(threshold, adjustedLag) {
_lagThreshold = threshold || 1 / _tinyNum;
_adjustedLag = Math.min(adjustedLag, _lagThreshold, 0);
},
fps: function fps(_fps) {
_gap = 1000 / (_fps || 240);
_nextTime = _self.time * 1000 + _gap;
},
add: function add(callback) {
_listeners.indexOf(callback) < 0 && _listeners.push(callback);
_wake();
},
remove: function remove(callback) {
var i;
~(i = _listeners.indexOf(callback)) && _listeners.splice(i, 1) && _i >= i && _i--;
},
_listeners: _listeners
};
return _self;
}(),
_wake = function _wake() {
return !_tickerActive && _ticker.wake();
},
_easeMap = {},
_customEaseExp = /^[\d.\-M][\d.\-,\s]/,
_quotesExp = /["']/g,
_parseObjectInString = function _parseObjectInString(value) {
var obj = {},
split = value.substr(1, value.length - 3).split(":"),
key = split[0],
i = 1,
l = split.length,
index,
val,
parsedVal;
for (; i < l; i++) {
val = split[i];
index = i !== l - 1 ? val.lastIndexOf(",") : val.length;
parsedVal = val.substr(0, index);
obj[key] = isNaN(parsedVal) ? parsedVal.replace(_quotesExp, "").trim() : +parsedVal;
key = val.substr(index + 1).trim();
}
return obj;
},
_valueInParentheses = function _valueInParentheses(value) {
var open = value.indexOf("(") + 1,
close = value.indexOf(")"),
nested = value.indexOf("(", open);
return value.substring(open, ~nested && nested < close ? value.indexOf(")", close + 1) : close);
},
_configEaseFromString = function _configEaseFromString(name) {
var split = (name + "").split("("),
ease = _easeMap[split[0]];
return ease && split.length > 1 && ease.config ? ease.config.apply(null, ~name.indexOf("{") ? [_parseObjectInString(split[1])] : _valueInParentheses(name).split(",").map(_numericIfPossible)) : _easeMap._CE && _customEaseExp.test(name) ? _easeMap._CE("", name) : ease;
},
_invertEase = function _invertEase(ease) {
return function (p) {
return 1 - ease(1 - p);
};
},
_propagateYoyoEase = function _propagateYoyoEase(timeline, isYoyo) {
var child = timeline._first,
ease;
while (child) {
if (child instanceof Timeline) {
_propagateYoyoEase(child, isYoyo);
} else if (child.vars.yoyoEase && (!child._yoyo || !child._repeat) && child._yoyo !== isYoyo) {
if (child.timeline) {
_propagateYoyoEase(child.timeline, isYoyo);
} else {
ease = child._ease;
child._ease = child._yEase;
child._yEase = ease;
child._yoyo = isYoyo;
}
}
child = child._next;
}
},
_parseEase = function _parseEase(ease, defaultEase) {
return !ease ? defaultEase : (_isFunction(ease) ? ease : _easeMap[ease] || _configEaseFromString(ease)) || defaultEase;
},
_insertEase = function _insertEase(names, easeIn, easeOut, easeInOut) {
if (easeOut === void 0) {
easeOut = function easeOut(p) {
return 1 - easeIn(1 - p);
};
}
if (easeInOut === void 0) {
easeInOut = function easeInOut(p) {
return p < .5 ? easeIn(p * 2) / 2 : 1 - easeIn((1 - p) * 2) / 2;
};
}
var ease = {
easeIn: easeIn,
easeOut: easeOut,
easeInOut: easeInOut
},
lowercaseName;
_forEachName(names, function (name) {
_easeMap[name] = _globals[name] = ease;
_easeMap[lowercaseName = name.toLowerCase()] = easeOut;
for (var p in ease) {
_easeMap[lowercaseName + (p === "easeIn" ? ".in" : p === "easeOut" ? ".out" : ".inOut")] = _easeMap[name + "." + p] = ease[p];
}
});
return ease;
},
_easeInOutFromOut = function _easeInOutFromOut(easeOut) {
return function (p) {
return p < .5 ? (1 - easeOut(1 - p * 2)) / 2 : .5 + easeOut((p - .5) * 2) / 2;
};
},
_configElastic = function _configElastic(type, amplitude, period) {
var p1 = amplitude >= 1 ? amplitude : 1,
p2 = (period || (type ? .3 : .45)) / (amplitude < 1 ? amplitude : 1),
p3 = p2 / _2PI * (Math.asin(1 / p1) || 0),
easeOut = function easeOut(p) {
return p === 1 ? 1 : p1 * Math.pow(2, -10 * p) * _sin((p - p3) * p2) + 1;
},
ease = type === "out" ? easeOut : type === "in" ? function (p) {
return 1 - easeOut(1 - p);
} : _easeInOutFromOut(easeOut);
p2 = _2PI / p2;
ease.config = function (amplitude, period) {
return _configElastic(type, amplitude, period);
};
return ease;
},
_configBack = function _configBack(type, overshoot) {
if (overshoot === void 0) {
overshoot = 1.70158;
}
var easeOut = function easeOut(p) {
return p ? --p * p * ((overshoot + 1) * p + overshoot) + 1 : 0;
},
ease = type === "out" ? easeOut : type === "in" ? function (p) {
return 1 - easeOut(1 - p);
} : _easeInOutFromOut(easeOut);
ease.config = function (overshoot) {
return _configBack(type, overshoot);
};
return ease;
};
_forEachName("Linear,Quad,Cubic,Quart,Quint,Strong", function (name, i) {
var power = i < 5 ? i + 1 : i;
_insertEase(name + ",Power" + (power - 1), i ? function (p) {
return Math.pow(p, power);
} : function (p) {
return p;
}, function (p) {
return 1 - Math.pow(1 - p, power);
}, function (p) {
return p < .5 ? Math.pow(p * 2, power) / 2 : 1 - Math.pow((1 - p) * 2, power) / 2;
});
});
_easeMap.Linear.easeNone = _easeMap.none = _easeMap.Linear.easeIn;
_insertEase("Elastic", _configElastic("in"), _configElastic("out"), _configElastic());
(function (n, c) {
var n1 = 1 / c,
n2 = 2 * n1,
n3 = 2.5 * n1,
easeOut = function easeOut(p) {
return p < n1 ? n * p * p : p < n2 ? n * Math.pow(p - 1.5 / c, 2) + .75 : p < n3 ? n * (p -= 2.25 / c) * p + .9375 : n * Math.pow(p - 2.625 / c, 2) + .984375;
};
_insertEase("Bounce", function (p) {
return 1 - easeOut(1 - p);
}, easeOut);
})(7.5625, 2.75);
_insertEase("Expo", function (p) {
return p ? Math.pow(2, 10 * (p - 1)) : 0;
});
_insertEase("Circ", function (p) {
return -(_sqrt(1 - p * p) - 1);
});
_insertEase("Sine", function (p) {
return p === 1 ? 1 : -_cos(p * _HALF_PI) + 1;
});
_insertEase("Back", _configBack("in"), _configBack("out"), _configBack());
_easeMap.SteppedEase = _easeMap.steps = _globals.SteppedEase = {
config: function config(steps, immediateStart) {
if (steps === void 0) {
steps = 1;
}
var p1 = 1 / steps,
p2 = steps + (immediateStart ? 0 : 1),
p3 = immediateStart ? 1 : 0,
max = 1 - _tinyNum;
return function (p) {
return ((p2 * _clamp(0, max, p) | 0) + p3) * p1;
};
}
};
_defaults.ease = _easeMap["quad.out"];
_forEachName("onComplete,onUpdate,onStart,onRepeat,onReverseComplete,onInterrupt", function (name) {
return _callbackNames += name + "," + name + "Params,";
});
var GSCache = function GSCache(target, harness) {
this.id = _gsID++;
target._gsap = this;
this.target = target;
this.harness = harness;
this.get = harness ? harness.get : _getProperty;
this.set = harness ? harness.getSetter : _getSetter;
};
var Animation = function () {
function Animation(vars, time) {
var parent = vars.parent || _globalTimeline;
this.vars = vars;
this._delay = +vars.delay || 0;
if (this._repeat = vars.repeat === Infinity ? -2 : vars.repeat || 0) {
this._rDelay = vars.repeatDelay || 0;
this._yoyo = !!vars.yoyo || !!vars.yoyoEase;
}
this._ts = 1;
_setDuration(this, +vars.duration, 1, 1);
this.data = vars.data;
_tickerActive || _ticker.wake();
parent && _addToTimeline(parent, this, time || time === 0 ? time : parent._time, 1);
vars.reversed && this.reverse();
vars.paused && this.paused(true);
}
var _proto = Animation.prototype;
_proto.delay = function delay(value) {
if (value || value === 0) {
this.parent && this.parent.smoothChildTiming && this.startTime(this._start + value - this._delay);
this._delay = value;
return this;
}
return this._delay;
};
_proto.duration = function duration(value) {
return arguments.length ? this.totalDuration(this._repeat > 0 ? value + (value + this._rDelay) * this._repeat : value) : this.totalDuration() && this._dur;
};
_proto.totalDuration = function totalDuration(value) {
if (!arguments.length) {
return this._tDur;
}
this._dirty = 0;
return _setDuration(this, this._repeat < 0 ? value : (value - this._repeat * this._rDelay) / (this._repeat + 1));
};
_proto.totalTime = function totalTime(_totalTime, suppressEvents) {
_wake();
if (!arguments.length) {
return this._tTime;
}
var parent = this._dp;
if (parent && parent.smoothChildTiming && this._ts) {
_alignPlayhead(this, _totalTime);
!parent._dp || parent.parent || _postAddChecks(parent, this);
while (parent.parent) {
if (parent.parent._time !== parent._start + (parent._ts >= 0 ? parent._tTime / parent._ts : (parent.totalDuration() - parent._tTime) / -parent._ts)) {
parent.totalTime(parent._tTime, true);
}
parent = parent.parent;
}
if (!this.parent && this._dp.autoRemoveChildren && (this._ts > 0 && _totalTime < this._tDur || this._ts < 0 && _totalTime > 0 || !this._tDur && !_totalTime)) {
_addToTimeline(this._dp, this, this._start - this._delay);
}
}
if (this._tTime !== _totalTime || !this._dur && !suppressEvents || this._initted && Math.abs(this._zTime) === _tinyNum || !_totalTime && !this._initted && (this.add || this._ptLookup)) {
this._ts || (this._pTime = _totalTime);
_lazySafeRender(this, _totalTime, suppressEvents);
}
return this;
};
_proto.time = function time(value, suppressEvents) {
return arguments.length ? this.totalTime(Math.min(this.totalDuration(), value + _elapsedCycleDuration(this)) % this._dur || (value ? this._dur : 0), suppressEvents) : this._time;
};
_proto.totalProgress = function totalProgress(value, suppressEvents) {
return arguments.length ? this.totalTime(this.totalDuration() * value, suppressEvents) : this.totalDuration() ? Math.min(1, this._tTime / this._tDur) : this.ratio;
};
_proto.progress = function progress(value, suppressEvents) {
return arguments.length ? this.totalTime(this.duration() * (this._yoyo && !(this.iteration() & 1) ? 1 - value : value) + _elapsedCycleDuration(this), suppressEvents) : this.duration() ? Math.min(1, this._time / this._dur) : this.ratio;
};
_proto.iteration = function iteration(value, suppressEvents) {
var cycleDuration = this.duration() + this._rDelay;
return arguments.length ? this.totalTime(this._time + (value - 1) * cycleDuration, suppressEvents) : this._repeat ? _animationCycle(this._tTime, cycleDuration) + 1 : 1;
};
_proto.timeScale = function timeScale(value) {
if (!arguments.length) {
return this._rts === -_tinyNum ? 0 : this._rts;
}
if (this._rts === value) {
return this;
}
var tTime = this.parent && this._ts ? _parentToChildTotalTime(this.parent._time, this) : this._tTime;
this._rts = +value || 0;
this._ts = this._ps || value === -_tinyNum ? 0 : this._rts;
return _recacheAncestors(this.totalTime(_clamp(-this._delay, this._tDur, tTime), true));
};
_proto.paused = function paused(value) {
if (!arguments.length) {
return this._ps;
}
if (this._ps !== value) {
this._ps = value;
if (value) {
this._pTime = this._tTime || Math.max(-this._delay, this.rawTime());
this._ts = this._act = 0;
} else {
_wake();
this._ts = this._rts;
this.totalTime(this.parent && !this.parent.smoothChildTiming ? this.rawTime() : this._tTime || this._pTime, this.progress() === 1 && (this._tTime -= _tinyNum) && Math.abs(this._zTime) !== _tinyNum);
}
}
return this;
};
_proto.startTime = function startTime(value) {
if (arguments.length) {
this._start = value;
var parent = this.parent || this._dp;
parent && (parent._sort || !this.parent) && _addToTimeline(parent, this, value - this._delay);
return this;
}
return this._start;
};
_proto.endTime = function endTime(includeRepeats) {
return this._start + (_isNotFalse(includeRepeats) ? this.totalDuration() : this.duration()) / Math.abs(this._ts);
};
_proto.rawTime = function rawTime(wrapRepeats) {
var parent = this.parent || this._dp;
return !parent ? this._tTime : wrapRepeats && (!this._ts || this._repeat && this._time && this.totalProgress() < 1) ? this._tTime % (this._dur + this._rDelay) : !this._ts ? this._tTime : _parentToChildTotalTime(parent.rawTime(wrapRepeats), this);
};
_proto.globalTime = function globalTime(rawTime) {
var animation = this,
time = arguments.length ? rawTime : animation.rawTime();
while (animation) {
time = animation._start + time / (animation._ts || 1);
animation = animation._dp;
}
return time;
};
_proto.repeat = function repeat(value) {
if (arguments.length) {
this._repeat = value === Infinity ? -2 : value;
return _onUpdateTotalDuration(this);
}
return this._repeat === -2 ? Infinity : this._repeat;
};
_proto.repeatDelay = function repeatDelay(value) {
if (arguments.length) {
this._rDelay = value;
return _onUpdateTotalDuration(this);
}
return this._rDelay;
};
_proto.yoyo = function yoyo(value) {
if (arguments.length) {
this._yoyo = value;
return this;
}
return this._yoyo;
};
_proto.seek = function seek(position, suppressEvents) {
return this.totalTime(_parsePosition(this, position), _isNotFalse(suppressEvents));
};
_proto.restart = function restart(includeDelay, suppressEvents) {
return this.play().totalTime(includeDelay ? -this._delay : 0, _isNotFalse(suppressEvents));
};
_proto.play = function play(from, suppressEvents) {
from != null && this.seek(from, suppressEvents);
return this.reversed(false).paused(false);
};
_proto.reverse = function reverse(from, suppressEvents) {
from != null && this.seek(from || this.totalDuration(), suppressEvents);
return this.reversed(true).paused(false);
};
_proto.pause = function pause(atTime, suppressEvents) {
atTime != null && this.seek(atTime, suppressEvents);
return this.paused(true);
};
_proto.resume = function resume() {
return this.paused(false);
};
_proto.reversed = function reversed(value) {
if (arguments.length) {
!!value !== this.reversed() && this.timeScale(-this._rts || (value ? -_tinyNum : 0));
return this;
}
return this._rts < 0;
};
_proto.invalidate = function invalidate() {
this._initted = this._act = 0;
this._zTime = -_tinyNum;
return this;
};
_proto.isActive = function isActive() {
var parent = this.parent || this._dp,
start = this._start,
rawTime;
return !!(!parent || this._ts && this._initted && parent.isActive() && (rawTime = parent.rawTime(true)) >= start && rawTime < this.endTime(true) - _tinyNum);
};
_proto.eventCallback = function eventCallback(type, callback, params) {
var vars = this.vars;
if (arguments.length > 1) {
if (!callback) {
delete vars[type];
} else {
vars[type] = callback;
params && (vars[type + "Params"] = params);
type === "onUpdate" && (this._onUpdate = callback);
}
return this;
}
return vars[type];
};
_proto.then = function then(onFulfilled) {
var self = this;
return new Promise(function (resolve) {
var f = _isFunction(onFulfilled) ? onFulfilled : _passThrough,
_resolve = function _resolve() {
var _then = self.then;
self.then = null;
_isFunction(f) && (f = f(self)) && (f.then || f === self) && (self.then = _then);
resolve(f);
self.then = _then;
};
if (self._initted && self.totalProgress() === 1 && self._ts >= 0 || !self._tTime && self._ts < 0) {
_resolve();
} else {
self._prom = _resolve;
}
});
};
_proto.kill = function kill() {
_interrupt(this);
};
return Animation;
}();
_setDefaults(Animation.prototype, {
_time: 0,
_start: 0,
_end: 0,
_tTime: 0,
_tDur: 0,
_dirty: 0,
_repeat: 0,
_yoyo: false,
parent: null,
_initted: false,
_rDelay: 0,
_ts: 1,
_dp: 0,
ratio: 0,
_zTime: -_tinyNum,
_prom: 0,
_ps: false,
_rts: 1
});
var Timeline = function (_Animation) {
_inheritsLoose(Timeline, _Animation);
function Timeline(vars, time) {
var _this;
if (vars === void 0) {
vars = {};
}
_this = _Animation.call(this, vars, time) || this;
_this.labels = {};
_this.smoothChildTiming = !!vars.smoothChildTiming;
_this.autoRemoveChildren = !!vars.autoRemoveChildren;
_this._sort = _isNotFalse(vars.sortChildren);
_this.parent && _postAddChecks(_this.parent, _assertThisInitialized(_this));
vars.scrollTrigger && _scrollTrigger(_assertThisInitialized(_this), vars.scrollTrigger);
return _this;
}
var _proto2 = Timeline.prototype;
_proto2.to = function to(targets, vars, position) {
new Tween(targets, _parseVars(arguments, 0, this), _parsePosition(this, _isNumber(vars) ? arguments[3] : position));
return this;
};
_proto2.from = function from(targets, vars, position) {
new Tween(targets, _parseVars(arguments, 1, this), _parsePosition(this, _isNumber(vars) ? arguments[3] : position));
return this;
};
_proto2.fromTo = function fromTo(targets, fromVars, toVars, position) {
new Tween(targets, _parseVars(arguments, 2, this), _parsePosition(this, _isNumber(fromVars) ? arguments[4] : position));
return this;
};
_proto2.set = function set(targets, vars, position) {
vars.duration = 0;
vars.parent = this;
_inheritDefaults(vars).repeatDelay || (vars.repeat = 0);
vars.immediateRender = !!vars.immediateRender;
new Tween(targets, vars, _parsePosition(this, position), 1);
return this;
};
_proto2.call = function call(callback, params, position) {
return _addToTimeline(this, Tween.delayedCall(0, callback, params), _parsePosition(this, position));
};
_proto2.staggerTo = function staggerTo(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams) {
vars.duration = duration;
vars.stagger = vars.stagger || stagger;
vars.onComplete = onCompleteAll;
vars.onCompleteParams = onCompleteAllParams;
vars.parent = this;
new Tween(targets, vars, _parsePosition(this, position));
return this;
};
_proto2.staggerFrom = function staggerFrom(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams) {
vars.runBackwards = 1;
_inheritDefaults(vars).immediateRender = _isNotFalse(vars.immediateRender);
return this.staggerTo(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams);
};
_proto2.staggerFromTo = function staggerFromTo(targets, duration, fromVars, toVars, stagger, position, onCompleteAll, onCompleteAllParams) {
toVars.startAt = fromVars;
_inheritDefaults(toVars).immediateRender = _isNotFalse(toVars.immediateRender);
return this.staggerTo(targets, duration, toVars, stagger, position, onCompleteAll, onCompleteAllParams);
};
_proto2.render = function render(totalTime, suppressEvents, force) {
var prevTime = this._time,
tDur = this._dirty ? this.totalDuration() : this._tDur,
dur = this._dur,
tTime = this !== _globalTimeline && totalTime > tDur - _tinyNum && totalTime >= 0 ? tDur : totalTime < _tinyNum ? 0 : totalTime,
crossingStart = this._zTime < 0 !== totalTime < 0 && (this._initted || !dur),
time,
child,
next,
iteration,
cycleDuration,
prevPaused,
pauseTween,
timeScale,
prevStart,
prevIteration,
yoyo,
isYoyo;
if (tTime !== this._tTime || force || crossingStart) {
if (prevTime !== this._time && dur) {
tTime += this._time - prevTime;
totalTime += this._time - prevTime;
}
time = tTime;
prevStart = this._start;
timeScale = this._ts;
prevPaused = !timeScale;
if (crossingStart) {
dur || (prevTime = this._zTime);
(totalTime || !suppressEvents) && (this._zTime = totalTime);
}
if (this._repeat) {
yoyo = this._yoyo;
cycleDuration = dur + this._rDelay;
if (this._repeat < -1 && totalTime < 0) {
return this.totalTime(cycleDuration * 100 + totalTime, suppressEvents, force);
}
time = _round(tTime % cycleDuration);
if (tTime === tDur) {
iteration = this._repeat;
time = dur;
} else {
iteration = ~~(tTime / cycleDuration);
if (iteration && iteration === tTime / cycleDuration) {
time = dur;
iteration--;
}
time > dur && (time = dur);
}
prevIteration = _animationCycle(this._tTime, cycleDuration);
!prevTime && this._tTime && prevIteration !== iteration && (prevIteration = iteration);
if (yoyo && iteration & 1) {
time = dur - time;
isYoyo = 1;
}
if (iteration !== prevIteration && !this._lock) {
var rewinding = yoyo && prevIteration & 1,
doesWrap = rewinding === (yoyo && iteration & 1);
iteration < prevIteration && (rewinding = !rewinding);
prevTime = rewinding ? 0 : dur;
this._lock = 1;
this.render(prevTime || (isYoyo ? 0 : _round(iteration * cycleDuration)), suppressEvents, !dur)._lock = 0;
!suppressEvents && this.parent && _callback(this, "onRepeat");
this.vars.repeatRefresh && !isYoyo && (this.invalidate()._lock = 1);
if (prevTime && prevTime !== this._time || prevPaused !== !this._ts || this.vars.onRepeat && !this.parent && !this._act) {
return this;
}
dur = this._dur;
tDur = this._tDur;
if (doesWrap) {
this._lock = 2;
prevTime = rewinding ? dur : -0.0001;
this.render(prevTime, true);
}
this._lock = 0;
if (!this._ts && !prevPaused) {
return this;
}
_propagateYoyoEase(this, isYoyo);
}
}
if (this._hasPause && !this._forcing && this._lock < 2) {
pauseTween = _findNextPauseTween(this, _round(prevTime), _round(time));
if (pauseTween) {
tTime -= time - (time = pauseTween._start);
}
}
this._tTime = tTime;
this._time = time;
this._act = !timeScale;
if (!this._initted) {
this._onUpdate = this.vars.onUpdate;
this._initted = 1;
this._zTime = totalTime;
prevTime = 0;
}
!prevTime && time && !suppressEvents && _callback(this, "onStart");
if (time >= prevTime && totalTime >= 0) {
child = this._first;
while (child) {
next = child._next;
if ((child._act || time >= child._start) && child._ts && pauseTween !== child) {
if (child.parent !== this) {
return this.render(totalTime, suppressEvents, force);
}
child.render(child._ts > 0 ? (time - child._start) * child._ts : (child._dirty ? child.totalDuration() : child._tDur) + (time - child._start) * child._ts, suppressEvents, force);
if (time !== this._time || !this._ts && !prevPaused) {
pauseTween = 0;
next && (tTime += this._zTime = -_tinyNum);
break;
}
}
child = next;
}
} else {
child = this._last;
var adjustedTime = totalTime < 0 ? totalTime : time;
while (child) {
next = child._prev;
if ((child._act || adjustedTime <= child._end) && child._ts && pauseTween !== child) {
if (child.parent !== this) {
return this.render(totalTime, suppressEvents, force);
}
child.render(child._ts > 0 ? (adjustedTime - child._start) * child._ts : (child._dirty ? child.totalDuration() : child._tDur) + (adjustedTime - child._start) * child._ts, suppressEvents, force);
if (time !== this._time || !this._ts && !prevPaused) {
pauseTween = 0;
next && (tTime += this._zTime = adjustedTime ? -_tinyNum : _tinyNum);
break;
}
}
child = next;
}
}
if (pauseTween && !suppressEvents) {
this.pause();
pauseTween.render(time >= prevTime ? 0 : -_tinyNum)._zTime = time >= prevTime ? 1 : -1;
if (this._ts) {
this._start = prevStart;
_setEnd(this);
return this.render(totalTime, suppressEvents, force);
}
}
this._onUpdate && !suppressEvents && _callback(this, "onUpdate", true);
if (tTime === tDur && tDur >= this.totalDuration() || !tTime && prevTime) if (prevStart === this._start || Math.abs(timeScale) !== Math.abs(this._ts)) if (!this._lock) {
(totalTime || !dur) && (tTime === tDur && this._ts > 0 || !tTime && this._ts < 0) && _removeFromParent(this, 1);
if (!suppressEvents && !(totalTime < 0 && !prevTime) && (tTime || prevTime)) {
_callback(this, tTime === tDur ? "onComplete" : "onReverseComplete", true);
this._prom && !(tTime < tDur && this.timeScale() > 0) && this._prom();
}
}
}
return this;
};
_proto2.add = function add(child, position) {
var _this2 = this;
_isNumber(position) || (position = _parsePosition(this, position));
if (!(child instanceof Animation)) {
if (_isArray(child)) {
child.forEach(function (obj) {
return _this2.add(obj, position);
});
return this;
}
if (_isString(child)) {
return this.addLabel(child, position);
}
if (_isFunction(child)) {
child = Tween.delayedCall(0, child);
} else {
return this;
}
}
return this !== child ? _addToTimeline(this, child, position) : this;
};
_proto2.getChildren = function getChildren(nested, tweens, timelines, ignoreBeforeTime) {
if (nested === void 0) {
nested = true;
}
if (tweens === void 0) {
tweens = true;
}
if (timelines === void 0) {
timelines = true;
}
if (ignoreBeforeTime === void 0) {
ignoreBeforeTime = -_bigNum;
}
var a = [],
child = this._first;
while (child) {
if (child._start >= ignoreBeforeTime) {
if (child instanceof Tween) {
tweens && a.push(child);
} else {
timelines && a.push(child);
nested && a.push.apply(a, child.getChildren(true, tweens, timelines));
}
}
child = child._next;
}
return a;
};
_proto2.getById = function getById(id) {
var animations = this.getChildren(1, 1, 1),
i = animations.length;
while (i--) {
if (animations[i].vars.id === id) {
return animations[i];
}
}
};
_proto2.remove = function remove(child) {
if (_isString(child)) {
return this.removeLabel(child);
}
if (_isFunction(child)) {
return this.killTweensOf(child);
}
_removeLinkedListItem(this, child);
if (child === this._recent) {
this._recent = this._last;
}
return _uncache(this);
};
_proto2.totalTime = function totalTime(_totalTime2, suppressEvents) {
if (!arguments.length) {
return this._tTime;
}
this._forcing = 1;
if (!this._dp && this._ts) {
this._start = _round(_ticker.time - (this._ts > 0 ? _totalTime2 / this._ts : (this.totalDuration() - _totalTime2) / -this._ts));
}
_Animation.prototype.totalTime.call(this, _totalTime2, suppressEvents);
this._forcing = 0;
return this;
};
_proto2.addLabel = function addLabel(label, position) {
this.labels[label] = _parsePosition(this, position);
return this;
};
_proto2.removeLabel = function removeLabel(label) {
delete this.labels[label];
return this;
};
_proto2.addPause = function addPause(position, callback, params) {
var t = Tween.delayedCall(0, callback || _emptyFunc, params);
t.data = "isPause";
this._hasPause = 1;
return _addToTimeline(this, t, _parsePosition(this, position));
};
_proto2.removePause = function removePause(position) {
var child = this._first;
position = _parsePosition(this, position);
while (child) {
if (child._start === position && child.data === "isPause") {
_removeFromParent(child);
}
child = child._next;
}
};
_proto2.killTweensOf = function killTweensOf(targets, props, onlyActive) {
var tweens = this.getTweensOf(targets, onlyActive),
i = tweens.length;
while (i--) {
_overwritingTween !== tweens[i] && tweens[i].kill(targets, props);
}
return this;
};
_proto2.getTweensOf = function getTweensOf(targets, onlyActive) {
var a = [],
parsedTargets = toArray(targets),
child = this._first,
isGlobalTime = _isNumber(onlyActive),
children;
while (child) {
if (child instanceof Tween) {
if (_arrayContainsAny(child._targets, parsedTargets) && (isGlobalTime ? (!_overwritingTween || child._initted && child._ts) && child.globalTime(0) <= onlyActive && child.globalTime(child.totalDuration()) > onlyActive : !onlyActive || child.isActive())) {
a.push(child);
}
} else if ((children = child.getTweensOf(parsedTargets, onlyActive)).length) {
a.push.apply(a, children);
}
child = child._next;
}
return a;
};
_proto2.tweenTo = function tweenTo(position, vars) {
vars = vars || {};
var tl = this,
endTime = _parsePosition(tl, position),
_vars = vars,
startAt = _vars.startAt,
_onStart = _vars.onStart,
onStartParams = _vars.onStartParams,
immediateRender = _vars.immediateRender,
tween = Tween.to(tl, _setDefaults({
ease: vars.ease || "none",
lazy: false,
immediateRender: false,
time: endTime,
overwrite: "auto",
duration: vars.duration || Math.abs((endTime - (startAt && "time" in startAt ? startAt.time : tl._time)) / tl.timeScale()) || _tinyNum,
onStart: function onStart() {
tl.pause();
var duration = vars.duration || Math.abs((endTime - tl._time) / tl.timeScale());
tween._dur !== duration && _setDuration(tween, duration, 0, 1).render(tween._time, true, true);
_onStart && _onStart.apply(tween, onStartParams || []);
}
}, vars));
return immediateRender ? tween.render(0) : tween;
};
_proto2.tweenFromTo = function tweenFromTo(fromPosition, toPosition, vars) {
return this.tweenTo(toPosition, _setDefaults({
startAt: {
time: _parsePosition(this, fromPosition)
}
}, vars));
};
_proto2.recent = function recent() {
return this._recent;
};
_proto2.nextLabel = function nextLabel(afterTime) {
if (afterTime === void 0) {
afterTime = this._time;
}
return _getLabelInDirection(this, _parsePosition(this, afterTime));
};
_proto2.previousLabel = function previousLabel(beforeTime) {
if (beforeTime === void 0) {
beforeTime = this._time;
}
return _getLabelInDirection(this, _parsePosition(this, beforeTime), 1);
};
_proto2.currentLabel = function currentLabel(value) {
return arguments.length ? this.seek(value, true) : this.previousLabel(this._time + _tinyNum);
};
_proto2.shiftChildren = function shiftChildren(amount, adjustLabels, ignoreBeforeTime) {
if (ignoreBeforeTime === void 0) {
ignoreBeforeTime = 0;
}
var child = this._first,
labels = this.labels,
p;
while (child) {
if (child._start >= ignoreBeforeTime) {
child._start += amount;
child._end += amount;
}
child = child._next;
}
if (adjustLabels) {
for (p in labels) {
if (labels[p] >= ignoreBeforeTime) {
labels[p] += amount;
}
}
}
return _uncache(this);
};
_proto2.invalidate = function invalidate() {
var child = this._first;
this._lock = 0;
while (child) {
child.invalidate();
child = child._next;
}
return _Animation.prototype.invalidate.call(this);
};
_proto2.clear = function clear(includeLabels) {
if (includeLabels === void 0) {
includeLabels = true;
}
var child = this._first,
next;
while (child) {
next = child._next;
this.remove(child);
child = next;
}
this._dp && (this._time = this._tTime = this._pTime = 0);
includeLabels && (this.labels = {});
return _uncache(this);
};
_proto2.totalDuration = function totalDuration(value) {
var max = 0,
self = this,
child = self._last,
prevStart = _bigNum,
prev,
start,
parent;
if (arguments.length) {
return self.timeScale((self._repeat < 0 ? self.duration() : self.totalDuration()) / (self.reversed() ? -value : value));
}
if (self._dirty) {
parent = self.parent;
while (child) {
prev = child._prev;
child._dirty && child.totalDuration();
start = child._start;
if (start > prevStart && self._sort && child._ts && !self._lock) {
self._lock = 1;
_addToTimeline(self, child, start - child._delay, 1)._lock = 0;
} else {
prevStart = start;
}
if (start < 0 && child._ts) {
max -= start;
if (!parent && !self._dp || parent && parent.smoothChildTiming) {
self._start += start / self._ts;
self._time -= start;
self._tTime -= start;
}
self.shiftChildren(-start, false, -1e999);
prevStart = 0;
}
child._end > max && child._ts && (max = child._end);
child = prev;
}
_setDuration(self, self === _globalTimeline && self._time > max ? self._time : max, 1, 1);
self._dirty = 0;
}
return self._tDur;
};
Timeline.updateRoot = function updateRoot(time) {
if (_globalTimeline._ts) {
_lazySafeRender(_globalTimeline, _parentToChildTotalTime(time, _globalTimeline));
_lastRenderedFrame = _ticker.frame;
}
if (_ticker.frame >= _nextGCFrame) {
_nextGCFrame += _config.autoSleep || 120;
var child = _globalTimeline._first;
if (!child || !child._ts) if (_config.autoSleep && _ticker._listeners.length < 2) {
while (child && !child._ts) {
child = child._next;
}
child || _ticker.sleep();
}
}
};
return Timeline;
}(Animation);
_setDefaults(Timeline.prototype, {
_lock: 0,
_hasPause: 0,
_forcing: 0
});
var _addComplexStringPropTween = function _addComplexStringPropTween(target, prop, start, end, setter, stringFilter, funcParam) {
var pt = new PropTween(this._pt, target, prop, 0, 1, _renderComplexString, null, setter),
index = 0,
matchIndex = 0,
result,
startNums,
color,
endNum,
chunk,
startNum,
hasRandom,
a;
pt.b = start;
pt.e = end;
start += "";
end += "";
if (hasRandom = ~end.indexOf("random(")) {
end = _replaceRandom(end);
}
if (stringFilter) {
a = [start, end];
stringFilter(a, target, prop);
start = a[0];
end = a[1];
}
startNums = start.match(_complexStringNumExp) || [];
while (result = _complexStringNumExp.exec(end)) {
endNum = result[0];
chunk = end.substring(index, result.index);
if (color) {
color = (color + 1) % 5;
} else if (chunk.substr(-5) === "rgba(") {
color = 1;
}
if (endNum !== startNums[matchIndex++]) {
startNum = parseFloat(startNums[matchIndex - 1]) || 0;
pt._pt = {
_next: pt._pt,
p: chunk || matchIndex === 1 ? chunk : ",",
s: startNum,
c: endNum.charAt(1) === "=" ? parseFloat(endNum.substr(2)) * (endNum.charAt(0) === "-" ? -1 : 1) : parseFloat(endNum) - startNum,
m: color && color < 4 ? Math.round : 0
};
index = _complexStringNumExp.lastIndex;
}
}
pt.c = index < end.length ? end.substring(index, end.length) : "";
pt.fp = funcParam;
if (_relExp.test(end) || hasRandom) {
pt.e = 0;
}
this._pt = pt;
return pt;
},
_addPropTween = function _addPropTween(target, prop, start, end, index, targets, modifier, stringFilter, funcParam) {
_isFunction(end) && (end = end(index || 0, target, targets));
var currentValue = target[prop],
parsedStart = start !== "get" ? start : !_isFunction(currentValue) ? currentValue : funcParam ? target[prop.indexOf("set") || !_isFunction(target["get" + prop.substr(3)]) ? prop : "get" + prop.substr(3)](funcParam) : target[prop](),
setter = !_isFunction(currentValue) ? _setterPlain : funcParam ? _setterFuncWithParam : _setterFunc,
pt;
if (_isString(end)) {
if (~end.indexOf("random(")) {
end = _replaceRandom(end);
}
if (end.charAt(1) === "=") {
end = parseFloat(parsedStart) + parseFloat(end.substr(2)) * (end.charAt(0) === "-" ? -1 : 1) + (getUnit(parsedStart) || 0);
}
}
if (parsedStart !== end) {
if (!isNaN(parsedStart * end)) {
pt = new PropTween(this._pt, target, prop, +parsedStart || 0, end - (parsedStart || 0), typeof currentValue === "boolean" ? _renderBoolean : _renderPlain, 0, setter);
funcParam && (pt.fp = funcParam);
modifier && pt.modifier(modifier, this, target);
return this._pt = pt;
}
!currentValue && !(prop in target) && _missingPlugin(prop, end);
return _addComplexStringPropTween.call(this, target, prop, parsedStart, end, setter, stringFilter || _config.stringFilter, funcParam);
}
},
_processVars = function _processVars(vars, index, target, targets, tween) {
_isFunction(vars) && (vars = _parseFuncOrString(vars, tween, index, target, targets));
if (!_isObject(vars) || vars.style && vars.nodeType || _isArray(vars) || _isTypedArray(vars)) {
return _isString(vars) ? _parseFuncOrString(vars, tween, index, target, targets) : vars;
}
var copy = {},
p;
for (p in vars) {
copy[p] = _parseFuncOrString(vars[p], tween, index, target, targets);
}
return copy;
},
_checkPlugin = function _checkPlugin(property, vars, tween, index, target, targets) {
var plugin, pt, ptLookup, i;
if (_plugins[property] && (plugin = new _plugins[property]()).init(target, plugin.rawVars ? vars[property] : _processVars(vars[property], index, target, targets, tween), tween, index, targets) !== false) {
tween._pt = pt = new PropTween(tween._pt, target, property, 0, 1, plugin.render, plugin, 0, plugin.priority);
if (tween !== _quickTween) {
ptLookup = tween._ptLookup[tween._targets.indexOf(target)];
i = plugin._props.length;
while (i--) {
ptLookup[plugin._props[i]] = pt;
}
}
}
return plugin;
},
_overwritingTween,
_initTween = function _initTween(tween, time) {
var vars = tween.vars,
ease = vars.ease,
startAt = vars.startAt,
immediateRender = vars.immediateRender,
lazy = vars.lazy,
onUpdate = vars.onUpdate,
onUpdateParams = vars.onUpdateParams,
callbackScope = vars.callbackScope,
runBackwards = vars.runBackwards,
yoyoEase = vars.yoyoEase,
keyframes = vars.keyframes,
autoRevert = vars.autoRevert,
dur = tween._dur,
prevStartAt = tween._startAt,
targets = tween._targets,
parent = tween.parent,
fullTargets = parent && parent.data === "nested" ? parent.parent._targets : targets,
autoOverwrite = tween._overwrite === "auto" && !_suppressOverwrites,
tl = tween.timeline,
cleanVars,
i,
p,
pt,
target,
hasPriority,
gsData,
harness,
plugin,
ptLookup,
index,
harnessVars,
overwritten;
tl && (!keyframes || !ease) && (ease = "none");
tween._ease = _parseEase(ease, _defaults.ease);
tween._yEase = yoyoEase ? _invertEase(_parseEase(yoyoEase === true ? ease : yoyoEase, _defaults.ease)) : 0;
if (yoyoEase && tween._yoyo && !tween._repeat) {
yoyoEase = tween._yEase;
tween._yEase = tween._ease;
tween._ease = yoyoEase;
}
if (!tl) {
harness = targets[0] ? _getCache(targets[0]).harness : 0;
harnessVars = harness && vars[harness.prop];
cleanVars = _copyExcluding(vars, _reservedProps);
prevStartAt && prevStartAt.render(-1, true).kill();
if (startAt) {
_removeFromParent(tween._startAt = Tween.set(targets, _setDefaults({
data: "isStart",
overwrite: false,
parent: parent,
immediateRender: true,
lazy: _isNotFalse(lazy),
startAt: null,
delay: 0,
onUpdate: onUpdate,
onUpdateParams: onUpdateParams,
callbackScope: callbackScope,
stagger: 0
}, startAt)));
if (immediateRender) {
if (time > 0) {
autoRevert || (tween._startAt = 0);
} else if (dur && !(time < 0 && prevStartAt)) {
time && (tween._zTime = time);
return;
}
} else if (autoRevert === false) {
tween._startAt = 0;
}
} else if (runBackwards && dur) {
if (prevStartAt) {
!autoRevert && (tween._startAt = 0);
} else {
time && (immediateRender = false);
p = _setDefaults({
overwrite: false,
data: "isFromStart",
lazy: immediateRender && _isNotFalse(lazy),
immediateRender: immediateRender,
stagger: 0,
parent: parent
}, cleanVars);
harnessVars && (p[harness.prop] = harnessVars);
_removeFromParent(tween._startAt = Tween.set(targets, p));
if (!immediateRender) {
_initTween(tween._startAt, _tinyNum);
} else if (!time) {
return;
}
}
}
tween._pt = 0;
lazy = dur && _isNotFalse(lazy) || lazy && !dur;
for (i = 0; i < targets.length; i++) {
target = targets[i];
gsData = target._gsap || _harness(targets)[i]._gsap;
tween._ptLookup[i] = ptLookup = {};
_lazyLookup[gsData.id] && _lazyTweens.length && _lazyRender();
index = fullTargets === targets ? i : fullTargets.indexOf(target);
if (harness && (plugin = new harness()).init(target, harnessVars || cleanVars, tween, index, fullTargets) !== false) {
tween._pt = pt = new PropTween(tween._pt, target, plugin.name, 0, 1, plugin.render, plugin, 0, plugin.priority);
plugin._props.forEach(function (name) {
ptLookup[name] = pt;
});
plugin.priority && (hasPriority = 1);
}
if (!harness || harnessVars) {
for (p in cleanVars) {
if (_plugins[p] && (plugin = _checkPlugin(p, cleanVars, tween, index, target, fullTargets))) {
plugin.priority && (hasPriority = 1);
} else {
ptLookup[p] = pt = _addPropTween.call(tween, target, p, "get", cleanVars[p], index, fullTargets, 0, vars.stringFilter);
}
}
}
tween._op && tween._op[i] && tween.kill(target, tween._op[i]);
if (autoOverwrite && tween._pt) {
_overwritingTween = tween;
_globalTimeline.killTweensOf(target, ptLookup, tween.globalTime(0));
overwritten = !tween.parent;
_overwritingTween = 0;
}
tween._pt && lazy && (_lazyLookup[gsData.id] = 1);
}
hasPriority && _sortPropTweensByPriority(tween);
tween._onInit && tween._onInit(tween);
}
tween._from = !tl && !!vars.runBackwards;
tween._onUpdate = onUpdate;
tween._initted = (!tween._op || tween._pt) && !overwritten;
},
_addAliasesToVars = function _addAliasesToVars(targets, vars) {
var harness = targets[0] ? _getCache(targets[0]).harness : 0,
propertyAliases = harness && harness.aliases,
copy,
p,
i,
aliases;
if (!propertyAliases) {
return vars;
}
copy = _merge({}, vars);
for (p in propertyAliases) {
if (p in copy) {
aliases = propertyAliases[p].split(",");
i = aliases.length;
while (i--) {
copy[aliases[i]] = copy[p];
}
}
}
return copy;
},
_parseFuncOrString = function _parseFuncOrString(value, tween, i, target, targets) {
return _isFunction(value) ? value.call(tween, i, target, targets) : _isString(value) && ~value.indexOf("random(") ? _replaceRandom(value) : value;
},
_staggerTweenProps = _callbackNames + "repeat,repeatDelay,yoyo,repeatRefresh,yoyoEase",
_staggerPropsToSkip = (_staggerTweenProps + ",id,stagger,delay,duration,paused,scrollTrigger").split(",");
var Tween = function (_Animation2) {
_inheritsLoose(Tween, _Animation2);
function Tween(targets, vars, time, skipInherit) {
var _this3;
if (typeof vars === "number") {
time.duration = vars;
vars = time;
time = null;
}
_this3 = _Animation2.call(this, skipInherit ? vars : _inheritDefaults(vars), time) || this;
var _this3$vars = _this3.vars,
duration = _this3$vars.duration,
delay = _this3$vars.delay,
immediateRender = _this3$vars.immediateRender,
stagger = _this3$vars.stagger,
overwrite = _this3$vars.overwrite,
keyframes = _this3$vars.keyframes,
defaults = _this3$vars.defaults,
scrollTrigger = _this3$vars.scrollTrigger,
yoyoEase = _this3$vars.yoyoEase,
parent = _this3.parent,
parsedTargets = (_isArray(targets) || _isTypedArray(targets) ? _isNumber(targets[0]) : "length" in vars) ? [targets] : toArray(targets),
tl,
i,
copy,
l,
p,
curTarget,
staggerFunc,
staggerVarsToMerge;
_this3._targets = parsedTargets.length ? _harness(parsedTargets) : _warn("GSAP target " + targets + " not found. https://greensock.com", !_config.nullTargetWarn) || [];
_this3._ptLookup = [];
_this3._overwrite = overwrite;
if (keyframes || stagger || _isFuncOrString(duration) || _isFuncOrString(delay)) {
vars = _this3.vars;
tl = _this3.timeline = new Timeline({
data: "nested",
defaults: defaults || {}
});
tl.kill();
tl.parent = tl._dp = _assertThisInitialized(_this3);
tl._start = 0;
if (keyframes) {
_setDefaults(tl.vars.defaults, {
ease: "none"
});
keyframes.forEach(function (frame) {
return tl.to(parsedTargets, frame, ">");
});
} else {
l = parsedTargets.length;
staggerFunc = stagger ? distribute(stagger) : _emptyFunc;
if (_isObject(stagger)) {
for (p in stagger) {
if (~_staggerTweenProps.indexOf(p)) {
staggerVarsToMerge || (staggerVarsToMerge = {});
staggerVarsToMerge[p] = stagger[p];
}
}
}
for (i = 0; i < l; i++) {
copy = {};
for (p in vars) {
if (_staggerPropsToSkip.indexOf(p) < 0) {
copy[p] = vars[p];
}
}
copy.stagger = 0;
yoyoEase && (copy.yoyoEase = yoyoEase);
staggerVarsToMerge && _merge(copy, staggerVarsToMerge);
curTarget = parsedTargets[i];
copy.duration = +_parseFuncOrString(duration, _assertThisInitialized(_this3), i, curTarget, parsedTargets);
copy.delay = (+_parseFuncOrString(delay, _assertThisInitialized(_this3), i, curTarget, parsedTargets) || 0) - _this3._delay;
if (!stagger && l === 1 && copy.delay) {
_this3._delay = delay = copy.delay;
_this3._start += delay;
copy.delay = 0;
}
tl.to(curTarget, copy, staggerFunc(i, curTarget, parsedTargets));
}
tl.duration() ? duration = delay = 0 : _this3.timeline = 0;
}
duration || _this3.duration(duration = tl.duration());
} else {
_this3.timeline = 0;
}
if (overwrite === true && !_suppressOverwrites) {
_overwritingTween = _assertThisInitialized(_this3);
_globalTimeline.killTweensOf(parsedTargets);
_overwritingTween = 0;
}
parent && _postAddChecks(parent, _assertThisInitialized(_this3));
if (immediateRender || !duration && !keyframes && _this3._start === _round(parent._time) && _isNotFalse(immediateRender) && _hasNoPausedAncestors(_assertThisInitialized(_this3)) && parent.data !== "nested") {
_this3._tTime = -_tinyNum;
_this3.render(Math.max(0, -delay));
}
scrollTrigger && _scrollTrigger(_assertThisInitialized(_this3), scrollTrigger);
return _this3;
}
var _proto3 = Tween.prototype;
_proto3.render = function render(totalTime, suppressEvents, force) {
var prevTime = this._time,
tDur = this._tDur,
dur = this._dur,
tTime = totalTime > tDur - _tinyNum && totalTime >= 0 ? tDur : totalTime < _tinyNum ? 0 : totalTime,
time,
pt,
iteration,
cycleDuration,
prevIteration,
isYoyo,
ratio,
timeline,
yoyoEase;
if (!dur) {
_renderZeroDurationTween(this, totalTime, suppressEvents, force);
} else if (tTime !== this._tTime || !totalTime || force || !this._initted && this._tTime || this._startAt && this._zTime < 0 !== totalTime < 0) {
time = tTime;
timeline = this.timeline;
if (this._repeat) {
cycleDuration = dur + this._rDelay;
if (this._repeat < -1 && totalTime < 0) {
return this.totalTime(cycleDuration * 100 + totalTime, suppressEvents, force);
}
time = _round(tTime % cycleDuration);
if (tTime === tDur) {
iteration = this._repeat;
time = dur;
} else {
iteration = ~~(tTime / cycleDuration);
if (iteration && iteration === tTime / cycleDuration) {
time = dur;
iteration--;
}
time > dur && (time = dur);
}
isYoyo = this._yoyo && iteration & 1;
if (isYoyo) {
yoyoEase = this._yEase;
time = dur - time;
}
prevIteration = _animationCycle(this._tTime, cycleDuration);
if (time === prevTime && !force && this._initted) {
return this;
}
if (iteration !== prevIteration) {
timeline && this._yEase && _propagateYoyoEase(timeline, isYoyo);
if (this.vars.repeatRefresh && !isYoyo && !this._lock) {
this._lock = force = 1;
this.render(_round(cycleDuration * iteration), true).invalidate()._lock = 0;
}
}
}
if (!this._initted) {
if (_attemptInitTween(this, totalTime < 0 ? totalTime : time, force, suppressEvents)) {
this._tTime = 0;
return this;
}
if (dur !== this._dur) {
return this.render(totalTime, suppressEvents, force);
}
}
this._tTime = tTime;
this._time = time;
if (!this._act && this._ts) {
this._act = 1;
this._lazy = 0;
}
this.ratio = ratio = (yoyoEase || this._ease)(time / dur);
if (this._from) {
this.ratio = ratio = 1 - ratio;
}
time && !prevTime && !suppressEvents && _callback(this, "onStart");
pt = this._pt;
while (pt) {
pt.r(ratio, pt.d);
pt = pt._next;
}
timeline && timeline.render(totalTime < 0 ? totalTime : !time && isYoyo ? -_tinyNum : timeline._dur * ratio, suppressEvents, force) || this._startAt && (this._zTime = totalTime);
if (this._onUpdate && !suppressEvents) {
totalTime < 0 && this._startAt && this._startAt.render(totalTime, true, force);
_callback(this, "onUpdate");
}
this._repeat && iteration !== prevIteration && this.vars.onRepeat && !suppressEvents && this.parent && _callback(this, "onRepeat");
if ((tTime === this._tDur || !tTime) && this._tTime === tTime) {
totalTime < 0 && this._startAt && !this._onUpdate && this._startAt.render(totalTime, true, true);
(totalTime || !dur) && (tTime === this._tDur && this._ts > 0 || !tTime && this._ts < 0) && _removeFromParent(this, 1);
if (!suppressEvents && !(totalTime < 0 && !prevTime) && (tTime || prevTime)) {
_callback(this, tTime === tDur ? "onComplete" : "onReverseComplete", true);
this._prom && !(tTime < tDur && this.timeScale() > 0) && this._prom();
}
}
}
return this;
};
_proto3.targets = function targets() {
return this._targets;
};
_proto3.invalidate = function invalidate() {
this._pt = this._op = this._startAt = this._onUpdate = this._lazy = this.ratio = 0;
this._ptLookup = [];
this.timeline && this.timeline.invalidate();
return _Animation2.prototype.invalidate.call(this);
};
_proto3.kill = function kill(targets, vars) {
if (vars === void 0) {
vars = "all";
}
if (!targets && (!vars || vars === "all")) {
this._lazy = this._pt = 0;
return this.parent ? _interrupt(this) : this;
}
if (this.timeline) {
var tDur = this.timeline.totalDuration();
this.timeline.killTweensOf(targets, vars, _overwritingTween && _overwritingTween.vars.overwrite !== true)._first || _interrupt(this);
this.parent && tDur !== this.timeline.totalDuration() && _setDuration(this, this._dur * this.timeline._tDur / tDur, 0, 1);
return this;
}
var parsedTargets = this._targets,
killingTargets = targets ? toArray(targets) : parsedTargets,
propTweenLookup = this._ptLookup,
firstPT = this._pt,
overwrittenProps,
curLookup,
curOverwriteProps,
props,
p,
pt,
i;
if ((!vars || vars === "all") && _arraysMatch(parsedTargets, killingTargets)) {
vars === "all" && (this._pt = 0);
return _interrupt(this);
}
overwrittenProps = this._op = this._op || [];
if (vars !== "all") {
if (_isString(vars)) {
p = {};
_forEachName(vars, function (name) {
return p[name] = 1;
});
vars = p;
}
vars = _addAliasesToVars(parsedTargets, vars);
}
i = parsedTargets.length;
while (i--) {
if (~killingTargets.indexOf(parsedTargets[i])) {
curLookup = propTweenLookup[i];
if (vars === "all") {
overwrittenProps[i] = vars;
props = curLookup;
curOverwriteProps = {};
} else {
curOverwriteProps = overwrittenProps[i] = overwrittenProps[i] || {};
props = vars;
}
for (p in props) {
pt = curLookup && curLookup[p];
if (pt) {
if (!("kill" in pt.d) || pt.d.kill(p) === true) {
_removeLinkedListItem(this, pt, "_pt");
}
delete curLookup[p];
}
if (curOverwriteProps !== "all") {
curOverwriteProps[p] = 1;
}
}
}
}
this._initted && !this._pt && firstPT && _interrupt(this);
return this;
};
Tween.to = function to(targets, vars) {
return new Tween(targets, vars, arguments[2]);
};
Tween.from = function from(targets, vars) {
return new Tween(targets, _parseVars(arguments, 1));
};
Tween.delayedCall = function delayedCall(delay, callback, params, scope) {
return new Tween(callback, 0, {
immediateRender: false,
lazy: false,
overwrite: false,
delay: delay,
onComplete: callback,
onReverseComplete: callback,
onCompleteParams: params,
onReverseCompleteParams: params,
callbackScope: scope
});
};
Tween.fromTo = function fromTo(targets, fromVars, toVars) {
return new Tween(targets, _parseVars(arguments, 2));
};
Tween.set = function set(targets, vars) {
vars.duration = 0;
vars.repeatDelay || (vars.repeat = 0);
return new Tween(targets, vars);
};
Tween.killTweensOf = function killTweensOf(targets, props, onlyActive) {
return _globalTimeline.killTweensOf(targets, props, onlyActive);
};
return Tween;
}(Animation);
_setDefaults(Tween.prototype, {
_targets: [],
_lazy: 0,
_startAt: 0,
_op: 0,
_onInit: 0
});
_forEachName("staggerTo,staggerFrom,staggerFromTo", function (name) {
Tween[name] = function () {
var tl = new Timeline(),
params = _slice.call(arguments, 0);
params.splice(name === "staggerFromTo" ? 5 : 4, 0, 0);
return tl[name].apply(tl, params);
};
});
var _setterPlain = function _setterPlain(target, property, value) {
return target[property] = value;
},
_setterFunc = function _setterFunc(target, property, value) {
return target[property](value);
},
_setterFuncWithParam = function _setterFuncWithParam(target, property, value, data) {
return target[property](data.fp, value);
},
_setterAttribute = function _setterAttribute(target, property, value) {
return target.setAttribute(property, value);
},
_getSetter = function _getSetter(target, property) {
return _isFunction(target[property]) ? _setterFunc : _isUndefined(target[property]) && target.setAttribute ? _setterAttribute : _setterPlain;
},
_renderPlain = function _renderPlain(ratio, data) {
return data.set(data.t, data.p, Math.round((data.s + data.c * ratio) * 10000) / 10000, data);
},
_renderBoolean = function _renderBoolean(ratio, data) {
return data.set(data.t, data.p, !!(data.s + data.c * ratio), data);
},
_renderComplexString = function _renderComplexString(ratio, data) {
var pt = data._pt,
s = "";
if (!ratio && data.b) {
s = data.b;
} else if (ratio === 1 && data.e) {
s = data.e;
} else {
while (pt) {
s = pt.p + (pt.m ? pt.m(pt.s + pt.c * ratio) : Math.round((pt.s + pt.c * ratio) * 10000) / 10000) + s;
pt = pt._next;
}
s += data.c;
}
data.set(data.t, data.p, s, data);
},
_renderPropTweens = function _renderPropTweens(ratio, data) {
var pt = data._pt;
while (pt) {
pt.r(ratio, pt.d);
pt = pt._next;
}
},
_addPluginModifier = function _addPluginModifier(modifier, tween, target, property) {
var pt = this._pt,
next;
while (pt) {
next = pt._next;
pt.p === property && pt.modifier(modifier, tween, target);
pt = next;
}
},
_killPropTweensOf = function _killPropTweensOf(property) {
var pt = this._pt,
hasNonDependentRemaining,
next;
while (pt) {
next = pt._next;
if (pt.p === property && !pt.op || pt.op === property) {
_removeLinkedListItem(this, pt, "_pt");
} else if (!pt.dep) {
hasNonDependentRemaining = 1;
}
pt = next;
}
return !hasNonDependentRemaining;
},
_setterWithModifier = function _setterWithModifier(target, property, value, data) {
data.mSet(target, property, data.m.call(data.tween, value, data.mt), data);
},
_sortPropTweensByPriority = function _sortPropTweensByPriority(parent) {
var pt = parent._pt,
next,
pt2,
first,
last;
while (pt) {
next = pt._next;
pt2 = first;
while (pt2 && pt2.pr > pt.pr) {
pt2 = pt2._next;
}
if (pt._prev = pt2 ? pt2._prev : last) {
pt._prev._next = pt;
} else {
first = pt;
}
if (pt._next = pt2) {
pt2._prev = pt;
} else {
last = pt;
}
pt = next;
}
parent._pt = first;
};
var PropTween = function () {
function PropTween(next, target, prop, start, change, renderer, data, setter, priority) {
this.t = target;
this.s = start;
this.c = change;
this.p = prop;
this.r = renderer || _renderPlain;
this.d = data || this;
this.set = setter || _setterPlain;
this.pr = priority || 0;
this._next = next;
if (next) {
next._prev = this;
}
}
var _proto4 = PropTween.prototype;
_proto4.modifier = function modifier(func, tween, target) {
this.mSet = this.mSet || this.set;
this.set = _setterWithModifier;
this.m = func;
this.mt = target;
this.tween = tween;
};
return PropTween;
}();
_forEachName(_callbackNames + "parent,duration,ease,delay,overwrite,runBackwards,startAt,yoyo,immediateRender,repeat,repeatDelay,data,paused,reversed,lazy,callbackScope,stringFilter,id,yoyoEase,stagger,inherit,repeatRefresh,keyframes,autoRevert,scrollTrigger", function (name) {
return _reservedProps[name] = 1;
});
_globals.TweenMax = _globals.TweenLite = Tween;
_globals.TimelineLite = _globals.TimelineMax = Timeline;
_globalTimeline = new Timeline({
sortChildren: false,
defaults: _defaults,
autoRemoveChildren: true,
id: "root",
smoothChildTiming: true
});
_config.stringFilter = _colorStringFilter;
var _gsap = {
registerPlugin: function registerPlugin() {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
args.forEach(function (config) {
return _createPlugin(config);
});
},
timeline: function timeline(vars) {
return new Timeline(vars);
},
getTweensOf: function getTweensOf(targets, onlyActive) {
return _globalTimeline.getTweensOf(targets, onlyActive);
},
getProperty: function getProperty(target, property, unit, uncache) {
_isString(target) && (target = toArray(target)[0]);
var getter = _getCache(target || {}).get,
format = unit ? _passThrough : _numericIfPossible;
unit === "native" && (unit = "");
return !target ? target : !property ? function (property, unit, uncache) {
return format((_plugins[property] && _plugins[property].get || getter)(target, property, unit, uncache));
} : format((_plugins[property] && _plugins[property].get || getter)(target, property, unit, uncache));
},
quickSetter: function quickSetter(target, property, unit) {
target = toArray(target);
if (target.length > 1) {
var setters = target.map(function (t) {
return gsap.quickSetter(t, property, unit);
}),
l = setters.length;
return function (value) {
var i = l;
while (i--) {
setters[i](value);
}
};
}
target = target[0] || {};
var Plugin = _plugins[property],
cache = _getCache(target),
p = cache.harness && (cache.harness.aliases || {})[property] || property,
setter = Plugin ? function (value) {
var p = new Plugin();
_quickTween._pt = 0;
p.init(target, unit ? value + unit : value, _quickTween, 0, [target]);
p.render(1, p);
_quickTween._pt && _renderPropTweens(1, _quickTween);
} : cache.set(target, p);
return Plugin ? setter : function (value) {
return setter(target, p, unit ? value + unit : value, cache, 1);
};
},
isTweening: function isTweening(targets) {
return _globalTimeline.getTweensOf(targets, true).length > 0;
},
defaults: function defaults(value) {
value && value.ease && (value.ease = _parseEase(value.ease, _defaults.ease));
return _mergeDeep(_defaults, value || {});
},
config: function config(value) {
return _mergeDeep(_config, value || {});
},
registerEffect: function registerEffect(_ref2) {
var name = _ref2.name,
effect = _ref2.effect,
plugins = _ref2.plugins,
defaults = _ref2.defaults,
extendTimeline = _ref2.extendTimeline;
(plugins || "").split(",").forEach(function (pluginName) {
return pluginName && !_plugins[pluginName] && !_globals[pluginName] && _warn(name + " effect requires " + pluginName + " plugin.");
});
_effects[name] = function (targets, vars, tl) {
return effect(toArray(targets), _setDefaults(vars || {}, defaults), tl);
};
if (extendTimeline) {
Timeline.prototype[name] = function (targets, vars, position) {
return this.add(_effects[name](targets, _isObject(vars) ? vars : (position = vars) && {}, this), position);
};
}
},
registerEase: function registerEase(name, ease) {
_easeMap[name] = _parseEase(ease);
},
parseEase: function parseEase(ease, defaultEase) {
return arguments.length ? _parseEase(ease, defaultEase) : _easeMap;
},
getById: function getById(id) {
return _globalTimeline.getById(id);
},
exportRoot: function exportRoot(vars, includeDelayedCalls) {
if (vars === void 0) {
vars = {};
}
var tl = new Timeline(vars),
child,
next;
tl.smoothChildTiming = _isNotFalse(vars.smoothChildTiming);
_globalTimeline.remove(tl);
tl._dp = 0;
tl._time = tl._tTime = _globalTimeline._time;
child = _globalTimeline._first;
while (child) {
next = child._next;
if (includeDelayedCalls || !(!child._dur && child instanceof Tween && child.vars.onComplete === child._targets[0])) {
_addToTimeline(tl, child, child._start - child._delay);
}
child = next;
}
_addToTimeline(_globalTimeline, tl, 0);
return tl;
},
utils: {
wrap: wrap,
wrapYoyo: wrapYoyo,
distribute: distribute,
random: random,
snap: snap,
normalize: normalize,
getUnit: getUnit,
clamp: clamp,
splitColor: splitColor,
toArray: toArray,
mapRange: mapRange,
pipe: pipe,
unitize: unitize,
interpolate: interpolate,
shuffle: shuffle
},
install: _install,
effects: _effects,
ticker: _ticker,
updateRoot: Timeline.updateRoot,
plugins: _plugins,
globalTimeline: _globalTimeline,
core: {
PropTween: PropTween,
globals: _addGlobal,
Tween: Tween,
Timeline: Timeline,
Animation: Animation,
getCache: _getCache,
_removeLinkedListItem: _removeLinkedListItem,
suppressOverwrites: function suppressOverwrites(value) {
return _suppressOverwrites = value;
}
}
};
_forEachName("to,from,fromTo,delayedCall,set,killTweensOf", function (name) {
return _gsap[name] = Tween[name];
});
_ticker.add(Timeline.updateRoot);
_quickTween = _gsap.to({}, {
duration: 0
});
var _getPluginPropTween = function _getPluginPropTween(plugin, prop) {
var pt = plugin._pt;
while (pt && pt.p !== prop && pt.op !== prop && pt.fp !== prop) {
pt = pt._next;
}
return pt;
},
_addModifiers = function _addModifiers(tween, modifiers) {
var targets = tween._targets,
p,
i,
pt;
for (p in modifiers) {
i = targets.length;
while (i--) {
pt = tween._ptLookup[i][p];
if (pt && (pt = pt.d)) {
if (pt._pt) {
pt = _getPluginPropTween(pt, p);
}
pt && pt.modifier && pt.modifier(modifiers[p], tween, targets[i], p);
}
}
}
},
_buildModifierPlugin = function _buildModifierPlugin(name, modifier) {
return {
name: name,
rawVars: 1,
init: function init(target, vars, tween) {
tween._onInit = function (tween) {
var temp, p;
if (_isString(vars)) {
temp = {};
_forEachName(vars, function (name) {
return temp[name] = 1;
});
vars = temp;
}
if (modifier) {
temp = {};
for (p in vars) {
temp[p] = modifier(vars[p]);
}
vars = temp;
}
_addModifiers(tween, vars);
};
}
};
};
var gsap = _gsap.registerPlugin({
name: "attr",
init: function init(target, vars, tween, index, targets) {
var p, pt;
for (p in vars) {
pt = this.add(target, "setAttribute", (target.getAttribute(p) || 0) + "", vars[p], index, targets, 0, 0, p);
pt && (pt.op = p);
this._props.push(p);
}
}
}, {
name: "endArray",
init: function init(target, value) {
var i = value.length;
while (i--) {
this.add(target, i, target[i] || 0, value[i]);
}
}
}, _buildModifierPlugin("roundProps", _roundModifier), _buildModifierPlugin("modifiers"), _buildModifierPlugin("snap", snap)) || _gsap;
Tween.version = Timeline.version = gsap.version = "3.6.1";
_coreReady = 1;
if (_windowExists()) {
_wake();
}
var Power0 = _easeMap.Power0,
Power1 = _easeMap.Power1,
Power2 = _easeMap.Power2,
Power3 = _easeMap.Power3,
Power4 = _easeMap.Power4,
Linear = _easeMap.Linear,
Quad = _easeMap.Quad,
Cubic = _easeMap.Cubic,
Quart = _easeMap.Quart,
Quint = _easeMap.Quint,
Strong = _easeMap.Strong,
Elastic = _easeMap.Elastic,
Back = _easeMap.Back,
SteppedEase = _easeMap.SteppedEase,
Bounce = _easeMap.Bounce,
Sine = _easeMap.Sine,
Expo = _easeMap.Expo,
Circ = _easeMap.Circ;
var _win$1,
_doc$1,
_docElement,
_pluginInitted,
_tempDiv,
_tempDivStyler,
_recentSetterPlugin,
_windowExists$1 = function _windowExists() {
return typeof window !== "undefined";
},
_transformProps = {},
_RAD2DEG = 180 / Math.PI,
_DEG2RAD = Math.PI / 180,
_atan2 = Math.atan2,
_bigNum$1 = 1e8,
_capsExp = /([A-Z])/g,
_horizontalExp = /(?:left|right|width|margin|padding|x)/i,
_complexExp = /[\s,\(]\S/,
_propertyAliases = {
autoAlpha: "opacity,visibility",
scale: "scaleX,scaleY",
alpha: "opacity"
},
_renderCSSProp = function _renderCSSProp(ratio, data) {
return data.set(data.t, data.p, Math.round((data.s + data.c * ratio) * 10000) / 10000 + data.u, data);
},
_renderPropWithEnd = function _renderPropWithEnd(ratio, data) {
return data.set(data.t, data.p, ratio === 1 ? data.e : Math.round((data.s + data.c * ratio) * 10000) / 10000 + data.u, data);
},
_renderCSSPropWithBeginning = function _renderCSSPropWithBeginning(ratio, data) {
return data.set(data.t, data.p, ratio ? Math.round((data.s + data.c * ratio) * 10000) / 10000 + data.u : data.b, data);
},
_renderRoundedCSSProp = function _renderRoundedCSSProp(ratio, data) {
var value = data.s + data.c * ratio;
data.set(data.t, data.p, ~~(value + (value < 0 ? -.5 : .5)) + data.u, data);
},
_renderNonTweeningValue = function _renderNonTweeningValue(ratio, data) {
return data.set(data.t, data.p, ratio ? data.e : data.b, data);
},
_renderNonTweeningValueOnlyAtEnd = function _renderNonTweeningValueOnlyAtEnd(ratio, data) {
return data.set(data.t, data.p, ratio !== 1 ? data.b : data.e, data);
},
_setterCSSStyle = function _setterCSSStyle(target, property, value) {
return target.style[property] = value;
},
_setterCSSProp = function _setterCSSProp(target, property, value) {
return target.style.setProperty(property, value);
},
_setterTransform = function _setterTransform(target, property, value) {
return target._gsap[property] = value;
},
_setterScale = function _setterScale(target, property, value) {
return target._gsap.scaleX = target._gsap.scaleY = value;
},
_setterScaleWithRender = function _setterScaleWithRender(target, property, value, data, ratio) {
var cache = target._gsap;
cache.scaleX = cache.scaleY = value;
cache.renderTransform(ratio, cache);
},
_setterTransformWithRender = function _setterTransformWithRender(target, property, value, data, ratio) {
var cache = target._gsap;
cache[property] = value;
cache.renderTransform(ratio, cache);
},
_transformProp = "transform",
_transformOriginProp = _transformProp + "Origin",
_supports3D,
_createElement = function _createElement(type, ns) {
var e = _doc$1.createElementNS ? _doc$1.createElementNS((ns || "http://www.w3.org/1999/xhtml").replace(/^https/, "http"), type) : _doc$1.createElement(type);
return e.style ? e : _doc$1.createElement(type);
},
_getComputedProperty = function _getComputedProperty(target, property, skipPrefixFallback) {
var cs = getComputedStyle(target);
return cs[property] || cs.getPropertyValue(property.replace(_capsExp, "-$1").toLowerCase()) || cs.getPropertyValue(property) || !skipPrefixFallback && _getComputedProperty(target, _checkPropPrefix(property) || property, 1) || "";
},
_prefixes = "O,Moz,ms,Ms,Webkit".split(","),
_checkPropPrefix = function _checkPropPrefix(property, element, preferPrefix) {
var e = element || _tempDiv,
s = e.style,
i = 5;
if (property in s && !preferPrefix) {
return property;
}
property = property.charAt(0).toUpperCase() + property.substr(1);
while (i-- && !(_prefixes[i] + property in s)) {}
return i < 0 ? null : (i === 3 ? "ms" : i >= 0 ? _prefixes[i] : "") + property;
},
_initCore = function _initCore() {
if (_windowExists$1() && window.document) {
_win$1 = window;
_doc$1 = _win$1.document;
_docElement = _doc$1.documentElement;
_tempDiv = _createElement("div") || {
style: {}
};
_tempDivStyler = _createElement("div");
_transformProp = _checkPropPrefix(_transformProp);
_transformOriginProp = _transformProp + "Origin";
_tempDiv.style.cssText = "border-width:0;line-height:0;position:absolute;padding:0";
_supports3D = !!_checkPropPrefix("perspective");
_pluginInitted = 1;
}
},
_getBBoxHack = function _getBBoxHack(swapIfPossible) {
var svg = _createElement("svg", this.ownerSVGElement && this.ownerSVGElement.getAttribute("xmlns") || "http://www.w3.org/2000/svg"),
oldParent = this.parentNode,
oldSibling = this.nextSibling,
oldCSS = this.style.cssText,
bbox;
_docElement.appendChild(svg);
svg.appendChild(this);
this.style.display = "block";
if (swapIfPossible) {
try {
bbox = this.getBBox();
this._gsapBBox = this.getBBox;
this.getBBox = _getBBoxHack;
} catch (e) {}
} else if (this._gsapBBox) {
bbox = this._gsapBBox();
}
if (oldParent) {
if (oldSibling) {
oldParent.insertBefore(this, oldSibling);
} else {
oldParent.appendChild(this);
}
}
_docElement.removeChild(svg);
this.style.cssText = oldCSS;
return bbox;
},
_getAttributeFallbacks = function _getAttributeFallbacks(target, attributesArray) {
var i = attributesArray.length;
while (i--) {
if (target.hasAttribute(attributesArray[i])) {
return target.getAttribute(attributesArray[i]);
}
}
},
_getBBox = function _getBBox(target) {
var bounds;
try {
bounds = target.getBBox();
} catch (error) {
bounds = _getBBoxHack.call(target, true);
}
bounds && (bounds.width || bounds.height) || target.getBBox === _getBBoxHack || (bounds = _getBBoxHack.call(target, true));
return bounds && !bounds.width && !bounds.x && !bounds.y ? {
x: +_getAttributeFallbacks(target, ["x", "cx", "x1"]) || 0,
y: +_getAttributeFallbacks(target, ["y", "cy", "y1"]) || 0,
width: 0,
height: 0
} : bounds;
},
_isSVG = function _isSVG(e) {
return !!(e.getCTM && (!e.parentNode || e.ownerSVGElement) && _getBBox(e));
},
_removeProperty = function _removeProperty(target, property) {
if (property) {
var style = target.style;
if (property in _transformProps && property !== _transformOriginProp) {
property = _transformProp;
}
if (style.removeProperty) {
if (property.substr(0, 2) === "ms" || property.substr(0, 6) === "webkit") {
property = "-" + property;
}
style.removeProperty(property.replace(_capsExp, "-$1").toLowerCase());
} else {
style.removeAttribute(property);
}
}
},
_addNonTweeningPT = function _addNonTweeningPT(plugin, target, property, beginning, end, onlySetAtEnd) {
var pt = new PropTween(plugin._pt, target, property, 0, 1, onlySetAtEnd ? _renderNonTweeningValueOnlyAtEnd : _renderNonTweeningValue);
plugin._pt = pt;
pt.b = beginning;
pt.e = end;
plugin._props.push(property);
return pt;
},
_nonConvertibleUnits = {
deg: 1,
rad: 1,
turn: 1
},
_convertToUnit = function _convertToUnit(target, property, value, unit) {
var curValue = parseFloat(value) || 0,
curUnit = (value + "").trim().substr((curValue + "").length) || "px",
style = _tempDiv.style,
horizontal = _horizontalExp.test(property),
isRootSVG = target.tagName.toLowerCase() === "svg",
measureProperty = (isRootSVG ? "client" : "offset") + (horizontal ? "Width" : "Height"),
amount = 100,
toPixels = unit === "px",
toPercent = unit === "%",
px,
parent,
cache,
isSVG;
if (unit === curUnit || !curValue || _nonConvertibleUnits[unit] || _nonConvertibleUnits[curUnit]) {
return curValue;
}
curUnit !== "px" && !toPixels && (curValue = _convertToUnit(target, property, value, "px"));
isSVG = target.getCTM && _isSVG(target);
if ((toPercent || curUnit === "%") && (_transformProps[property] || ~property.indexOf("adius"))) {
px = isSVG ? target.getBBox()[horizontal ? "width" : "height"] : target[measureProperty];
return _round(toPercent ? curValue / px * amount : curValue / 100 * px);
}
style[horizontal ? "width" : "height"] = amount + (toPixels ? curUnit : unit);
parent = ~property.indexOf("adius") || unit === "em" && target.appendChild && !isRootSVG ? target : target.parentNode;
if (isSVG) {
parent = (target.ownerSVGElement || {}).parentNode;
}
if (!parent || parent === _doc$1 || !parent.appendChild) {
parent = _doc$1.body;
}
cache = parent._gsap;
if (cache && toPercent && cache.width && horizontal && cache.time === _ticker.time) {
return _round(curValue / cache.width * amount);
} else {
(toPercent || curUnit === "%") && (style.position = _getComputedProperty(target, "position"));
parent === target && (style.position = "static");
parent.appendChild(_tempDiv);
px = _tempDiv[measureProperty];
parent.removeChild(_tempDiv);
style.position = "absolute";
if (horizontal && toPercent) {
cache = _getCache(parent);
cache.time = _ticker.time;
cache.width = parent[measureProperty];
}
}
return _round(toPixels ? px * curValue / amount : px && curValue ? amount / px * curValue : 0);
},
_get = function _get(target, property, unit, uncache) {
var value;
_pluginInitted || _initCore();
if (property in _propertyAliases && property !== "transform") {
property = _propertyAliases[property];
if (~property.indexOf(",")) {
property = property.split(",")[0];
}
}
if (_transformProps[property] && property !== "transform") {
value = _parseTransform(target, uncache);
value = property !== "transformOrigin" ? value[property] : _firstTwoOnly(_getComputedProperty(target, _transformOriginProp)) + " " + value.zOrigin + "px";
} else {
value = target.style[property];
if (!value || value === "auto" || uncache || ~(value + "").indexOf("calc(")) {
value = _specialProps[property] && _specialProps[property](target, property, unit) || _getComputedProperty(target, property) || _getProperty(target, property) || (property === "opacity" ? 1 : 0);
}
}
return unit && !~(value + "").trim().indexOf(" ") ? _convertToUnit(target, property, value, unit) + unit : value;
},
_tweenComplexCSSString = function _tweenComplexCSSString(target, prop, start, end) {
if (!start || start === "none") {
var p = _checkPropPrefix(prop, target, 1),
s = p && _getComputedProperty(target, p, 1);
if (s && s !== start) {
prop = p;
start = s;
} else if (prop === "borderColor") {
start = _getComputedProperty(target, "borderTopColor");
}
}
var pt = new PropTween(this._pt, target.style, prop, 0, 1, _renderComplexString),
index = 0,
matchIndex = 0,
a,
result,
startValues,
startNum,
color,
startValue,
endValue,
endNum,
chunk,
endUnit,
startUnit,
relative,
endValues;
pt.b = start;
pt.e = end;
start += "";
end += "";
if (end === "auto") {
target.style[prop] = end;
end = _getComputedProperty(target, prop) || end;
target.style[prop] = start;
}
a = [start, end];
_colorStringFilter(a);
start = a[0];
end = a[1];
startValues = start.match(_numWithUnitExp) || [];
endValues = end.match(_numWithUnitExp) || [];
if (endValues.length) {
while (result = _numWithUnitExp.exec(end)) {
endValue = result[0];
chunk = end.substring(index, result.index);
if (color) {
color = (color + 1) % 5;
} else if (chunk.substr(-5) === "rgba(" || chunk.substr(-5) === "hsla(") {
color = 1;
}
if (endValue !== (startValue = startValues[matchIndex++] || "")) {
startNum = parseFloat(startValue) || 0;
startUnit = startValue.substr((startNum + "").length);
relative = endValue.charAt(1) === "=" ? +(endValue.charAt(0) + "1") : 0;
if (relative) {
endValue = endValue.substr(2);
}
endNum = parseFloat(endValue);
endUnit = endValue.substr((endNum + "").length);
index = _numWithUnitExp.lastIndex - endUnit.length;
if (!endUnit) {
endUnit = endUnit || _config.units[prop] || startUnit;
if (index === end.length) {
end += endUnit;
pt.e += endUnit;
}
}
if (startUnit !== endUnit) {
startNum = _convertToUnit(target, prop, startValue, endUnit) || 0;
}
pt._pt = {
_next: pt._pt,
p: chunk || matchIndex === 1 ? chunk : ",",
s: startNum,
c: relative ? relative * endNum : endNum - startNum,
m: color && color < 4 || prop === "zIndex" ? Math.round : 0
};
}
}
pt.c = index < end.length ? end.substring(index, end.length) : "";
} else {
pt.r = prop === "display" && end === "none" ? _renderNonTweeningValueOnlyAtEnd : _renderNonTweeningValue;
}
_relExp.test(end) && (pt.e = 0);
this._pt = pt;
return pt;
},
_keywordToPercent = {
top: "0%",
bottom: "100%",
left: "0%",
right: "100%",
center: "50%"
},
_convertKeywordsToPercentages = function _convertKeywordsToPercentages(value) {
var split = value.split(" "),
x = split[0],
y = split[1] || "50%";
if (x === "top" || x === "bottom" || y === "left" || y === "right") {
value = x;
x = y;
y = value;
}
split[0] = _keywordToPercent[x] || x;
split[1] = _keywordToPercent[y] || y;
return split.join(" ");
},
_renderClearProps = function _renderClearProps(ratio, data) {
if (data.tween && data.tween._time === data.tween._dur) {
var target = data.t,
style = target.style,
props = data.u,
cache = target._gsap,
prop,
clearTransforms,
i;
if (props === "all" || props === true) {
style.cssText = "";
clearTransforms = 1;
} else {
props = props.split(",");
i = props.length;
while (--i > -1) {
prop = props[i];
if (_transformProps[prop]) {
clearTransforms = 1;
prop = prop === "transformOrigin" ? _transformOriginProp : _transformProp;
}
_removeProperty(target, prop);
}
}
if (clearTransforms) {
_removeProperty(target, _transformProp);
if (cache) {
cache.svg && target.removeAttribute("transform");
_parseTransform(target, 1);
cache.uncache = 1;
}
}
}
},
_specialProps = {
clearProps: function clearProps(plugin, target, property, endValue, tween) {
if (tween.data !== "isFromStart") {
var pt = plugin._pt = new PropTween(plugin._pt, target, property, 0, 0, _renderClearProps);
pt.u = endValue;
pt.pr = -10;
pt.tween = tween;
plugin._props.push(property);
return 1;
}
}
},
_identity2DMatrix = [1, 0, 0, 1, 0, 0],
_rotationalProperties = {},
_isNullTransform = function _isNullTransform(value) {
return value === "matrix(1, 0, 0, 1, 0, 0)" || value === "none" || !value;
},
_getComputedTransformMatrixAsArray = function _getComputedTransformMatrixAsArray(target) {
var matrixString = _getComputedProperty(target, _transformProp);
return _isNullTransform(matrixString) ? _identity2DMatrix : matrixString.substr(7).match(_numExp).map(_round);
},
_getMatrix = function _getMatrix(target, force2D) {
var cache = target._gsap || _getCache(target),
style = target.style,
matrix = _getComputedTransformMatrixAsArray(target),
parent,
nextSibling,
temp,
addedToDOM;
if (cache.svg && target.getAttribute("transform")) {
temp = target.transform.baseVal.consolidate().matrix;
matrix = [temp.a, temp.b, temp.c, temp.d, temp.e, temp.f];
return matrix.join(",") === "1,0,0,1,0,0" ? _identity2DMatrix : matrix;
} else if (matrix === _identity2DMatrix && !target.offsetParent && target !== _docElement && !cache.svg) {
temp = style.display;
style.display = "block";
parent = target.parentNode;
if (!parent || !target.offsetParent) {
addedToDOM = 1;
nextSibling = target.nextSibling;
_docElement.appendChild(target);
}
matrix = _getComputedTransformMatrixAsArray(target);
temp ? style.display = temp : _removeProperty(target, "display");
if (addedToDOM) {
nextSibling ? parent.insertBefore(target, nextSibling) : parent ? parent.appendChild(target) : _docElement.removeChild(target);
}
}
return force2D && matrix.length > 6 ? [matrix[0], matrix[1], matrix[4], matrix[5], matrix[12], matrix[13]] : matrix;
},
_applySVGOrigin = function _applySVGOrigin(target, origin, originIsAbsolute, smooth, matrixArray, pluginToAddPropTweensTo) {
var cache = target._gsap,
matrix = matrixArray || _getMatrix(target, true),
xOriginOld = cache.xOrigin || 0,
yOriginOld = cache.yOrigin || 0,
xOffsetOld = cache.xOffset || 0,
yOffsetOld = cache.yOffset || 0,
a = matrix[0],
b = matrix[1],
c = matrix[2],
d = matrix[3],
tx = matrix[4],
ty = matrix[5],
originSplit = origin.split(" "),
xOrigin = parseFloat(originSplit[0]) || 0,
yOrigin = parseFloat(originSplit[1]) || 0,
bounds,
determinant,
x,
y;
if (!originIsAbsolute) {
bounds = _getBBox(target);
xOrigin = bounds.x + (~originSplit[0].indexOf("%") ? xOrigin / 100 * bounds.width : xOrigin);
yOrigin = bounds.y + (~(originSplit[1] || originSplit[0]).indexOf("%") ? yOrigin / 100 * bounds.height : yOrigin);
} else if (matrix !== _identity2DMatrix && (determinant = a * d - b * c)) {
x = xOrigin * (d / determinant) + yOrigin * (-c / determinant) + (c * ty - d * tx) / determinant;
y = xOrigin * (-b / determinant) + yOrigin * (a / determinant) - (a * ty - b * tx) / determinant;
xOrigin = x;
yOrigin = y;
}
if (smooth || smooth !== false && cache.smooth) {
tx = xOrigin - xOriginOld;
ty = yOrigin - yOriginOld;
cache.xOffset = xOffsetOld + (tx * a + ty * c) - tx;
cache.yOffset = yOffsetOld + (tx * b + ty * d) - ty;
} else {
cache.xOffset = cache.yOffset = 0;
}
cache.xOrigin = xOrigin;
cache.yOrigin = yOrigin;
cache.smooth = !!smooth;
cache.origin = origin;
cache.originIsAbsolute = !!originIsAbsolute;
target.style[_transformOriginProp] = "0px 0px";
if (pluginToAddPropTweensTo) {
_addNonTweeningPT(pluginToAddPropTweensTo, cache, "xOrigin", xOriginOld, xOrigin);
_addNonTweeningPT(pluginToAddPropTweensTo, cache, "yOrigin", yOriginOld, yOrigin);
_addNonTweeningPT(pluginToAddPropTweensTo, cache, "xOffset", xOffsetOld, cache.xOffset);
_addNonTweeningPT(pluginToAddPropTweensTo, cache, "yOffset", yOffsetOld, cache.yOffset);
}
target.setAttribute("data-svg-origin", xOrigin + " " + yOrigin);
},
_parseTransform = function _parseTransform(target, uncache) {
var cache = target._gsap || new GSCache(target);
if ("x" in cache && !uncache && !cache.uncache) {
return cache;
}
var style = target.style,
invertedScaleX = cache.scaleX < 0,
px = "px",
deg = "deg",
origin = _getComputedProperty(target, _transformOriginProp) || "0",
x,
y,
z,
scaleX,
scaleY,
rotation,
rotationX,
rotationY,
skewX,
skewY,
perspective,
xOrigin,
yOrigin,
matrix,
angle,
cos,
sin,
a,
b,
c,
d,
a12,
a22,
t1,
t2,
t3,
a13,
a23,
a33,
a42,
a43,
a32;
x = y = z = rotation = rotationX = rotationY = skewX = skewY = perspective = 0;
scaleX = scaleY = 1;
cache.svg = !!(target.getCTM && _isSVG(target));
matrix = _getMatrix(target, cache.svg);
if (cache.svg) {
t1 = !cache.uncache && !uncache && target.getAttribute("data-svg-origin");
_applySVGOrigin(target, t1 || origin, !!t1 || cache.originIsAbsolute, cache.smooth !== false, matrix);
}
xOrigin = cache.xOrigin || 0;
yOrigin = cache.yOrigin || 0;
if (matrix !== _identity2DMatrix) {
a = matrix[0];
b = matrix[1];
c = matrix[2];
d = matrix[3];
x = a12 = matrix[4];
y = a22 = matrix[5];
if (matrix.length === 6) {
scaleX = Math.sqrt(a * a + b * b);
scaleY = Math.sqrt(d * d + c * c);
rotation = a || b ? _atan2(b, a) * _RAD2DEG : 0;
skewX = c || d ? _atan2(c, d) * _RAD2DEG + rotation : 0;
skewX && (scaleY *= Math.abs(Math.cos(skewX * _DEG2RAD)));
if (cache.svg) {
x -= xOrigin - (xOrigin * a + yOrigin * c);
y -= yOrigin - (xOrigin * b + yOrigin * d);
}
} else {
a32 = matrix[6];
a42 = matrix[7];
a13 = matrix[8];
a23 = matrix[9];
a33 = matrix[10];
a43 = matrix[11];
x = matrix[12];
y = matrix[13];
z = matrix[14];
angle = _atan2(a32, a33);
rotationX = angle * _RAD2DEG;
if (angle) {
cos = Math.cos(-angle);
sin = Math.sin(-angle);
t1 = a12 * cos + a13 * sin;
t2 = a22 * cos + a23 * sin;
t3 = a32 * cos + a33 * sin;
a13 = a12 * -sin + a13 * cos;
a23 = a22 * -sin + a23 * cos;
a33 = a32 * -sin + a33 * cos;
a43 = a42 * -sin + a43 * cos;
a12 = t1;
a22 = t2;
a32 = t3;
}
angle = _atan2(-c, a33);
rotationY = angle * _RAD2DEG;
if (angle) {
cos = Math.cos(-angle);
sin = Math.sin(-angle);
t1 = a * cos - a13 * sin;
t2 = b * cos - a23 * sin;
t3 = c * cos - a33 * sin;
a43 = d * sin + a43 * cos;
a = t1;
b = t2;
c = t3;
}
angle = _atan2(b, a);
rotation = angle * _RAD2DEG;
if (angle) {
cos = Math.cos(angle);
sin = Math.sin(angle);
t1 = a * cos + b * sin;
t2 = a12 * cos + a22 * sin;
b = b * cos - a * sin;
a22 = a22 * cos - a12 * sin;
a = t1;
a12 = t2;
}
if (rotationX && Math.abs(rotationX) + Math.abs(rotation) > 359.9) {
rotationX = rotation = 0;
rotationY = 180 - rotationY;
}
scaleX = _round(Math.sqrt(a * a + b * b + c * c));
scaleY = _round(Math.sqrt(a22 * a22 + a32 * a32));
angle = _atan2(a12, a22);
skewX = Math.abs(angle) > 0.0002 ? angle * _RAD2DEG : 0;
perspective = a43 ? 1 / (a43 < 0 ? -a43 : a43) : 0;
}
if (cache.svg) {
t1 = target.getAttribute("transform");
cache.forceCSS = target.setAttribute("transform", "") || !_isNullTransform(_getComputedProperty(target, _transformProp));
t1 && target.setAttribute("transform", t1);
}
}
if (Math.abs(skewX) > 90 && Math.abs(skewX) < 270) {
if (invertedScaleX) {
scaleX *= -1;
skewX += rotation <= 0 ? 180 : -180;
rotation += rotation <= 0 ? 180 : -180;
} else {
scaleY *= -1;
skewX += skewX <= 0 ? 180 : -180;
}
}
cache.x = x - ((cache.xPercent = x && (cache.xPercent || (Math.round(target.offsetWidth / 2) === Math.round(-x) ? -50 : 0))) ? target.offsetWidth * cache.xPercent / 100 : 0) + px;
cache.y = y - ((cache.yPercent = y && (cache.yPercent || (Math.round(target.offsetHeight / 2) === Math.round(-y) ? -50 : 0))) ? target.offsetHeight * cache.yPercent / 100 : 0) + px;
cache.z = z + px;
cache.scaleX = _round(scaleX);
cache.scaleY = _round(scaleY);
cache.rotation = _round(rotation) + deg;
cache.rotationX = _round(rotationX) + deg;
cache.rotationY = _round(rotationY) + deg;
cache.skewX = skewX + deg;
cache.skewY = skewY + deg;
cache.transformPerspective = perspective + px;
if (cache.zOrigin = parseFloat(origin.split(" ")[2]) || 0) {
style[_transformOriginProp] = _firstTwoOnly(origin);
}
cache.xOffset = cache.yOffset = 0;
cache.force3D = _config.force3D;
cache.renderTransform = cache.svg ? _renderSVGTransforms : _supports3D ? _renderCSSTransforms : _renderNon3DTransforms;
cache.uncache = 0;
return cache;
},
_firstTwoOnly = function _firstTwoOnly(value) {
return (value = value.split(" "))[0] + " " + value[1];
},
_addPxTranslate = function _addPxTranslate(target, start, value) {
var unit = getUnit(start);
return _round(parseFloat(start) + parseFloat(_convertToUnit(target, "x", value + "px", unit))) + unit;
},
_renderNon3DTransforms = function _renderNon3DTransforms(ratio, cache) {
cache.z = "0px";
cache.rotationY = cache.rotationX = "0deg";
cache.force3D = 0;
_renderCSSTransforms(ratio, cache);
},
_zeroDeg = "0deg",
_zeroPx = "0px",
_endParenthesis = ") ",
_renderCSSTransforms = function _renderCSSTransforms(ratio, cache) {
var _ref = cache || this,
xPercent = _ref.xPercent,
yPercent = _ref.yPercent,
x = _ref.x,
y = _ref.y,
z = _ref.z,
rotation = _ref.rotation,
rotationY = _ref.rotationY,
rotationX = _ref.rotationX,
skewX = _ref.skewX,
skewY = _ref.skewY,
scaleX = _ref.scaleX,
scaleY = _ref.scaleY,
transformPerspective = _ref.transformPerspective,
force3D = _ref.force3D,
target = _ref.target,
zOrigin = _ref.zOrigin,
transforms = "",
use3D = force3D === "auto" && ratio && ratio !== 1 || force3D === true;
if (zOrigin && (rotationX !== _zeroDeg || rotationY !== _zeroDeg)) {
var angle = parseFloat(rotationY) * _DEG2RAD,
a13 = Math.sin(angle),
a33 = Math.cos(angle),
cos;
angle = parseFloat(rotationX) * _DEG2RAD;
cos = Math.cos(angle);
x = _addPxTranslate(target, x, a13 * cos * -zOrigin);
y = _addPxTranslate(target, y, -Math.sin(angle) * -zOrigin);
z = _addPxTranslate(target, z, a33 * cos * -zOrigin + zOrigin);
}
if (transformPerspective !== _zeroPx) {
transforms += "perspective(" + transformPerspective + _endParenthesis;
}
if (xPercent || yPercent) {
transforms += "translate(" + xPercent + "%, " + yPercent + "%) ";
}
if (use3D || x !== _zeroPx || y !== _zeroPx || z !== _zeroPx) {
transforms += z !== _zeroPx || use3D ? "translate3d(" + x + ", " + y + ", " + z + ") " : "translate(" + x + ", " + y + _endParenthesis;
}
if (rotation !== _zeroDeg) {
transforms += "rotate(" + rotation + _endParenthesis;
}
if (rotationY !== _zeroDeg) {
transforms += "rotateY(" + rotationY + _endParenthesis;
}
if (rotationX !== _zeroDeg) {
transforms += "rotateX(" + rotationX + _endParenthesis;
}
if (skewX !== _zeroDeg || skewY !== _zeroDeg) {
transforms += "skew(" + skewX + ", " + skewY + _endParenthesis;
}
if (scaleX !== 1 || scaleY !== 1) {
transforms += "scale(" + scaleX + ", " + scaleY + _endParenthesis;
}
target.style[_transformProp] = transforms || "translate(0, 0)";
},
_renderSVGTransforms = function _renderSVGTransforms(ratio, cache) {
var _ref2 = cache || this,
xPercent = _ref2.xPercent,
yPercent = _ref2.yPercent,
x = _ref2.x,
y = _ref2.y,
rotation = _ref2.rotation,
skewX = _ref2.skewX,
skewY = _ref2.skewY,
scaleX = _ref2.scaleX,
scaleY = _ref2.scaleY,
target = _ref2.target,
xOrigin = _ref2.xOrigin,
yOrigin = _ref2.yOrigin,
xOffset = _ref2.xOffset,
yOffset = _ref2.yOffset,
forceCSS = _ref2.forceCSS,
tx = parseFloat(x),
ty = parseFloat(y),
a11,
a21,
a12,
a22,
temp;
rotation = parseFloat(rotation);
skewX = parseFloat(skewX);
skewY = parseFloat(skewY);
if (skewY) {
skewY = parseFloat(skewY);
skewX += skewY;
rotation += skewY;
}
if (rotation || skewX) {
rotation *= _DEG2RAD;
skewX *= _DEG2RAD;
a11 = Math.cos(rotation) * scaleX;
a21 = Math.sin(rotation) * scaleX;
a12 = Math.sin(rotation - skewX) * -scaleY;
a22 = Math.cos(rotation - skewX) * scaleY;
if (skewX) {
skewY *= _DEG2RAD;
temp = Math.tan(skewX - skewY);
temp = Math.sqrt(1 + temp * temp);
a12 *= temp;
a22 *= temp;
if (skewY) {
temp = Math.tan(skewY);
temp = Math.sqrt(1 + temp * temp);
a11 *= temp;
a21 *= temp;
}
}
a11 = _round(a11);
a21 = _round(a21);
a12 = _round(a12);
a22 = _round(a22);
} else {
a11 = scaleX;
a22 = scaleY;
a21 = a12 = 0;
}
if (tx && !~(x + "").indexOf("px") || ty && !~(y + "").indexOf("px")) {
tx = _convertToUnit(target, "x", x, "px");
ty = _convertToUnit(target, "y", y, "px");
}
if (xOrigin || yOrigin || xOffset || yOffset) {
tx = _round(tx + xOrigin - (xOrigin * a11 + yOrigin * a12) + xOffset);
ty = _round(ty + yOrigin - (xOrigin * a21 + yOrigin * a22) + yOffset);
}
if (xPercent || yPercent) {
temp = target.getBBox();
tx = _round(tx + xPercent / 100 * temp.width);
ty = _round(ty + yPercent / 100 * temp.height);
}
temp = "matrix(" + a11 + "," + a21 + "," + a12 + "," + a22 + "," + tx + "," + ty + ")";
target.setAttribute("transform", temp);
forceCSS && (target.style[_transformProp] = temp);
},
_addRotationalPropTween = function _addRotationalPropTween(plugin, target, property, startNum, endValue, relative) {
var cap = 360,
isString = _isString(endValue),
endNum = parseFloat(endValue) * (isString && ~endValue.indexOf("rad") ? _RAD2DEG : 1),
change = relative ? endNum * relative : endNum - startNum,
finalValue = startNum + change + "deg",
direction,
pt;
if (isString) {
direction = endValue.split("_")[1];
if (direction === "short") {
change %= cap;
if (change !== change % (cap / 2)) {
change += change < 0 ? cap : -cap;
}
}
if (direction === "cw" && change < 0) {
change = (change + cap * _bigNum$1) % cap - ~~(change / cap) * cap;
} else if (direction === "ccw" && change > 0) {
change = (change - cap * _bigNum$1) % cap - ~~(change / cap) * cap;
}
}
plugin._pt = pt = new PropTween(plugin._pt, target, property, startNum, change, _renderPropWithEnd);
pt.e = finalValue;
pt.u = "deg";
plugin._props.push(property);
return pt;
},
_assign = function _assign(target, source) {
for (var p in source) {
target[p] = source[p];
}
return target;
},
_addRawTransformPTs = function _addRawTransformPTs(plugin, transforms, target) {
var startCache = _assign({}, target._gsap),
exclude = "perspective,force3D,transformOrigin,svgOrigin",
style = target.style,
endCache,
p,
startValue,
endValue,
startNum,
endNum,
startUnit,
endUnit;
if (startCache.svg) {
startValue = target.getAttribute("transform");
target.setAttribute("transform", "");
style[_transformProp] = transforms;
endCache = _parseTransform(target, 1);
_removeProperty(target, _transformProp);
target.setAttribute("transform", startValue);
} else {
startValue = getComputedStyle(target)[_transformProp];
style[_transformProp] = transforms;
endCache = _parseTransform(target, 1);
style[_transformProp] = startValue;
}
for (p in _transformProps) {
startValue = startCache[p];
endValue = endCache[p];
if (startValue !== endValue && exclude.indexOf(p) < 0) {
startUnit = getUnit(startValue);
endUnit = getUnit(endValue);
startNum = startUnit !== endUnit ? _convertToUnit(target, p, startValue, endUnit) : parseFloat(startValue);
endNum = parseFloat(endValue);
plugin._pt = new PropTween(plugin._pt, endCache, p, startNum, endNum - startNum, _renderCSSProp);
plugin._pt.u = endUnit || 0;
plugin._props.push(p);
}
}
_assign(endCache, startCache);
};
_forEachName("padding,margin,Width,Radius", function (name, index) {
var t = "Top",
r = "Right",
b = "Bottom",
l = "Left",
props = (index < 3 ? [t, r, b, l] : [t + l, t + r, b + r, b + l]).map(function (side) {
return index < 2 ? name + side : "border" + side + name;
});
_specialProps[index > 1 ? "border" + name : name] = function (plugin, target, property, endValue, tween) {
var a, vars;
if (arguments.length < 4) {
a = props.map(function (prop) {
return _get(plugin, prop, property);
});
vars = a.join(" ");
return vars.split(a[0]).length === 5 ? a[0] : vars;
}
a = (endValue + "").split(" ");
vars = {};
props.forEach(function (prop, i) {
return vars[prop] = a[i] = a[i] || a[(i - 1) / 2 | 0];
});
plugin.init(target, vars, tween);
};
});
var CSSPlugin = {
name: "css",
register: _initCore,
targetTest: function targetTest(target) {
return target.style && target.nodeType;
},
init: function init(target, vars, tween, index, targets) {
var props = this._props,
style = target.style,
startAt = tween.vars.startAt,
startValue,
endValue,
endNum,
startNum,
type,
specialProp,
p,
startUnit,
endUnit,
relative,
isTransformRelated,
transformPropTween,
cache,
smooth,
hasPriority;
_pluginInitted || _initCore();
for (p in vars) {
if (p === "autoRound") {
continue;
}
endValue = vars[p];
if (_plugins[p] && _checkPlugin(p, vars, tween, index, target, targets)) {
continue;
}
type = typeof endValue;
specialProp = _specialProps[p];
if (type === "function") {
endValue = endValue.call(tween, index, target, targets);
type = typeof endValue;
}
if (type === "string" && ~endValue.indexOf("random(")) {
endValue = _replaceRandom(endValue);
}
if (specialProp) {
specialProp(this, target, p, endValue, tween) && (hasPriority = 1);
} else if (p.substr(0, 2) === "--") {
startValue = (getComputedStyle(target).getPropertyValue(p) + "").trim();
endValue += "";
_colorExp.lastIndex = 0;
if (!_colorExp.test(startValue)) {
startUnit = getUnit(startValue);
endUnit = getUnit(endValue);
}
endUnit ? startUnit !== endUnit && (startValue = _convertToUnit(target, p, startValue, endUnit) + endUnit) : startUnit && (endValue += startUnit);
this.add(style, "setProperty", startValue, endValue, index, targets, 0, 0, p);
} else if (type !== "undefined") {
if (startAt && p in startAt) {
startValue = typeof startAt[p] === "function" ? startAt[p].call(tween, index, target, targets) : startAt[p];
p in _config.units && !getUnit(startValue) && (startValue += _config.units[p]);
(startValue + "").charAt(1) === "=" && (startValue = _get(target, p));
} else {
startValue = _get(target, p);
}
startNum = parseFloat(startValue);
relative = type === "string" && endValue.charAt(1) === "=" ? +(endValue.charAt(0) + "1") : 0;
relative && (endValue = endValue.substr(2));
endNum = parseFloat(endValue);
if (p in _propertyAliases) {
if (p === "autoAlpha") {
if (startNum === 1 && _get(target, "visibility") === "hidden" && endNum) {
startNum = 0;
}
_addNonTweeningPT(this, style, "visibility", startNum ? "inherit" : "hidden", endNum ? "inherit" : "hidden", !endNum);
}
if (p !== "scale" && p !== "transform") {
p = _propertyAliases[p];
~p.indexOf(",") && (p = p.split(",")[0]);
}
}
isTransformRelated = p in _transformProps;
if (isTransformRelated) {
if (!transformPropTween) {
cache = target._gsap;
cache.renderTransform && !vars.parseTransform || _parseTransform(target, vars.parseTransform);
smooth = vars.smoothOrigin !== false && cache.smooth;
transformPropTween = this._pt = new PropTween(this._pt, style, _transformProp, 0, 1, cache.renderTransform, cache, 0, -1);
transformPropTween.dep = 1;
}
if (p === "scale") {
this._pt = new PropTween(this._pt, cache, "scaleY", cache.scaleY, relative ? relative * endNum : endNum - cache.scaleY);
props.push("scaleY", p);
p += "X";
} else if (p === "transformOrigin") {
endValue = _convertKeywordsToPercentages(endValue);
if (cache.svg) {
_applySVGOrigin(target, endValue, 0, smooth, 0, this);
} else {
endUnit = parseFloat(endValue.split(" ")[2]) || 0;
endUnit !== cache.zOrigin && _addNonTweeningPT(this, cache, "zOrigin", cache.zOrigin, endUnit);
_addNonTweeningPT(this, style, p, _firstTwoOnly(startValue), _firstTwoOnly(endValue));
}
continue;
} else if (p === "svgOrigin") {
_applySVGOrigin(target, endValue, 1, smooth, 0, this);
continue;
} else if (p in _rotationalProperties) {
_addRotationalPropTween(this, cache, p, startNum, endValue, relative);
continue;
} else if (p === "smoothOrigin") {
_addNonTweeningPT(this, cache, "smooth", cache.smooth, endValue);
continue;
} else if (p === "force3D") {
cache[p] = endValue;
continue;
} else if (p === "transform") {
_addRawTransformPTs(this, endValue, target);
continue;
}
} else if (!(p in style)) {
p = _checkPropPrefix(p) || p;
}
if (isTransformRelated || (endNum || endNum === 0) && (startNum || startNum === 0) && !_complexExp.test(endValue) && p in style) {
startUnit = (startValue + "").substr((startNum + "").length);
endNum || (endNum = 0);
endUnit = getUnit(endValue) || (p in _config.units ? _config.units[p] : startUnit);
startUnit !== endUnit && (startNum = _convertToUnit(target, p, startValue, endUnit));
this._pt = new PropTween(this._pt, isTransformRelated ? cache : style, p, startNum, relative ? relative * endNum : endNum - startNum, !isTransformRelated && (endUnit === "px" || p === "zIndex") && vars.autoRound !== false ? _renderRoundedCSSProp : _renderCSSProp);
this._pt.u = endUnit || 0;
if (startUnit !== endUnit) {
this._pt.b = startValue;
this._pt.r = _renderCSSPropWithBeginning;
}
} else if (!(p in style)) {
if (p in target) {
this.add(target, p, target[p], endValue, index, targets);
} else {
_missingPlugin(p, endValue);
continue;
}
} else {
_tweenComplexCSSString.call(this, target, p, startValue, endValue);
}
props.push(p);
}
}
hasPriority && _sortPropTweensByPriority(this);
},
get: _get,
aliases: _propertyAliases,
getSetter: function getSetter(target, property, plugin) {
var p = _propertyAliases[property];
p && p.indexOf(",") < 0 && (property = p);
return property in _transformProps && property !== _transformOriginProp && (target._gsap.x || _get(target, "x")) ? plugin && _recentSetterPlugin === plugin ? property === "scale" ? _setterScale : _setterTransform : (_recentSetterPlugin = plugin || {}) && (property === "scale" ? _setterScaleWithRender : _setterTransformWithRender) : target.style && !_isUndefined(target.style[property]) ? _setterCSSStyle : ~property.indexOf("-") ? _setterCSSProp : _getSetter(target, property);
},
core: {
_removeProperty: _removeProperty,
_getMatrix: _getMatrix
}
};
gsap.utils.checkPrefix = _checkPropPrefix;
(function (positionAndScale, rotation, others, aliases) {
var all = _forEachName(positionAndScale + "," + rotation + "," + others, function (name) {
_transformProps[name] = 1;
});
_forEachName(rotation, function (name) {
_config.units[name] = "deg";
_rotationalProperties[name] = 1;
});
_propertyAliases[all[13]] = positionAndScale + "," + rotation;
_forEachName(aliases, function (name) {
var split = name.split(":");
_propertyAliases[split[1]] = all[split[0]];
});
})("x,y,z,scale,scaleX,scaleY,xPercent,yPercent", "rotation,rotationX,rotationY,skewX,skewY", "transform,transformOrigin,svgOrigin,force3D,smoothOrigin,transformPerspective", "0:translateX,1:translateY,2:translateZ,8:rotate,8:rotationZ,8:rotateZ,9:rotateX,10:rotateY");
_forEachName("x,y,z,top,right,bottom,left,width,height,fontSize,padding,margin,perspective", function (name) {
_config.units[name] = "px";
});
gsap.registerPlugin(CSSPlugin);
var gsapWithCSS = gsap.registerPlugin(CSSPlugin) || gsap,
TweenMaxWithCSS = gsapWithCSS.core.Tween;
exports.Back = Back;
exports.Bounce = Bounce;
exports.CSSPlugin = CSSPlugin;
exports.Circ = Circ;
exports.Cubic = Cubic;
exports.Elastic = Elastic;
exports.Expo = Expo;
exports.Linear = Linear;
exports.Power0 = Power0;
exports.Power1 = Power1;
exports.Power2 = Power2;
exports.Power3 = Power3;
exports.Power4 = Power4;
exports.Quad = Quad;
exports.Quart = Quart;
exports.Quint = Quint;
exports.Sine = Sine;
exports.SteppedEase = SteppedEase;
exports.Strong = Strong;
exports.TimelineLite = Timeline;
exports.TimelineMax = Timeline;
exports.TweenLite = Tween;
exports.TweenMax = TweenMaxWithCSS;
exports.default = gsapWithCSS;
exports.gsap = gsapWithCSS;
if (typeof(window) === 'undefined' || window !== exports) {Object.defineProperty(exports, '__esModule', { value: true });} else {delete window.default;}
})));
(function(window, $) {
'use strict';
var counter = 0,
$headCache = $('head'),
oldBigText = window.BigText,
oldjQueryMethod = $.fn.bigtext,
BigText = {
DEBUG_MODE: false,
DEFAULT_MIN_FONT_SIZE_PX: null,
DEFAULT_MAX_FONT_SIZE_PX: 528,
GLOBAL_STYLE_ID: 'bigtext-style',
STYLE_ID: 'bigtext-id',
LINE_CLASS_PREFIX: 'bigtext-line',
EXEMPT_CLASS: 'bigtext-exempt',
noConflict: function(restore)
{
if(restore) {
$.fn.bigtext = oldjQueryMethod;
window.BigText = oldBigText;
}
return BigText;
},
supports: {
wholeNumberFontSizeOnly: (function() {
if( !( 'getComputedStyle' in window ) ) {
return true;
}
var test = $('
').css({
position: 'absolute',
'font-size': '14.1px'
}).insertBefore( $('script').eq(0) ),
computedStyle = window.getComputedStyle( test[0], null );
var ret = computedStyle && computedStyle.getPropertyValue( 'font-size' ) === '14px';
test.remove();
return ret;
})()
},
init: function() {
if(!$('#'+BigText.GLOBAL_STYLE_ID).length) {
$headCache.append(BigText.generateStyleTag(BigText.GLOBAL_STYLE_ID, ['.bigtext * { white-space: nowrap; } .bigtext > * { display: block; }',
'.bigtext .' + BigText.EXEMPT_CLASS + ', .bigtext .' + BigText.EXEMPT_CLASS + ' * { white-space: normal; }']));
}
},
bindResize: function(eventName, resizeFunction) {
var timeoutId;
$(window).unbind(eventName).bind(eventName, function() {
if( timeoutId ) {
clearTimeout( timeoutId );
}
timeoutId = setTimeout( resizeFunction, 300 );
});
},
getStyleId: function(id)
{
return BigText.STYLE_ID + '-' + id;
},
generateStyleTag: function(id, css)
{
return $('').attr('id', id);
},
clearCss: function(id)
{
var styleId = BigText.getStyleId(id);
$('#' + styleId).remove();
},
generateCss: function(id, linesFontSizes, lineWordSpacings, minFontSizes)
{
var css = [];
BigText.clearCss(id);
for(var j=0, k=linesFontSizes.length; j= maxWidth) {
$line.css(property, '');
if(width === maxWidth) {
return {
match: 'exact',
size: parseFloat((parseFloat(size) - 0.1).toFixed(3))
};
}
// Since this is an estimate, we calculate how far over the width we went with the new value.
// If this is word-spacing (our last resort guess) and the over is less than the under, we keep the higher value.
// Otherwise, we revert to the underestimate.
var under = maxWidth - previousWidth,
over = width - maxWidth;
return {
match: 'estimate',
size: parseFloat((parseFloat(size) - (property === 'word-spacing' && previousWidth && ( over < under ) ? 0 : interval)).toFixed(3))
};
}
return width;
}
function calculateSizes($t, $children, maxWidth, maxFontSize, minFontSize)
{
var $c = $t.clone(true)
.addClass('bigtext-cloned')
.css({
fontFamily: $t.css('font-family'),
textTransform: $t.css('text-transform'),
wordSpacing: $t.css('word-spacing'),
letterSpacing: $t.css('letter-spacing'),
position: 'absolute',
left: BigText.DEBUG_MODE ? 0 : -9999,
top: BigText.DEBUG_MODE ? 0 : -9999
})
.appendTo(document.body);
// font-size isn't the only thing we can modify, we can also mess with:
// word-spacing and letter-spacing. WebKit does not respect subpixel
// letter-spacing, word-spacing, or font-size.
// TODO try -webkit-transform: scale() as a workaround.
var fontSizes = [],
wordSpacings = [],
minFontSizes = [],
ratios = [];
$children.css('float', 'left').each(function() {
var $line = $(this),
// TODO replace 8, 4 with a proportional size to the calculated font-size.
intervals = BigText.supports.wholeNumberFontSizeOnly ? [8, 4, 1] : [8, 4, 1, 0.1],
lineMax,
newFontSize;
if($line.hasClass(BigText.EXEMPT_CLASS)) {
fontSizes.push(null);
ratios.push(null);
minFontSizes.push(false);
return;
}
// TODO we can cache this ratio?
var autoGuessSubtraction = 32, // font size in px
currentFontSize = parseFloat($line.css('font-size')),
ratio = ( $line.width() / currentFontSize ).toFixed(6);
newFontSize = parseInt( maxWidth / ratio, 10 ) - autoGuessSubtraction;
outer: for(var m=0, n=intervals.length; m maxFontSize) {
newFontSize = maxFontSize;
break outer;
}
lineMax = testLineDimensions($line, maxWidth, 'font-size', newFontSize + j*intervals[m], intervals[m], 'px', lineMax);
if(typeof lineMax !== 'number') {
newFontSize = lineMax.size;
if(lineMax.match === 'exact') {
break outer;
}
break inner;
}
}
}
ratios.push(maxWidth / newFontSize);
if(newFontSize > maxFontSize) {
fontSizes.push(maxFontSize);
minFontSizes.push(false);
} else if(!!minFontSize && newFontSize < minFontSize) {
fontSizes.push(minFontSize);
minFontSizes.push(true);
} else {
fontSizes.push(newFontSize);
minFontSizes.push(false);
}
}).each(function(lineNumber) {
var $line = $(this),
wordSpacing = 0,
interval = 1,
maxWordSpacing;
if($line.hasClass(BigText.EXEMPT_CLASS)) {
wordSpacings.push(null);
return;
}
// must re-use font-size, even though it was removed above.
$line.css('font-size', fontSizes[lineNumber] + 'px');
for(var m=1, n=3; m $().plugin('option', {...})
if ( !PluginClass.prototype.option ) {
// option setter
PluginClass.prototype.option = function( opts ) {
// bail out if not an object
if ( !$.isPlainObject( opts ) ){
return;
}
this.options = $.extend( true, this.options, opts );
};
}
// make jQuery plugin
$.fn[ namespace ] = function( arg0 /*, arg1 */ ) {
if ( typeof arg0 == 'string' ) {
// method call $().plugin( 'methodName', { options } )
// shift arguments by 1
var args = arraySlice.call( arguments, 1 );
return methodCall( this, arg0, args );
}
// just $().plugin({ options })
plainCall( this, arg0 );
return this;
};
// $().plugin('methodName')
function methodCall( $elems, methodName, args ) {
var returnValue;
var pluginMethodStr = '$().' + namespace + '("' + methodName + '")';
$elems.each( function( i, elem ) {
// get instance
var instance = $.data( elem, namespace );
if ( !instance ) {
logError( namespace + ' not initialized. Cannot call methods, i.e. ' +
pluginMethodStr );
return;
}
var method = instance[ methodName ];
if ( !method || methodName.charAt(0) == '_' ) {
logError( pluginMethodStr + ' is not a valid method' );
return;
}
// apply method, get return value
var value = method.apply( instance, args );
// set return value if value is returned, use only first value
returnValue = returnValue === undefined ? value : returnValue;
});
return returnValue !== undefined ? returnValue : $elems;
}
function plainCall( $elems, options ) {
$elems.each( function( i, elem ) {
var instance = $.data( elem, namespace );
if ( instance ) {
// set options & init
instance.option( options );
instance._init();
} else {
// initialize new instance
instance = new PluginClass( elem, options );
$.data( elem, namespace, instance );
}
});
}
updateJQuery( $ );
}
// ----- updateJQuery ----- //
// set $.bridget for v1 backwards compatibility
function updateJQuery( $ ) {
if ( !$ || ( $ && $.bridget ) ) {
return;
}
$.bridget = jQueryBridget;
}
updateJQuery( jQuery || window.jQuery );
// ----- ----- //
return jQueryBridget;
}));
/**
* EvEmitter v1.1.0
* Lil' event emitter
* MIT License
*/
/* jshint unused: true, undef: true, strict: true */
( function( global, factory ) {
// universal module definition
/* jshint strict: false */ /* globals define, module, window */
if ( typeof define == 'function' && define.amd ) {
// AMD - RequireJS
define( 'ev-emitter/ev-emitter',factory );
} else if ( typeof module == 'object' && module.exports ) {
// CommonJS - Browserify, Webpack
module.exports = factory();
} else {
// Browser globals
global.EvEmitter = factory();
}
}( typeof window != 'undefined' ? window : this, function() {
function EvEmitter() {}
var proto = EvEmitter.prototype;
proto.on = function( eventName, listener ) {
if ( !eventName || !listener ) {
return;
}
// set events hash
var events = this._events = this._events || {};
// set listeners array
var listeners = events[ eventName ] = events[ eventName ] || [];
// only add once
if ( listeners.indexOf( listener ) == -1 ) {
listeners.push( listener );
}
return this;
};
proto.once = function( eventName, listener ) {
if ( !eventName || !listener ) {
return;
}
// add event
this.on( eventName, listener );
// set once flag
// set onceEvents hash
var onceEvents = this._onceEvents = this._onceEvents || {};
// set onceListeners object
var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {};
// set flag
onceListeners[ listener ] = true;
return this;
};
proto.off = function( eventName, listener ) {
var listeners = this._events && this._events[ eventName ];
if ( !listeners || !listeners.length ) {
return;
}
var index = listeners.indexOf( listener );
if ( index != -1 ) {
listeners.splice( index, 1 );
}
return this;
};
proto.emitEvent = function( eventName, args ) {
var listeners = this._events && this._events[ eventName ];
if ( !listeners || !listeners.length ) {
return;
}
// copy over to avoid interference if .off() in listener
listeners = listeners.slice(0);
args = args || [];
// once stuff
var onceListeners = this._onceEvents && this._onceEvents[ eventName ];
for ( var i=0; i < listeners.length; i++ ) {
var listener = listeners[i]
var isOnce = onceListeners && onceListeners[ listener ];
if ( isOnce ) {
// remove listener
// remove before trigger to prevent recursion
this.off( eventName, listener );
// unset once flag
delete onceListeners[ listener ];
}
// trigger listener
listener.apply( this, args );
}
return this;
};
proto.allOff = function() {
delete this._events;
delete this._onceEvents;
};
return EvEmitter;
}));
/*!
* getSize v2.0.3
* measure size of elements
* MIT license
*/
/* jshint browser: true, strict: true, undef: true, unused: true */
/* globals console: false */
( function( window, factory ) {
/* jshint strict: false */ /* globals define, module */
if ( typeof define == 'function' && define.amd ) {
// AMD
define( 'get-size/get-size',factory );
} else if ( typeof module == 'object' && module.exports ) {
// CommonJS
module.exports = factory();
} else {
// browser global
window.getSize = factory();
}
})( window, function factory() {
'use strict';
// -------------------------- helpers -------------------------- //
// get a number from a string, not a percentage
function getStyleSize( value ) {
var num = parseFloat( value );
// not a percent like '100%', and a number
var isValid = value.indexOf('%') == -1 && !isNaN( num );
return isValid && num;
}
function noop() {}
var logError = typeof console == 'undefined' ? noop :
function( message ) {
console.error( message );
};
// -------------------------- measurements -------------------------- //
var measurements = [
'paddingLeft',
'paddingRight',
'paddingTop',
'paddingBottom',
'marginLeft',
'marginRight',
'marginTop',
'marginBottom',
'borderLeftWidth',
'borderRightWidth',
'borderTopWidth',
'borderBottomWidth'
];
var measurementsLength = measurements.length;
function getZeroSize() {
var size = {
width: 0,
height: 0,
innerWidth: 0,
innerHeight: 0,
outerWidth: 0,
outerHeight: 0
};
for ( var i=0; i < measurementsLength; i++ ) {
var measurement = measurements[i];
size[ measurement ] = 0;
}
return size;
}
// -------------------------- getStyle -------------------------- //
/**
* getStyle, get style of element, check for Firefox bug
* https://bugzilla.mozilla.org/show_bug.cgi?id=548397
*/
function getStyle( elem ) {
var style = getComputedStyle( elem );
if ( !style ) {
logError( 'Style returned ' + style +
'. Are you running this code in a hidden iframe on Firefox? ' +
'See https://bit.ly/getsizebug1' );
}
return style;
}
// -------------------------- setup -------------------------- //
var isSetup = false;
var isBoxSizeOuter;
/**
* setup
* check isBoxSizerOuter
* do on first getSize() rather than on page load for Firefox bug
*/
function setup() {
// setup once
if ( isSetup ) {
return;
}
isSetup = true;
// -------------------------- box sizing -------------------------- //
/**
* Chrome & Safari measure the outer-width on style.width on border-box elems
* IE11 & Firefox<29 measures the inner-width
*/
var div = document.createElement('div');
div.style.width = '200px';
div.style.padding = '1px 2px 3px 4px';
div.style.borderStyle = 'solid';
div.style.borderWidth = '1px 2px 3px 4px';
div.style.boxSizing = 'border-box';
var body = document.body || document.documentElement;
body.appendChild( div );
var style = getStyle( div );
// round value for browser zoom. desandro/masonry#928
isBoxSizeOuter = Math.round( getStyleSize( style.width ) ) == 200;
getSize.isBoxSizeOuter = isBoxSizeOuter;
body.removeChild( div );
}
// -------------------------- getSize -------------------------- //
function getSize( elem ) {
setup();
// use querySeletor if elem is string
if ( typeof elem == 'string' ) {
elem = document.querySelector( elem );
}
// do not proceed on non-objects
if ( !elem || typeof elem != 'object' || !elem.nodeType ) {
return;
}
var style = getStyle( elem );
// if hidden, everything is 0
if ( style.display == 'none' ) {
return getZeroSize();
}
var size = {};
size.width = elem.offsetWidth;
size.height = elem.offsetHeight;
var isBorderBox = size.isBorderBox = style.boxSizing == 'border-box';
// get all measurements
for ( var i=0; i < measurementsLength; i++ ) {
var measurement = measurements[i];
var value = style[ measurement ];
var num = parseFloat( value );
// any 'auto', 'medium' value will be 0
size[ measurement ] = !isNaN( num ) ? num : 0;
}
var paddingWidth = size.paddingLeft + size.paddingRight;
var paddingHeight = size.paddingTop + size.paddingBottom;
var marginWidth = size.marginLeft + size.marginRight;
var marginHeight = size.marginTop + size.marginBottom;
var borderWidth = size.borderLeftWidth + size.borderRightWidth;
var borderHeight = size.borderTopWidth + size.borderBottomWidth;
var isBorderBoxSizeOuter = isBorderBox && isBoxSizeOuter;
// overwrite width and height if we can get it from style
var styleWidth = getStyleSize( style.width );
if ( styleWidth !== false ) {
size.width = styleWidth +
// add padding and border unless it's already including it
( isBorderBoxSizeOuter ? 0 : paddingWidth + borderWidth );
}
var styleHeight = getStyleSize( style.height );
if ( styleHeight !== false ) {
size.height = styleHeight +
// add padding and border unless it's already including it
( isBorderBoxSizeOuter ? 0 : paddingHeight + borderHeight );
}
size.innerWidth = size.width - ( paddingWidth + borderWidth );
size.innerHeight = size.height - ( paddingHeight + borderHeight );
size.outerWidth = size.width + marginWidth;
size.outerHeight = size.height + marginHeight;
return size;
}
return getSize;
});
/**
* matchesSelector v2.0.2
* matchesSelector( element, '.selector' )
* MIT license
*/
/*jshint browser: true, strict: true, undef: true, unused: true */
( function( window, factory ) {
/*global define: false, module: false */
'use strict';
// universal module definition
if ( typeof define == 'function' && define.amd ) {
// AMD
define( 'desandro-matches-selector/matches-selector',factory );
} else if ( typeof module == 'object' && module.exports ) {
// CommonJS
module.exports = factory();
} else {
// browser global
window.matchesSelector = factory();
}
}( window, function factory() {
'use strict';
var matchesMethod = ( function() {
var ElemProto = window.Element.prototype;
// check for the standard method name first
if ( ElemProto.matches ) {
return 'matches';
}
// check un-prefixed
if ( ElemProto.matchesSelector ) {
return 'matchesSelector';
}
// check vendor prefixes
var prefixes = [ 'webkit', 'moz', 'ms', 'o' ];
for ( var i=0; i < prefixes.length; i++ ) {
var prefix = prefixes[i];
var method = prefix + 'MatchesSelector';
if ( ElemProto[ method ] ) {
return method;
}
}
})();
return function matchesSelector( elem, selector ) {
return elem[ matchesMethod ]( selector );
};
}));
/**
* Fizzy UI utils v2.0.7
* MIT license
*/
/*jshint browser: true, undef: true, unused: true, strict: true */
( function( window, factory ) {
// universal module definition
/*jshint strict: false */ /*globals define, module, require */
if ( typeof define == 'function' && define.amd ) {
// AMD
define( 'fizzy-ui-utils/utils',[
'desandro-matches-selector/matches-selector'
], function( matchesSelector ) {
return factory( window, matchesSelector );
});
} else if ( typeof module == 'object' && module.exports ) {
// CommonJS
module.exports = factory(
window,
require('desandro-matches-selector')
);
} else {
// browser global
window.fizzyUIUtils = factory(
window,
window.matchesSelector
);
}
}( window, function factory( window, matchesSelector ) {
var utils = {};
// ----- extend ----- //
// extends objects
utils.extend = function( a, b ) {
for ( var prop in b ) {
a[ prop ] = b[ prop ];
}
return a;
};
// ----- modulo ----- //
utils.modulo = function( num, div ) {
return ( ( num % div ) + div ) % div;
};
// ----- makeArray ----- //
var arraySlice = Array.prototype.slice;
// turn element or nodeList into an array
utils.makeArray = function( obj ) {
if ( Array.isArray( obj ) ) {
// use object if already an array
return obj;
}
// return empty array if undefined or null. #6
if ( obj === null || obj === undefined ) {
return [];
}
var isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';
if ( isArrayLike ) {
// convert nodeList to array
return arraySlice.call( obj );
}
// array of single index
return [ obj ];
};
// ----- removeFrom ----- //
utils.removeFrom = function( ary, obj ) {
var index = ary.indexOf( obj );
if ( index != -1 ) {
ary.splice( index, 1 );
}
};
// ----- getParent ----- //
utils.getParent = function( elem, selector ) {
while ( elem.parentNode && elem != document.body ) {
elem = elem.parentNode;
if ( matchesSelector( elem, selector ) ) {
return elem;
}
}
};
// ----- getQueryElement ----- //
// use element as selector string
utils.getQueryElement = function( elem ) {
if ( typeof elem == 'string' ) {
return document.querySelector( elem );
}
return elem;
};
// ----- handleEvent ----- //
// enable .ontype to trigger from .addEventListener( elem, 'type' )
utils.handleEvent = function( event ) {
var method = 'on' + event.type;
if ( this[ method ] ) {
this[ method ]( event );
}
};
// ----- filterFindElements ----- //
utils.filterFindElements = function( elems, selector ) {
// make array of elems
elems = utils.makeArray( elems );
var ffElems = [];
elems.forEach( function( elem ) {
// check that elem is an actual element
// START UNCODE EDIT
// if ( !( elem instanceof HTMLElement ) ) {
if ( !( elem instanceof HTMLElement ) && !SiteParameters.is_frontend_editor ) {
// END UNCODE EDIT
return;
}
// add elem if no selector
if ( !selector ) {
ffElems.push( elem );
return;
}
// filter & find items if we have a selector
// filter
if ( matchesSelector( elem, selector ) ) {
ffElems.push( elem );
}
// find children
var childElems = elem.querySelectorAll( selector );
// concat childElems to filterFound array
for ( var i=0; i < childElems.length; i++ ) {
ffElems.push( childElems[i] );
}
});
return ffElems;
};
// ----- debounceMethod ----- //
utils.debounceMethod = function( _class, methodName, threshold ) {
threshold = threshold || 100;
// original method
var method = _class.prototype[ methodName ];
var timeoutName = methodName + 'Timeout';
_class.prototype[ methodName ] = function() {
var timeout = this[ timeoutName ];
clearTimeout( timeout );
var args = arguments;
var _this = this;
this[ timeoutName ] = setTimeout( function() {
method.apply( _this, args );
delete _this[ timeoutName ];
}, threshold );
};
};
// ----- docReady ----- //
utils.docReady = function( callback ) {
var readyState = document.readyState;
if ( readyState == 'complete' || readyState == 'interactive' ) {
// do async to allow for other scripts to run. metafizzy/flickity#441
setTimeout( callback );
} else {
document.addEventListener( 'DOMContentLoaded', callback );
}
};
// ----- htmlInit ----- //
// http://jamesroberts.name/blog/2010/02/22/string-functions-for-javascript-trim-to-camel-case-to-dashed-and-to-underscore/
utils.toDashed = function( str ) {
return str.replace( /(.)([A-Z])/g, function( match, $1, $2 ) {
return $1 + '-' + $2;
}).toLowerCase();
};
var console = window.console;
/**
* allow user to initialize classes via [data-namespace] or .js-namespace class
* htmlInit( Widget, 'widgetName' )
* options are parsed from data-namespace-options
*/
utils.htmlInit = function( WidgetClass, namespace ) {
utils.docReady( function() {
var dashedNamespace = utils.toDashed( namespace );
var dataAttr = 'data-' + dashedNamespace;
var dataAttrElems = document.querySelectorAll( '[' + dataAttr + ']' );
var jsDashElems = document.querySelectorAll( '.js-' + dashedNamespace );
var elems = utils.makeArray( dataAttrElems )
.concat( utils.makeArray( jsDashElems ) );
var dataOptionsAttr = dataAttr + '-options';
var jQuery = window.jQuery;
elems.forEach( function( elem ) {
var attr = elem.getAttribute( dataAttr ) ||
elem.getAttribute( dataOptionsAttr );
var options;
try {
options = attr && JSON.parse( attr );
} catch ( error ) {
// log error, do not initialize
if ( console ) {
console.error( 'Error parsing ' + dataAttr + ' on ' + elem.className +
': ' + error );
}
return;
}
// initialize
var instance = new WidgetClass( elem, options );
// make available via $().data('namespace')
if ( jQuery ) {
jQuery.data( elem, namespace, instance );
}
});
});
};
// ----- ----- //
return utils;
}));
/**
* Outlayer Item
*/
( function( window, factory ) {
// universal module definition
/* jshint strict: false */ /* globals define, module, require */
if ( typeof define == 'function' && define.amd ) {
// AMD - RequireJS
define( 'outlayer/item',[
'ev-emitter/ev-emitter',
'get-size/get-size'
],
factory
);
} else if ( typeof module == 'object' && module.exports ) {
// CommonJS - Browserify, Webpack
module.exports = factory(
require('ev-emitter'),
require('get-size')
);
} else {
// browser global
window.Outlayer = {};
window.Outlayer.Item = factory(
window.EvEmitter,
window.getSize
);
}
}( window, function factory( EvEmitter, getSize ) {
'use strict';
// ----- helpers ----- //
function isEmptyObj( obj ) {
for ( var prop in obj ) {
return false;
}
prop = null;
return true;
}
// -------------------------- CSS3 support -------------------------- //
var docElemStyle = document.documentElement.style;
var transitionProperty = typeof docElemStyle.transition == 'string' ?
'transition' : 'WebkitTransition';
var transformProperty = typeof docElemStyle.transform == 'string' ?
'transform' : 'WebkitTransform';
var transitionEndEvent = {
WebkitTransition: 'webkitTransitionEnd',
transition: 'transitionend'
}[ transitionProperty ];
// cache all vendor properties that could have vendor prefix
var vendorProperties = {
transform: transformProperty,
transition: transitionProperty,
transitionDuration: transitionProperty + 'Duration',
transitionProperty: transitionProperty + 'Property',
transitionDelay: transitionProperty + 'Delay'
};
// -------------------------- Item -------------------------- //
function Item( element, layout ) {
if ( !element ) {
return;
}
this.element = element;
// parent layout class, i.e. Masonry, Isotope, or Packery
this.layout = layout;
this.position = {
x: 0,
y: 0
};
this._create();
}
// inherit EvEmitter
var proto = Item.prototype = Object.create( EvEmitter.prototype );
proto.constructor = Item;
proto._create = function() {
// transition objects
this._transn = {
ingProperties: {},
clean: {},
onEnd: {}
};
this.css({
position: 'absolute'
});
};
// trigger specified handler for event type
proto.handleEvent = function( event ) {
var method = 'on' + event.type;
if ( this[ method ] ) {
this[ method ]( event );
}
};
proto.getSize = function() {
this.size = getSize( this.element );
};
/**
* apply CSS styles to element
* @param {Object} style
*/
proto.css = function( style ) {
var elemStyle = this.element.style;
for ( var prop in style ) {
// use vendor property if available
var supportedProp = vendorProperties[ prop ] || prop;
elemStyle[ supportedProp ] = style[ prop ];
}
};
// measure position, and sets it
proto.getPosition = function() {
var style = getComputedStyle( this.element );
var isOriginLeft = this.layout._getOption('originLeft');
var isOriginTop = this.layout._getOption('originTop');
var xValue = style[ isOriginLeft ? 'left' : 'right' ];
var yValue = style[ isOriginTop ? 'top' : 'bottom' ];
var x = parseFloat( xValue );
var y = parseFloat( yValue );
// convert percent to pixels
var layoutSize = this.layout.size;
if ( xValue.indexOf('%') != -1 ) {
x = ( x / 100 ) * layoutSize.width;
}
if ( yValue.indexOf('%') != -1 ) {
y = ( y / 100 ) * layoutSize.height;
}
// clean up 'auto' or other non-integer values
x = isNaN( x ) ? 0 : x;
y = isNaN( y ) ? 0 : y;
// remove padding from measurement
x -= isOriginLeft ? layoutSize.paddingLeft : layoutSize.paddingRight;
y -= isOriginTop ? layoutSize.paddingTop : layoutSize.paddingBottom;
this.position.x = x;
this.position.y = y;
};
// set settled position, apply padding
proto.layoutPosition = function() {
var layoutSize = this.layout.size;
var style = {};
var isOriginLeft = this.layout._getOption('originLeft');
var isOriginTop = this.layout._getOption('originTop');
// x
var xPadding = isOriginLeft ? 'paddingLeft' : 'paddingRight';
var xProperty = isOriginLeft ? 'left' : 'right';
var xResetProperty = isOriginLeft ? 'right' : 'left';
var x = this.position.x + layoutSize[ xPadding ];
// set in percentage or pixels
style[ xProperty ] = this.getXValue( x );
// reset other property
style[ xResetProperty ] = '';
// y
var yPadding = isOriginTop ? 'paddingTop' : 'paddingBottom';
var yProperty = isOriginTop ? 'top' : 'bottom';
var yResetProperty = isOriginTop ? 'bottom' : 'top';
var y = this.position.y + layoutSize[ yPadding ];
// set in percentage or pixels
style[ yProperty ] = this.getYValue( y );
// reset other property
style[ yResetProperty ] = '';
this.css( style );
this.emitEvent( 'layout', [ this ] );
};
proto.getXValue = function( x ) {
var isHorizontal = this.layout._getOption('horizontal');
return this.layout.options.percentPosition && !isHorizontal ?
( ( x / this.layout.size.width ) * 100 ) + '%' : x + 'px';
};
proto.getYValue = function( y ) {
var isHorizontal = this.layout._getOption('horizontal');
return this.layout.options.percentPosition && isHorizontal ?
( ( y / this.layout.size.height ) * 100 ) + '%' : y + 'px';
};
proto._transitionTo = function( x, y ) {
this.getPosition();
// get current x & y from top/left
var curX = this.position.x;
var curY = this.position.y;
var didNotMove = x == this.position.x && y == this.position.y;
// save end position
this.setPosition( x, y );
// if did not move and not transitioning, just go to layout
if ( didNotMove && !this.isTransitioning ) {
this.layoutPosition();
return;
}
var transX = x - curX;
var transY = y - curY;
var transitionStyle = {};
transitionStyle.transform = this.getTranslate( transX, transY );
this.transition({
to: transitionStyle,
onTransitionEnd: {
transform: this.layoutPosition
},
isCleaning: true
});
};
proto.getTranslate = function( x, y ) {
// flip cooridinates if origin on right or bottom
var isOriginLeft = this.layout._getOption('originLeft');
var isOriginTop = this.layout._getOption('originTop');
x = isOriginLeft ? x : -x;
y = isOriginTop ? y : -y;
return 'translate3d(' + x + 'px, ' + y + 'px, 0)';
};
// non transition + transform support
proto.goTo = function( x, y ) {
this.setPosition( x, y );
this.layoutPosition();
};
proto.moveTo = proto._transitionTo;
proto.setPosition = function( x, y ) {
this.position.x = parseFloat( x );
this.position.y = parseFloat( y );
};
// ----- transition ----- //
/**
* @param {Object} style - CSS
* @param {Function} onTransitionEnd
*/
// non transition, just trigger callback
proto._nonTransition = function( args ) {
this.css( args.to );
if ( args.isCleaning ) {
this._removeStyles( args.to );
}
for ( var prop in args.onTransitionEnd ) {
args.onTransitionEnd[ prop ].call( this );
}
};
/**
* proper transition
* @param {Object} args - arguments
* @param {Object} to - style to transition to
* @param {Object} from - style to start transition from
* @param {Boolean} isCleaning - removes transition styles after transition
* @param {Function} onTransitionEnd - callback
*/
proto.transition = function( args ) {
// redirect to nonTransition if no transition duration
if ( !parseFloat( this.layout.options.transitionDuration ) ) {
this._nonTransition( args );
return;
}
var _transition = this._transn;
// keep track of onTransitionEnd callback by css property
for ( var prop in args.onTransitionEnd ) {
_transition.onEnd[ prop ] = args.onTransitionEnd[ prop ];
}
// keep track of properties that are transitioning
for ( prop in args.to ) {
_transition.ingProperties[ prop ] = true;
// keep track of properties to clean up when transition is done
if ( args.isCleaning ) {
_transition.clean[ prop ] = true;
}
}
// set from styles
if ( args.from ) {
this.css( args.from );
// force redraw. http://blog.alexmaccaw.com/css-transitions
var h = this.element.offsetHeight;
// hack for JSHint to hush about unused var
h = null;
}
// enable transition
this.enableTransition( args.to );
// set styles that are transitioning
this.css( args.to );
this.isTransitioning = true;
};
// dash before all cap letters, including first for
// WebkitTransform => -webkit-transform
function toDashedAll( str ) {
return str.replace( /([A-Z])/g, function( $1 ) {
return '-' + $1.toLowerCase();
});
}
var transitionProps = 'opacity,' + toDashedAll( transformProperty );
proto.enableTransition = function(/* style */) {
// HACK changing transitionProperty during a transition
// will cause transition to jump
if ( this.isTransitioning ) {
return;
}
// make `transition: foo, bar, baz` from style object
// HACK un-comment this when enableTransition can work
// while a transition is happening
// var transitionValues = [];
// for ( var prop in style ) {
// // dash-ify camelCased properties like WebkitTransition
// prop = vendorProperties[ prop ] || prop;
// transitionValues.push( toDashedAll( prop ) );
// }
// munge number to millisecond, to match stagger
var duration = this.layout.options.transitionDuration;
duration = typeof duration == 'number' ? duration + 'ms' : duration;
// enable transition styles
this.css({
transitionProperty: transitionProps,
transitionDuration: duration,
transitionDelay: this.staggerDelay || 0
});
// listen for transition end event
this.element.addEventListener( transitionEndEvent, this, false );
};
// ----- events ----- //
proto.onwebkitTransitionEnd = function( event ) {
this.ontransitionend( event );
};
proto.onotransitionend = function( event ) {
this.ontransitionend( event );
};
// properties that I munge to make my life easier
var dashedVendorProperties = {
'-webkit-transform': 'transform'
};
proto.ontransitionend = function( event ) {
// disregard bubbled events from children
if ( event.target !== this.element ) {
return;
}
var _transition = this._transn;
// get property name of transitioned property, convert to prefix-free
var propertyName = dashedVendorProperties[ event.propertyName ] || event.propertyName;
// remove property that has completed transitioning
delete _transition.ingProperties[ propertyName ];
// check if any properties are still transitioning
if ( isEmptyObj( _transition.ingProperties ) ) {
// all properties have completed transitioning
this.disableTransition();
}
// clean style
if ( propertyName in _transition.clean ) {
// clean up style
this.element.style[ event.propertyName ] = '';
delete _transition.clean[ propertyName ];
}
// trigger onTransitionEnd callback
if ( propertyName in _transition.onEnd ) {
var onTransitionEnd = _transition.onEnd[ propertyName ];
onTransitionEnd.call( this );
delete _transition.onEnd[ propertyName ];
}
this.emitEvent( 'transitionEnd', [ this ] );
};
proto.disableTransition = function() {
this.removeTransitionStyles();
this.element.removeEventListener( transitionEndEvent, this, false );
this.isTransitioning = false;
};
/**
* removes style property from element
* @param {Object} style
**/
proto._removeStyles = function( style ) {
// clean up transition styles
var cleanStyle = {};
for ( var prop in style ) {
cleanStyle[ prop ] = '';
}
this.css( cleanStyle );
};
var cleanTransitionStyle = {
transitionProperty: '',
transitionDuration: '',
transitionDelay: ''
};
proto.removeTransitionStyles = function() {
// remove transition
this.css( cleanTransitionStyle );
};
// ----- stagger ----- //
proto.stagger = function( delay ) {
delay = isNaN( delay ) ? 0 : delay;
this.staggerDelay = delay + 'ms';
};
// ----- show/hide/remove ----- //
// remove element from DOM
proto.removeElem = function() {
this.element.parentNode.removeChild( this.element );
// remove display: none
this.css({ display: '' });
this.emitEvent( 'remove', [ this ] );
};
proto.remove = function() {
// just remove element if no transition support or no transition
if ( !transitionProperty || !parseFloat( this.layout.options.transitionDuration ) ) {
this.removeElem();
return;
}
// start transition
this.once( 'transitionEnd', function() {
this.removeElem();
});
this.hide();
};
proto.reveal = function() {
delete this.isHidden;
// remove display: none
this.css({ display: '' });
var options = this.layout.options;
var onTransitionEnd = {};
var transitionEndProperty = this.getHideRevealTransitionEndProperty('visibleStyle');
onTransitionEnd[ transitionEndProperty ] = this.onRevealTransitionEnd;
this.transition({
from: options.hiddenStyle,
to: options.visibleStyle,
isCleaning: true,
onTransitionEnd: onTransitionEnd
});
};
proto.onRevealTransitionEnd = function() {
// check if still visible
// during transition, item may have been hidden
if ( !this.isHidden ) {
this.emitEvent('reveal');
}
};
/**
* get style property use for hide/reveal transition end
* @param {String} styleProperty - hiddenStyle/visibleStyle
* @returns {String}
*/
proto.getHideRevealTransitionEndProperty = function( styleProperty ) {
var optionStyle = this.layout.options[ styleProperty ];
// use opacity
if ( optionStyle.opacity ) {
return 'opacity';
}
// get first property
for ( var prop in optionStyle ) {
return prop;
}
};
proto.hide = function() {
// set flag
this.isHidden = true;
// remove display: none
this.css({ display: '' });
var options = this.layout.options;
var onTransitionEnd = {};
var transitionEndProperty = this.getHideRevealTransitionEndProperty('hiddenStyle');
onTransitionEnd[ transitionEndProperty ] = this.onHideTransitionEnd;
this.transition({
from: options.visibleStyle,
to: options.hiddenStyle,
// keep hidden stuff hidden
isCleaning: true,
onTransitionEnd: onTransitionEnd
});
};
proto.onHideTransitionEnd = function() {
// check if still hidden
// during transition, item may have been un-hidden
if ( this.isHidden ) {
this.css({ display: 'none' });
this.emitEvent('hide');
}
};
proto.destroy = function() {
this.css({
position: '',
left: '',
right: '',
top: '',
bottom: '',
transition: '',
transform: ''
});
};
return Item;
}));
/*!
* Outlayer v2.1.1
* the brains and guts of a layout library
* MIT license
*/
( function( window, factory ) {
'use strict';
// universal module definition
/* jshint strict: false */ /* globals define, module, require */
if ( typeof define == 'function' && define.amd ) {
// AMD - RequireJS
define( 'outlayer/outlayer',[
'ev-emitter/ev-emitter',
'get-size/get-size',
'fizzy-ui-utils/utils',
'./item'
],
function( EvEmitter, getSize, utils, Item ) {
return factory( window, EvEmitter, getSize, utils, Item);
}
);
} else if ( typeof module == 'object' && module.exports ) {
// CommonJS - Browserify, Webpack
module.exports = factory(
window,
require('ev-emitter'),
require('get-size'),
require('fizzy-ui-utils'),
require('./item')
);
} else {
// browser global
window.Outlayer = factory(
window,
window.EvEmitter,
window.getSize,
window.fizzyUIUtils,
window.Outlayer.Item
);
}
}( window, function factory( window, EvEmitter, getSize, utils, Item ) {
'use strict';
// ----- vars ----- //
var console = window.console;
var jQuery = window.jQuery;
var noop = function() {};
// -------------------------- Outlayer -------------------------- //
// globally unique identifiers
var GUID = 0;
// internal store of all Outlayer intances
var instances = {};
/**
* @param {Element, String} element
* @param {Object} options
* @constructor
*/
function Outlayer( element, options ) {
var queryElement = utils.getQueryElement( element );
if ( !queryElement ) {
if ( console ) {
console.error( 'Bad element for ' + this.constructor.namespace +
': ' + ( queryElement || element ) );
}
return;
}
this.element = queryElement;
// add jQuery
if ( jQuery ) {
this.$element = jQuery( this.element );
}
// options
this.options = utils.extend( {}, this.constructor.defaults );
this.option( options );
// add id for Outlayer.getFromElement
var id = ++GUID;
this.element.outlayerGUID = id; // expando
instances[ id ] = this; // associate via id
// kick it off
this._create();
var isInitLayout = this._getOption('initLayout');
if ( isInitLayout ) {
this.layout();
}
}
// settings are for internal use only
Outlayer.namespace = 'outlayer';
Outlayer.Item = Item;
// default options
Outlayer.defaults = {
containerStyle: {
position: 'relative'
},
initLayout: true,
originLeft: true,
originTop: true,
resize: true,
resizeContainer: true,
// item options
transitionDuration: '0.4s',
hiddenStyle: {
opacity: 0,
transform: 'scale(0.001)'
},
visibleStyle: {
opacity: 1,
transform: 'scale(1)'
}
};
var proto = Outlayer.prototype;
// inherit EvEmitter
utils.extend( proto, EvEmitter.prototype );
/**
* set options
* @param {Object} opts
*/
proto.option = function( opts ) {
utils.extend( this.options, opts );
};
/**
* get backwards compatible option value, check old name
*/
proto._getOption = function( option ) {
var oldOption = this.constructor.compatOptions[ option ];
return oldOption && this.options[ oldOption ] !== undefined ?
this.options[ oldOption ] : this.options[ option ];
};
Outlayer.compatOptions = {
// currentName: oldName
initLayout: 'isInitLayout',
horizontal: 'isHorizontal',
layoutInstant: 'isLayoutInstant',
originLeft: 'isOriginLeft',
originTop: 'isOriginTop',
resize: 'isResizeBound',
resizeContainer: 'isResizingContainer'
};
proto._create = function() {
// get items from children
this.reloadItems();
// elements that affect layout, but are not laid out
this.stamps = [];
this.stamp( this.options.stamp );
// set container style
utils.extend( this.element.style, this.options.containerStyle );
// bind resize method
var canBindResize = this._getOption('resize');
if ( canBindResize ) {
this.bindResize();
}
};
// goes through all children again and gets bricks in proper order
proto.reloadItems = function() {
// collection of item elements
this.items = this._itemize( this.element.children );
};
/**
* turn elements into Outlayer.Items to be used in layout
* @param {Array or NodeList or HTMLElement} elems
* @returns {Array} items - collection of new Outlayer Items
*/
proto._itemize = function( elems ) {
var itemElems = this._filterFindItemElements( elems );
var Item = this.constructor.Item;
// create new Outlayer Items for collection
var items = [];
for ( var i=0; i < itemElems.length; i++ ) {
var elem = itemElems[i];
var item = new Item( elem, this );
items.push( item );
}
return items;
};
/**
* get item elements to be used in layout
* @param {Array or NodeList or HTMLElement} elems
* @returns {Array} items - item elements
*/
proto._filterFindItemElements = function( elems ) {
return utils.filterFindElements( elems, this.options.itemSelector );
};
/**
* getter method for getting item elements
* @returns {Array} elems - collection of item elements
*/
proto.getItemElements = function() {
return this.items.map( function( item ) {
return item.element;
});
};
// ----- init & layout ----- //
/**
* lays out all items
*/
proto.layout = function() {
this._resetLayout();
this._manageStamps();
// don't animate first layout
var layoutInstant = this._getOption('layoutInstant');
var isInstant = layoutInstant !== undefined ?
layoutInstant : !this._isLayoutInited;
this.layoutItems( this.items, isInstant );
// flag for initalized
this._isLayoutInited = true;
};
// _init is alias for layout
proto._init = proto.layout;
/**
* logic before any new layout
*/
proto._resetLayout = function() {
this.getSize();
};
proto.getSize = function() {
this.size = getSize( this.element );
};
/**
* get measurement from option, for columnWidth, rowHeight, gutter
* if option is String -> get element from selector string, & get size of element
* if option is Element -> get size of element
* else use option as a number
*
* @param {String} measurement
* @param {String} size - width or height
* @private
*/
proto._getMeasurement = function( measurement, size ) {
var option = this.options[ measurement ];
var elem;
if ( !option ) {
// default to 0
this[ measurement ] = 0;
} else {
// use option as an element
if ( typeof option == 'string' ) {
elem = this.element.querySelector( option );
} else if ( option instanceof HTMLElement ) {
elem = option;
}
// use size of element, if element
this[ measurement ] = elem ? getSize( elem )[ size ] : option;
}
};
/**
* layout a collection of item elements
* @api public
*/
proto.layoutItems = function( items, isInstant ) {
items = this._getItemsForLayout( items );
this._layoutItems( items, isInstant );
this._postLayout();
};
/**
* get the items to be laid out
* you may want to skip over some items
* @param {Array} items
* @returns {Array} items
*/
proto._getItemsForLayout = function( items ) {
return items.filter( function( item ) {
return !item.isIgnored;
});
};
/**
* layout items
* @param {Array} items
* @param {Boolean} isInstant
*/
proto._layoutItems = function( items, isInstant ) {
this._emitCompleteOnItems( 'layout', items );
if ( !items || !items.length ) {
// no items, emit event with empty array
return;
}
var queue = [];
items.forEach( function( item ) {
// get x/y object from method
var position = this._getItemLayoutPosition( item );
// enqueue
position.item = item;
position.isInstant = isInstant || item.isLayoutInstant;
queue.push( position );
}, this );
this._processLayoutQueue( queue );
};
/**
* get item layout position
* @param {Outlayer.Item} item
* @returns {Object} x and y position
*/
proto._getItemLayoutPosition = function( /* item */ ) {
return {
x: 0,
y: 0
};
};
/**
* iterate over array and position each item
* Reason being - separating this logic prevents 'layout invalidation'
* thx @paul_irish
* @param {Array} queue
*/
proto._processLayoutQueue = function( queue ) {
this.updateStagger();
queue.forEach( function( obj, i ) {
this._positionItem( obj.item, obj.x, obj.y, obj.isInstant, i );
}, this );
};
// set stagger from option in milliseconds number
proto.updateStagger = function() {
var stagger = this.options.stagger;
if ( stagger === null || stagger === undefined ) {
this.stagger = 0;
return;
}
this.stagger = getMilliseconds( stagger );
return this.stagger;
};
/**
* Sets position of item in DOM
* @param {Outlayer.Item} item
* @param {Number} x - horizontal position
* @param {Number} y - vertical position
* @param {Boolean} isInstant - disables transitions
*/
proto._positionItem = function( item, x, y, isInstant, i ) {
if ( isInstant ) {
// if not transition, just set CSS
item.goTo( x, y );
} else {
item.stagger( i * this.stagger );
item.moveTo( x, y );
}
};
/**
* Any logic you want to do after each layout,
* i.e. size the container
*/
proto._postLayout = function() {
this.resizeContainer();
};
proto.resizeContainer = function() {
var isResizingContainer = this._getOption('resizeContainer');
if ( !isResizingContainer ) {
return;
}
var size = this._getContainerSize();
if ( size ) {
this._setContainerMeasure( size.width, true );
this._setContainerMeasure( size.height, false );
}
};
/**
* Sets width or height of container if returned
* @returns {Object} size
* @param {Number} width
* @param {Number} height
*/
proto._getContainerSize = noop;
/**
* @param {Number} measure - size of width or height
* @param {Boolean} isWidth
*/
proto._setContainerMeasure = function( measure, isWidth ) {
if ( measure === undefined ) {
return;
}
var elemSize = this.size;
// add padding and border width if border box
if ( elemSize.isBorderBox ) {
measure += isWidth ? elemSize.paddingLeft + elemSize.paddingRight +
elemSize.borderLeftWidth + elemSize.borderRightWidth :
elemSize.paddingBottom + elemSize.paddingTop +
elemSize.borderTopWidth + elemSize.borderBottomWidth;
}
measure = Math.max( measure, 0 );
this.element.style[ isWidth ? 'width' : 'height' ] = measure + 'px';
};
/**
* emit eventComplete on a collection of items events
* @param {String} eventName
* @param {Array} items - Outlayer.Items
*/
proto._emitCompleteOnItems = function( eventName, items ) {
var _this = this;
function onComplete() {
_this.dispatchEvent( eventName + 'Complete', null, [ items ] );
}
var count = items.length;
if ( !items || !count ) {
onComplete();
return;
}
var doneCount = 0;
function tick() {
doneCount++;
if ( doneCount == count ) {
onComplete();
}
}
// bind callback
items.forEach( function( item ) {
item.once( eventName, tick );
});
};
/**
* emits events via EvEmitter and jQuery events
* @param {String} type - name of event
* @param {Event} event - original event
* @param {Array} args - extra arguments
*/
proto.dispatchEvent = function( type, event, args ) {
// add original event to arguments
var emitArgs = event ? [ event ].concat( args ) : args;
this.emitEvent( type, emitArgs );
if ( jQuery ) {
// set this.$element
this.$element = this.$element || jQuery( this.element );
if ( event ) {
// create jQuery event
var $event = jQuery.Event( event );
$event.type = type;
this.$element.trigger( $event, args );
} else {
// just trigger with type if no event available
this.$element.trigger( type, args );
}
}
};
// -------------------------- ignore & stamps -------------------------- //
/**
* keep item in collection, but do not lay it out
* ignored items do not get skipped in layout
* @param {Element} elem
*/
proto.ignore = function( elem ) {
var item = this.getItem( elem );
if ( item ) {
item.isIgnored = true;
}
};
/**
* return item to layout collection
* @param {Element} elem
*/
proto.unignore = function( elem ) {
var item = this.getItem( elem );
if ( item ) {
delete item.isIgnored;
}
};
/**
* adds elements to stamps
* @param {NodeList, Array, Element, or String} elems
*/
proto.stamp = function( elems ) {
elems = this._find( elems );
if ( !elems ) {
return;
}
this.stamps = this.stamps.concat( elems );
// ignore
elems.forEach( this.ignore, this );
};
/**
* removes elements to stamps
* @param {NodeList, Array, or Element} elems
*/
proto.unstamp = function( elems ) {
elems = this._find( elems );
if ( !elems ){
return;
}
elems.forEach( function( elem ) {
// filter out removed stamp elements
utils.removeFrom( this.stamps, elem );
this.unignore( elem );
}, this );
};
/**
* finds child elements
* @param {NodeList, Array, Element, or String} elems
* @returns {Array} elems
*/
proto._find = function( elems ) {
if ( !elems ) {
return;
}
// if string, use argument as selector string
if ( typeof elems == 'string' ) {
elems = this.element.querySelectorAll( elems );
}
elems = utils.makeArray( elems );
return elems;
};
proto._manageStamps = function() {
if ( !this.stamps || !this.stamps.length ) {
return;
}
this._getBoundingRect();
this.stamps.forEach( this._manageStamp, this );
};
// update boundingLeft / Top
proto._getBoundingRect = function() {
// get bounding rect for container element
var boundingRect = this.element.getBoundingClientRect();
var size = this.size;
this._boundingRect = {
left: boundingRect.left + size.paddingLeft + size.borderLeftWidth,
top: boundingRect.top + size.paddingTop + size.borderTopWidth,
right: boundingRect.right - ( size.paddingRight + size.borderRightWidth ),
bottom: boundingRect.bottom - ( size.paddingBottom + size.borderBottomWidth )
};
};
/**
* @param {Element} stamp
**/
proto._manageStamp = noop;
/**
* get x/y position of element relative to container element
* @param {Element} elem
* @returns {Object} offset - has left, top, right, bottom
*/
proto._getElementOffset = function( elem ) {
var boundingRect = elem.getBoundingClientRect();
var thisRect = this._boundingRect;
var size = getSize( elem );
var offset = {
left: boundingRect.left - thisRect.left - size.marginLeft,
top: boundingRect.top - thisRect.top - size.marginTop,
right: thisRect.right - boundingRect.right - size.marginRight,
bottom: thisRect.bottom - boundingRect.bottom - size.marginBottom
};
return offset;
};
// -------------------------- resize -------------------------- //
// enable event handlers for listeners
// i.e. resize -> onresize
proto.handleEvent = utils.handleEvent;
/**
* Bind layout to window resizing
*/
proto.bindResize = function() {
window.addEventListener( 'resize', this );
this.isResizeBound = true;
};
/**
* Unbind layout to window resizing
*/
proto.unbindResize = function() {
window.removeEventListener( 'resize', this );
this.isResizeBound = false;
};
proto.onresize = function() {
this.resize();
};
utils.debounceMethod( Outlayer, 'onresize', 100 );
proto.resize = function() {
// don't trigger if size did not change
// or if resize was unbound. See #9
if ( !this.isResizeBound || !this.needsResizeLayout() ) {
return;
}
this.layout();
};
/**
* check if layout is needed post layout
* @returns Boolean
*/
proto.needsResizeLayout = function() {
var size = getSize( this.element );
// check that this.size and size are there
// IE8 triggers resize on body size change, so they might not be
var hasSizes = this.size && size;
return hasSizes && size.innerWidth !== this.size.innerWidth;
};
// -------------------------- methods -------------------------- //
/**
* add items to Outlayer instance
* @param {Array or NodeList or Element} elems
* @returns {Array} items - Outlayer.Items
**/
proto.addItems = function( elems ) {
var items = this._itemize( elems );
// add items to collection
if ( items.length ) {
this.items = this.items.concat( items );
}
return items;
};
/**
* Layout newly-appended item elements
* @param {Array or NodeList or Element} elems
*/
proto.appended = function( elems ) {
var items = this.addItems( elems );
if ( !items.length ) {
return;
}
// layout and reveal just the new items
this.layoutItems( items, true );
this.reveal( items );
};
/**
* Layout prepended elements
* @param {Array or NodeList or Element} elems
*/
proto.prepended = function( elems ) {
var items = this._itemize( elems );
if ( !items.length ) {
return;
}
// add items to beginning of collection
var previousItems = this.items.slice(0);
this.items = items.concat( previousItems );
// start new layout
this._resetLayout();
this._manageStamps();
// layout new stuff without transition
this.layoutItems( items, true );
this.reveal( items );
// layout previous items
this.layoutItems( previousItems );
};
/**
* reveal a collection of items
* @param {Array of Outlayer.Items} items
*/
proto.reveal = function( items ) {
this._emitCompleteOnItems( 'reveal', items );
if ( !items || !items.length ) {
return;
}
var stagger = this.updateStagger();
items.forEach( function( item, i ) {
item.stagger( i * stagger );
item.reveal();
});
};
/**
* hide a collection of items
* @param {Array of Outlayer.Items} items
*/
proto.hide = function( items ) {
this._emitCompleteOnItems( 'hide', items );
if ( !items || !items.length ) {
return;
}
var stagger = this.updateStagger();
items.forEach( function( item, i ) {
item.stagger( i * stagger );
item.hide();
});
};
/**
* reveal item elements
* @param {Array}, {Element}, {NodeList} items
*/
proto.revealItemElements = function( elems ) {
var items = this.getItems( elems );
this.reveal( items );
};
/**
* hide item elements
* @param {Array}, {Element}, {NodeList} items
*/
proto.hideItemElements = function( elems ) {
var items = this.getItems( elems );
this.hide( items );
};
/**
* get Outlayer.Item, given an Element
* @param {Element} elem
* @param {Function} callback
* @returns {Outlayer.Item} item
*/
proto.getItem = function( elem ) {
// loop through items to get the one that matches
for ( var i=0; i < this.items.length; i++ ) {
var item = this.items[i];
if ( item.element == elem ) {
// return item
return item;
}
}
};
/**
* get collection of Outlayer.Items, given Elements
* @param {Array} elems
* @returns {Array} items - Outlayer.Items
*/
proto.getItems = function( elems ) {
elems = utils.makeArray( elems );
var items = [];
elems.forEach( function( elem ) {
var item = this.getItem( elem );
if ( item ) {
items.push( item );
}
}, this );
return items;
};
/**
* remove element(s) from instance and DOM
* @param {Array or NodeList or Element} elems
*/
proto.remove = function( elems ) {
var removeItems = this.getItems( elems );
this._emitCompleteOnItems( 'remove', removeItems );
// bail if no items to remove
if ( !removeItems || !removeItems.length ) {
return;
}
removeItems.forEach( function( item ) {
item.remove();
// remove item from collection
utils.removeFrom( this.items, item );
}, this );
};
// ----- destroy ----- //
// remove and disable Outlayer instance
proto.destroy = function() {
// clean up dynamic styles
var style = this.element.style;
style.height = '';
style.position = '';
style.width = '';
// destroy items
this.items.forEach( function( item ) {
item.destroy();
});
this.unbindResize();
var id = this.element.outlayerGUID;
delete instances[ id ]; // remove reference to instance by id
delete this.element.outlayerGUID;
// remove data for jQuery
if ( jQuery ) {
jQuery.removeData( this.element, this.constructor.namespace );
}
};
// -------------------------- data -------------------------- //
/**
* get Outlayer instance from element
* @param {Element} elem
* @returns {Outlayer}
*/
Outlayer.data = function( elem ) {
elem = utils.getQueryElement( elem );
var id = elem && elem.outlayerGUID;
return id && instances[ id ];
};
// -------------------------- create Outlayer class -------------------------- //
/**
* create a layout class
* @param {String} namespace
*/
Outlayer.create = function( namespace, options ) {
// sub-class Outlayer
var Layout = subclass( Outlayer );
// apply new options and compatOptions
Layout.defaults = utils.extend( {}, Outlayer.defaults );
utils.extend( Layout.defaults, options );
Layout.compatOptions = utils.extend( {}, Outlayer.compatOptions );
Layout.namespace = namespace;
Layout.data = Outlayer.data;
// sub-class Item
Layout.Item = subclass( Item );
// -------------------------- declarative -------------------------- //
utils.htmlInit( Layout, namespace );
// -------------------------- jQuery bridge -------------------------- //
// make into jQuery plugin
if ( jQuery && jQuery.bridget ) {
jQuery.bridget( namespace, Layout );
}
return Layout;
};
function subclass( Parent ) {
function SubClass() {
Parent.apply( this, arguments );
}
SubClass.prototype = Object.create( Parent.prototype );
SubClass.prototype.constructor = SubClass;
return SubClass;
}
// ----- helpers ----- //
// how many milliseconds are in each unit
var msUnits = {
ms: 1,
s: 1000
};
// munge time-like parameter into millisecond number
// '0.4s' -> 40
function getMilliseconds( time ) {
if ( typeof time == 'number' ) {
return time;
}
var matches = time.match( /(^\d*\.?\d*)(\w*)/ );
var num = matches && matches[1];
var unit = matches && matches[2];
if ( !num.length ) {
return 0;
}
num = parseFloat( num );
var mult = msUnits[ unit ] || 1;
return num * mult;
}
// ----- fin ----- //
// back in global
Outlayer.Item = Item;
return Outlayer;
}));
/**
* Isotope Item
**/
( function( window, factory ) {
// universal module definition
/* jshint strict: false */ /*globals define, module, require */
if ( typeof define == 'function' && define.amd ) {
// AMD
define( 'isotope-layout/js/item',[
'outlayer/outlayer'
],
factory );
} else if ( typeof module == 'object' && module.exports ) {
// CommonJS
module.exports = factory(
require('outlayer')
);
} else {
// browser global
window.Isotope = window.Isotope || {};
window.Isotope.Item = factory(
window.Outlayer
);
}
}( window, function factory( Outlayer ) {
'use strict';
// -------------------------- Item -------------------------- //
// sub-class Outlayer Item
function Item() {
Outlayer.Item.apply( this, arguments );
}
var proto = Item.prototype = Object.create( Outlayer.Item.prototype );
var _create = proto._create;
proto._create = function() {
// assign id, used for original-order sorting
this.id = this.layout.itemGUID++;
_create.call( this );
this.sortData = {};
};
proto.updateSortData = function() {
if ( this.isIgnored ) {
return;
}
// default sorters
this.sortData.id = this.id;
// for backward compatibility
this.sortData['original-order'] = this.id;
this.sortData.random = Math.random();
// go thru getSortData obj and apply the sorters
var getSortData = this.layout.options.getSortData;
var sorters = this.layout._sorters;
for ( var key in getSortData ) {
var sorter = sorters[ key ];
this.sortData[ key ] = sorter( this.element, this );
}
};
var _destroy = proto.destroy;
proto.destroy = function() {
// call super
_destroy.apply( this, arguments );
// reset display, #741
this.css({
display: ''
});
};
return Item;
}));
/**
* Isotope LayoutMode
*/
( function( window, factory ) {
// universal module definition
/* jshint strict: false */ /*globals define, module, require */
if ( typeof define == 'function' && define.amd ) {
// AMD
define( 'isotope-layout/js/layout-mode',[
'get-size/get-size',
'outlayer/outlayer'
],
factory );
} else if ( typeof module == 'object' && module.exports ) {
// CommonJS
module.exports = factory(
require('get-size'),
require('outlayer')
);
} else {
// browser global
window.Isotope = window.Isotope || {};
window.Isotope.LayoutMode = factory(
window.getSize,
window.Outlayer
);
}
}( window, function factory( getSize, Outlayer ) {
'use strict';
// layout mode class
function LayoutMode( isotope ) {
this.isotope = isotope;
// link properties
if ( isotope ) {
this.options = isotope.options[ this.namespace ];
this.element = isotope.element;
this.items = isotope.filteredItems;
this.size = isotope.size;
}
}
var proto = LayoutMode.prototype;
/**
* some methods should just defer to default Outlayer method
* and reference the Isotope instance as `this`
**/
var facadeMethods = [
'_resetLayout',
'_getItemLayoutPosition',
'_manageStamp',
'_getContainerSize',
'_getElementOffset',
'needsResizeLayout',
'_getOption'
];
facadeMethods.forEach( function( methodName ) {
proto[ methodName ] = function() {
return Outlayer.prototype[ methodName ].apply( this.isotope, arguments );
};
});
// ----- ----- //
// for horizontal layout modes, check vertical size
proto.needsVerticalResizeLayout = function() {
// don't trigger if size did not change
var size = getSize( this.isotope.element );
// check that this.size and size are there
// IE8 triggers resize on body size change, so they might not be
var hasSizes = this.isotope.size && size;
return hasSizes && size.innerHeight != this.isotope.size.innerHeight;
};
// ----- measurements ----- //
proto._getMeasurement = function() {
this.isotope._getMeasurement.apply( this, arguments );
};
proto.getColumnWidth = function() {
this.getSegmentSize( 'column', 'Width' );
};
proto.getRowHeight = function() {
this.getSegmentSize( 'row', 'Height' );
};
/**
* get columnWidth or rowHeight
* segment: 'column' or 'row'
* size 'Width' or 'Height'
**/
proto.getSegmentSize = function( segment, size ) {
var segmentName = segment + size;
var outerSize = 'outer' + size;
// columnWidth / outerWidth // rowHeight / outerHeight
this._getMeasurement( segmentName, outerSize );
// got rowHeight or columnWidth, we can chill
if ( this[ segmentName ] ) {
return;
}
// fall back to item of first element
var firstItemSize = this.getFirstItemSize();
this[ segmentName ] = firstItemSize && firstItemSize[ outerSize ] ||
// or size of container
this.isotope.size[ 'inner' + size ];
};
proto.getFirstItemSize = function() {
var firstItem = this.isotope.filteredItems[0];
return firstItem && firstItem.element && getSize( firstItem.element );
};
// ----- methods that should reference isotope ----- //
proto.layout = function() {
this.isotope.layout.apply( this.isotope, arguments );
};
proto.getSize = function() {
this.isotope.getSize();
this.size = this.isotope.size;
};
// -------------------------- create -------------------------- //
LayoutMode.modes = {};
LayoutMode.create = function( namespace, options ) {
function Mode() {
LayoutMode.apply( this, arguments );
}
Mode.prototype = Object.create( proto );
Mode.prototype.constructor = Mode;
// default options
if ( options ) {
Mode.options = options;
}
Mode.prototype.namespace = namespace;
// register in Isotope
LayoutMode.modes[ namespace ] = Mode;
return Mode;
};
return LayoutMode;
}));
/*!
* Masonry v4.2.1
* Cascading grid layout library
* https://masonry.desandro.com
* MIT License
* by David DeSandro
*/
( function( window, factory ) {
// universal module definition
/* jshint strict: false */ /*globals define, module, require */
if ( typeof define == 'function' && define.amd ) {
// AMD
define( 'masonry-layout/masonry',[
'outlayer/outlayer',
'get-size/get-size'
],
factory );
} else if ( typeof module == 'object' && module.exports ) {
// CommonJS
module.exports = factory(
require('outlayer'),
require('get-size')
);
} else {
// browser global
window.Masonry = factory(
window.Outlayer,
window.getSize
);
}
}( window, function factory( Outlayer, getSize ) {
// -------------------------- masonryDefinition -------------------------- //
// create an Outlayer layout class
var Masonry = Outlayer.create('masonry');
// isFitWidth -> fitWidth
Masonry.compatOptions.fitWidth = 'isFitWidth';
var proto = Masonry.prototype;
proto._resetLayout = function() {
this.getSize();
this._getMeasurement( 'columnWidth', 'outerWidth' );
this._getMeasurement( 'gutter', 'outerWidth' );
this.measureColumns();
// reset column Y
this.colYs = [];
for ( var i=0; i < this.cols; i++ ) {
this.colYs.push( 0 );
}
this.maxY = 0;
this.horizontalColIndex = 0;
};
proto.measureColumns = function() {
this.getContainerWidth();
// if columnWidth is 0, default to outerWidth of first item
if ( !this.columnWidth ) {
var firstItem = this.items[0];
var firstItemElem = firstItem && firstItem.element;
// columnWidth fall back to item of first element
this.columnWidth = firstItemElem && getSize( firstItemElem ).outerWidth ||
// if first elem has no width, default to size of container
this.containerWidth;
}
var columnWidth = this.columnWidth += this.gutter;
// calculate columns
var containerWidth = this.containerWidth + this.gutter;
var cols = containerWidth / columnWidth;
// fix rounding errors, typically with gutters
var excess = columnWidth - containerWidth % columnWidth;
// if overshoot is less than a pixel, round up, otherwise floor it
var mathMethod = excess && excess < 1 ? 'round' : 'floor';
cols = Math[ mathMethod ]( cols );
this.cols = Math.max( cols, 1 );
};
proto.getContainerWidth = function() {
// container is parent if fit width
var isFitWidth = this._getOption('fitWidth');
var container = isFitWidth ? this.element.parentNode : this.element;
// check that this.size and size are there
// IE8 triggers resize on body size change, so they might not be
var size = getSize( container );
this.containerWidth = size && size.innerWidth;
};
proto._getItemLayoutPosition = function( item ) {
item.getSize();
// how many columns does this brick span
var remainder = item.size.outerWidth % this.columnWidth;
var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
// round if off by 1 pixel, otherwise use ceil
var colSpan = Math[ mathMethod ]( item.size.outerWidth / this.columnWidth );
colSpan = Math.min( colSpan, this.cols );
// use horizontal or top column position
var colPosMethod = this.options.horizontalOrder ?
'_getHorizontalColPosition' : '_getTopColPosition';
var colPosition = this[ colPosMethod ]( colSpan, item );
// position the brick
var position = {
x: this.columnWidth * colPosition.col,
y: colPosition.y
};
// apply setHeight to necessary columns
var setHeight = colPosition.y + item.size.outerHeight;
var setMax = colSpan + colPosition.col;
for ( var i = colPosition.col; i < setMax; i++ ) {
this.colYs[i] = setHeight;
}
return position;
};
proto._getTopColPosition = function( colSpan ) {
var colGroup = this._getTopColGroup( colSpan );
// get the minimum Y value from the columns
var minimumY = Math.min.apply( Math, colGroup );
return {
col: colGroup.indexOf( minimumY ),
y: minimumY,
};
};
/**
* @param {Number} colSpan - number of columns the element spans
* @returns {Array} colGroup
*/
proto._getTopColGroup = function( colSpan ) {
if ( colSpan < 2 ) {
// if brick spans only one column, use all the column Ys
return this.colYs;
}
var colGroup = [];
// how many different places could this brick fit horizontally
var groupCount = this.cols + 1 - colSpan;
// for each group potential horizontal position
for ( var i = 0; i < groupCount; i++ ) {
colGroup[i] = this._getColGroupY( i, colSpan );
}
return colGroup;
};
proto._getColGroupY = function( col, colSpan ) {
if ( colSpan < 2 ) {
return this.colYs[ col ];
}
// make an array of colY values for that one group
var groupColYs = this.colYs.slice( col, col + colSpan );
// and get the max value of the array
return Math.max.apply( Math, groupColYs );
};
// get column position based on horizontal index. #873
proto._getHorizontalColPosition = function( colSpan, item ) {
var col = this.horizontalColIndex % this.cols;
var isOver = colSpan > 1 && col + colSpan > this.cols;
// shift to next row if item can't fit on current row
col = isOver ? 0 : col;
// don't let zero-size items take up space
var hasSize = item.size.outerWidth && item.size.outerHeight;
this.horizontalColIndex = hasSize ? col + colSpan : this.horizontalColIndex;
return {
col: col,
y: this._getColGroupY( col, colSpan ),
};
};
proto._manageStamp = function( stamp ) {
var stampSize = getSize( stamp );
var offset = this._getElementOffset( stamp );
// get the columns that this stamp affects
var isOriginLeft = this._getOption('originLeft');
var firstX = isOriginLeft ? offset.left : offset.right;
var lastX = firstX + stampSize.outerWidth;
var firstCol = Math.floor( firstX / this.columnWidth );
firstCol = Math.max( 0, firstCol );
var lastCol = Math.floor( lastX / this.columnWidth );
// lastCol should not go over if multiple of columnWidth #425
lastCol -= lastX % this.columnWidth ? 0 : 1;
lastCol = Math.min( this.cols - 1, lastCol );
// set colYs to bottom of the stamp
var isOriginTop = this._getOption('originTop');
var stampMaxY = ( isOriginTop ? offset.top : offset.bottom ) +
stampSize.outerHeight;
for ( var i = firstCol; i <= lastCol; i++ ) {
this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
}
};
proto._getContainerSize = function() {
this.maxY = Math.max.apply( Math, this.colYs );
var size = {
height: this.maxY
};
if ( this._getOption('fitWidth') ) {
size.width = this._getContainerFitWidth();
}
return size;
};
proto._getContainerFitWidth = function() {
var unusedCols = 0;
// count unused columns
var i = this.cols;
while ( --i ) {
if ( this.colYs[i] !== 0 ) {
break;
}
unusedCols++;
}
// fit container to columns that have been used
return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
};
proto.needsResizeLayout = function() {
var previousWidth = this.containerWidth;
this.getContainerWidth();
return previousWidth != this.containerWidth;
};
return Masonry;
}));
/*!
* Masonry layout mode
* sub-classes Masonry
* https://masonry.desandro.com
*/
( function( window, factory ) {
// universal module definition
/* jshint strict: false */ /*globals define, module, require */
if ( typeof define == 'function' && define.amd ) {
// AMD
define( 'isotope-layout/js/layout-modes/masonry',[
'../layout-mode',
'masonry-layout/masonry'
],
factory );
} else if ( typeof module == 'object' && module.exports ) {
// CommonJS
module.exports = factory(
require('../layout-mode'),
require('masonry-layout')
);
} else {
// browser global
factory(
window.Isotope.LayoutMode,
window.Masonry
);
}
}( window, function factory( LayoutMode, Masonry ) {
'use strict';
// -------------------------- masonryDefinition -------------------------- //
// create an Outlayer layout class
var MasonryMode = LayoutMode.create('masonry');
var proto = MasonryMode.prototype;
var keepModeMethods = {
_getElementOffset: true,
layout: true,
_getMeasurement: true
};
// inherit Masonry prototype
for ( var method in Masonry.prototype ) {
// do not inherit mode methods
if ( !keepModeMethods[ method ] ) {
proto[ method ] = Masonry.prototype[ method ];
}
}
var measureColumns = proto.measureColumns;
proto.measureColumns = function() {
// set items, used if measuring first item
this.items = this.isotope.filteredItems;
measureColumns.call( this );
};
// point to mode options for fitWidth
var _getOption = proto._getOption;
proto._getOption = function( option ) {
if ( option == 'fitWidth' ) {
return this.options.isFitWidth !== undefined ?
this.options.isFitWidth : this.options.fitWidth;
}
return _getOption.apply( this.isotope, arguments );
};
return MasonryMode;
}));
/**
* fitRows layout mode
*/
( function( window, factory ) {
// universal module definition
/* jshint strict: false */ /*globals define, module, require */
if ( typeof define == 'function' && define.amd ) {
// AMD
define( 'isotope-layout/js/layout-modes/fit-rows',[
'../layout-mode'
],
factory );
} else if ( typeof exports == 'object' ) {
// CommonJS
module.exports = factory(
require('../layout-mode')
);
} else {
// browser global
factory(
window.Isotope.LayoutMode
);
}
}( window, function factory( LayoutMode ) {
'use strict';
var FitRows = LayoutMode.create('fitRows');
var proto = FitRows.prototype;
proto._resetLayout = function() {
this.x = 0;
this.y = 0;
this.maxY = 0;
this._getMeasurement( 'gutter', 'outerWidth' );
};
proto._getItemLayoutPosition = function( item ) {
item.getSize();
var itemWidth = item.size.outerWidth + this.gutter;
// if this element cannot fit in the current row
var containerWidth = this.isotope.size.innerWidth + this.gutter;
if ( this.x !== 0 && itemWidth + this.x > containerWidth ) {
this.x = 0;
this.y = this.maxY;
}
var position = {
x: this.x,
y: this.y
};
this.maxY = Math.max( this.maxY, this.y + item.size.outerHeight );
this.x += itemWidth;
return position;
};
proto._getContainerSize = function() {
return { height: this.maxY };
};
return FitRows;
}));
/**
* vertical layout mode
*/
( function( window, factory ) {
// universal module definition
/* jshint strict: false */ /*globals define, module, require */
if ( typeof define == 'function' && define.amd ) {
// AMD
define( 'isotope-layout/js/layout-modes/vertical',[
'../layout-mode'
],
factory );
} else if ( typeof module == 'object' && module.exports ) {
// CommonJS
module.exports = factory(
require('../layout-mode')
);
} else {
// browser global
factory(
window.Isotope.LayoutMode
);
}
}( window, function factory( LayoutMode ) {
'use strict';
var Vertical = LayoutMode.create( 'vertical', {
horizontalAlignment: 0
});
var proto = Vertical.prototype;
proto._resetLayout = function() {
this.y = 0;
};
proto._getItemLayoutPosition = function( item ) {
item.getSize();
var x = ( this.isotope.size.innerWidth - item.size.outerWidth ) *
this.options.horizontalAlignment;
var y = this.y;
this.y += item.size.outerHeight;
return { x: x, y: y };
};
proto._getContainerSize = function() {
return { height: this.y };
};
return Vertical;
}));
/*!
* Isotope v3.0.6
*
* Licensed GPLv3 for open source use
* or Isotope Commercial License for commercial use
*
* https://isotope.metafizzy.co
* Copyright 2010-2018 Metafizzy
*/
( function( window, factory ) {
// universal module definition
/* jshint strict: false */ /*globals define, module, require */
if ( typeof define == 'function' && define.amd ) {
// AMD
define( [
'outlayer/outlayer',
'get-size/get-size',
'desandro-matches-selector/matches-selector',
'fizzy-ui-utils/utils',
'isotope-layout/js/item',
'isotope-layout/js/layout-mode',
// include default layout modes
'isotope-layout/js/layout-modes/masonry',
'isotope-layout/js/layout-modes/fit-rows',
'isotope-layout/js/layout-modes/vertical'
],
function( Outlayer, getSize, matchesSelector, utils, Item, LayoutMode ) {
return factory( window, Outlayer, getSize, matchesSelector, utils, Item, LayoutMode );
});
} else if ( typeof module == 'object' && module.exports ) {
// CommonJS
module.exports = factory(
window,
require('outlayer'),
require('get-size'),
require('desandro-matches-selector'),
require('fizzy-ui-utils'),
require('isotope-layout/js/item'),
require('isotope-layout/js/layout-mode'),
// include default layout modes
require('isotope-layout/js/layout-modes/masonry'),
require('isotope-layout/js/layout-modes/fit-rows'),
require('isotope-layout/js/layout-modes/vertical')
);
} else {
// browser global
window.Isotope = factory(
window,
window.Outlayer,
window.getSize,
window.matchesSelector,
window.fizzyUIUtils,
window.Isotope.Item,
window.Isotope.LayoutMode
);
}
}( window, function factory( window, Outlayer, getSize, matchesSelector, utils,
Item, LayoutMode ) {
// -------------------------- vars -------------------------- //
var jQuery = window.jQuery;
// -------------------------- helpers -------------------------- //
var trim = String.prototype.trim ?
function( str ) {
return str.trim();
} :
function( str ) {
return str.replace( /^\s+|\s+$/g, '' );
};
// -------------------------- isotopeDefinition -------------------------- //
// create an Outlayer layout class
var Isotope = Outlayer.create( 'isotope', {
layoutMode: 'masonry',
isJQueryFiltering: true,
sortAscending: true
});
Isotope.Item = Item;
Isotope.LayoutMode = LayoutMode;
var proto = Isotope.prototype;
proto._create = function() {
this.itemGUID = 0;
// functions that sort items
this._sorters = {};
this._getSorters();
// call super
Outlayer.prototype._create.call( this );
// create layout modes
this.modes = {};
// start filteredItems with all items
this.filteredItems = this.items;
// keep of track of sortBys
this.sortHistory = [ 'original-order' ];
// create from registered layout modes
for ( var name in LayoutMode.modes ) {
this._initLayoutMode( name );
}
};
proto.reloadItems = function() {
// reset item ID counter
this.itemGUID = 0;
// call super
Outlayer.prototype.reloadItems.call( this );
};
proto._itemize = function() {
var items = Outlayer.prototype._itemize.apply( this, arguments );
// assign ID for original-order
for ( var i=0; i < items.length; i++ ) {
var item = items[i];
item.id = this.itemGUID++;
}
this._updateItemsSortData( items );
return items;
};
// -------------------------- layout -------------------------- //
proto._initLayoutMode = function( name ) {
var Mode = LayoutMode.modes[ name ];
// set mode options
// HACK extend initial options, back-fill in default options
var initialOpts = this.options[ name ] || {};
this.options[ name ] = Mode.options ?
utils.extend( Mode.options, initialOpts ) : initialOpts;
// init layout mode instance
this.modes[ name ] = new Mode( this );
};
proto.layout = function() {
// if first time doing layout, do all magic
if ( !this._isLayoutInited && this._getOption('initLayout') ) {
this.arrange();
return;
}
this._layout();
};
// private method to be used in layout() & magic()
proto._layout = function() {
// don't animate first layout
var isInstant = this._getIsInstant();
// layout flow
this._resetLayout();
this._manageStamps();
this.layoutItems( this.filteredItems, isInstant );
// flag for initalized
this._isLayoutInited = true;
};
// filter + sort + layout
proto.arrange = function( opts ) {
// set any options pass
this.option( opts );
this._getIsInstant();
// filter, sort, and layout
// filter
var filtered = this._filter( this.items );
this.filteredItems = filtered.matches;
this._bindArrangeComplete();
if ( this._isInstant ) {
this._noTransition( this._hideReveal, [ filtered ] );
} else {
this._hideReveal( filtered );
}
this._sort();
this._layout();
};
// alias to _init for main plugin method
proto._init = proto.arrange;
proto._hideReveal = function( filtered ) {
this.reveal( filtered.needReveal );
this.hide( filtered.needHide );
};
// HACK
// Don't animate/transition first layout
// Or don't animate/transition other layouts
proto._getIsInstant = function() {
var isLayoutInstant = this._getOption('layoutInstant');
var isInstant = isLayoutInstant !== undefined ? isLayoutInstant :
!this._isLayoutInited;
this._isInstant = isInstant;
return isInstant;
};
// listen for layoutComplete, hideComplete and revealComplete
// to trigger arrangeComplete
proto._bindArrangeComplete = function() {
// listen for 3 events to trigger arrangeComplete
var isLayoutComplete, isHideComplete, isRevealComplete;
var _this = this;
function arrangeParallelCallback() {
if ( isLayoutComplete && isHideComplete && isRevealComplete ) {
_this.dispatchEvent( 'arrangeComplete', null, [ _this.filteredItems ] );
}
}
this.once( 'layoutComplete', function() {
isLayoutComplete = true;
arrangeParallelCallback();
});
this.once( 'hideComplete', function() {
isHideComplete = true;
arrangeParallelCallback();
});
this.once( 'revealComplete', function() {
isRevealComplete = true;
arrangeParallelCallback();
});
};
// -------------------------- filter -------------------------- //
proto._filter = function( items ) {
var filter = this.options.filter;
filter = filter || '*';
var matches = [];
var hiddenMatched = [];
var visibleUnmatched = [];
var test = this._getFilterTest( filter );
// test each item
for ( var i=0; i < items.length; i++ ) {
var item = items[i];
if ( item.isIgnored ) {
continue;
}
// add item to either matched or unmatched group
var isMatched = test( item );
// item.isFilterMatched = isMatched;
// add to matches if its a match
if ( isMatched ) {
matches.push( item );
}
// add to additional group if item needs to be hidden or revealed
if ( isMatched && item.isHidden ) {
hiddenMatched.push( item );
} else if ( !isMatched && !item.isHidden ) {
visibleUnmatched.push( item );
}
}
// return collections of items to be manipulated
return {
matches: matches,
needReveal: hiddenMatched,
needHide: visibleUnmatched
};
};
// get a jQuery, function, or a matchesSelector test given the filter
proto._getFilterTest = function( filter ) {
if ( jQuery && this.options.isJQueryFiltering ) {
// use jQuery
return function( item ) {
return jQuery( item.element ).is( filter );
};
}
if ( typeof filter == 'function' ) {
// use filter as function
return function( item ) {
return filter( item.element );
};
}
// default, use filter as selector string
return function( item ) {
return matchesSelector( item.element, filter );
};
};
// -------------------------- sorting -------------------------- //
/**
* @params {Array} elems
* @public
*/
proto.updateSortData = function( elems ) {
// get items
var items;
if ( elems ) {
elems = utils.makeArray( elems );
items = this.getItems( elems );
} else {
// update all items if no elems provided
items = this.items;
}
this._getSorters();
this._updateItemsSortData( items );
};
proto._getSorters = function() {
var getSortData = this.options.getSortData;
for ( var key in getSortData ) {
var sorter = getSortData[ key ];
this._sorters[ key ] = mungeSorter( sorter );
}
};
/**
* @params {Array} items - of Isotope.Items
* @private
*/
proto._updateItemsSortData = function( items ) {
// do not update if no items
var len = items && items.length;
for ( var i=0; len && i < len; i++ ) {
var item = items[i];
item.updateSortData();
}
};
// ----- munge sorter ----- //
// encapsulate this, as we just need mungeSorter
// other functions in here are just for munging
var mungeSorter = ( function() {
// add a magic layer to sorters for convienent shorthands
// `.foo-bar` will use the text of .foo-bar querySelector
// `[foo-bar]` will use attribute
// you can also add parser
// `.foo-bar parseInt` will parse that as a number
function mungeSorter( sorter ) {
// if not a string, return function or whatever it is
if ( typeof sorter != 'string' ) {
return sorter;
}
// parse the sorter string
var args = trim( sorter ).split(' ');
var query = args[0];
// check if query looks like [an-attribute]
var attrMatch = query.match( /^\[(.+)\]$/ );
var attr = attrMatch && attrMatch[1];
var getValue = getValueGetter( attr, query );
// use second argument as a parser
var parser = Isotope.sortDataParsers[ args[1] ];
// parse the value, if there was a parser
sorter = parser ? function( elem ) {
return elem && parser( getValue( elem ) );
} :
// otherwise just return value
function( elem ) {
return elem && getValue( elem );
};
return sorter;
}
// get an attribute getter, or get text of the querySelector
function getValueGetter( attr, query ) {
// if query looks like [foo-bar], get attribute
if ( attr ) {
return function getAttribute( elem ) {
return elem.getAttribute( attr );
};
}
// otherwise, assume its a querySelector, and get its text
return function getChildText( elem ) {
var child = elem.querySelector( query );
return child && child.textContent;
};
}
return mungeSorter;
})();
// parsers used in getSortData shortcut strings
Isotope.sortDataParsers = {
'parseInt': function( val ) {
return parseInt( val, 10 );
},
'parseFloat': function( val ) {
return parseFloat( val );
}
};
// ----- sort method ----- //
// sort filteredItem order
proto._sort = function() {
if ( !this.options.sortBy ) {
return;
}
// keep track of sortBy History
var sortBys = utils.makeArray( this.options.sortBy );
if ( !this._getIsSameSortBy( sortBys ) ) {
// concat all sortBy and sortHistory, add to front, oldest goes in last
this.sortHistory = sortBys.concat( this.sortHistory );
}
// sort magic
var itemSorter = getItemSorter( this.sortHistory, this.options.sortAscending );
this.filteredItems.sort( itemSorter );
};
// check if sortBys is same as start of sortHistory
proto._getIsSameSortBy = function( sortBys ) {
for ( var i=0; i < sortBys.length; i++ ) {
if ( sortBys[i] != this.sortHistory[i] ) {
return false;
}
}
return true;
};
// returns a function used for sorting
function getItemSorter( sortBys, sortAsc ) {
return function sorter( itemA, itemB ) {
// cycle through all sortKeys
for ( var i = 0; i < sortBys.length; i++ ) {
var sortBy = sortBys[i];
var a = itemA.sortData[ sortBy ];
var b = itemB.sortData[ sortBy ];
if ( a > b || a < b ) {
// if sortAsc is an object, use the value given the sortBy key
var isAscending = sortAsc[ sortBy ] !== undefined ? sortAsc[ sortBy ] : sortAsc;
var direction = isAscending ? 1 : -1;
return ( a > b ? 1 : -1 ) * direction;
}
}
return 0;
};
}
// -------------------------- methods -------------------------- //
// get layout mode
proto._mode = function() {
var layoutMode = this.options.layoutMode;
var mode = this.modes[ layoutMode ];
if ( !mode ) {
// TODO console.error
throw new Error( 'No layout mode: ' + layoutMode );
}
// HACK sync mode's options
// any options set after init for layout mode need to be synced
mode.options = this.options[ layoutMode ];
return mode;
};
proto._resetLayout = function() {
// trigger original reset layout
Outlayer.prototype._resetLayout.call( this );
this._mode()._resetLayout();
};
proto._getItemLayoutPosition = function( item ) {
return this._mode()._getItemLayoutPosition( item );
};
proto._manageStamp = function( stamp ) {
this._mode()._manageStamp( stamp );
};
proto._getContainerSize = function() {
return this._mode()._getContainerSize();
};
proto.needsResizeLayout = function() {
return this._mode().needsResizeLayout();
};
// -------------------------- adding & removing -------------------------- //
// HEADS UP overwrites default Outlayer appended
proto.appended = function( elems ) {
var items = this.addItems( elems );
if ( !items.length ) {
return;
}
// filter, layout, reveal new items
var filteredItems = this._filterRevealAdded( items );
// add to filteredItems
this.filteredItems = this.filteredItems.concat( filteredItems );
};
// HEADS UP overwrites default Outlayer prepended
proto.prepended = function( elems ) {
var items = this._itemize( elems );
if ( !items.length ) {
return;
}
// start new layout
this._resetLayout();
this._manageStamps();
// filter, layout, reveal new items
var filteredItems = this._filterRevealAdded( items );
// layout previous items
this.layoutItems( this.filteredItems );
// add to items and filteredItems
this.filteredItems = filteredItems.concat( this.filteredItems );
this.items = items.concat( this.items );
};
proto._filterRevealAdded = function( items ) {
var filtered = this._filter( items );
this.hide( filtered.needHide );
// reveal all new items
this.reveal( filtered.matches );
// layout new items, no transition
this.layoutItems( filtered.matches, true );
return filtered.matches;
};
/**
* Filter, sort, and layout newly-appended item elements
* @param {Array or NodeList or Element} elems
*/
proto.insert = function( elems ) {
var items = this.addItems( elems );
if ( !items.length ) {
return;
}
// append item elements
var i, item;
var len = items.length;
for ( i=0; i < len; i++ ) {
item = items[i];
this.element.appendChild( item.element );
}
// filter new stuff
var filteredInsertItems = this._filter( items ).matches;
// set flag
for ( i=0; i < len; i++ ) {
items[i].isLayoutInstant = true;
}
this.arrange();
// reset flag
for ( i=0; i < len; i++ ) {
delete items[i].isLayoutInstant;
}
this.reveal( filteredInsertItems );
};
var _remove = proto.remove;
proto.remove = function( elems ) {
elems = utils.makeArray( elems );
var removeItems = this.getItems( elems );
// do regular thing
_remove.call( this, elems );
// bail if no items to remove
var len = removeItems && removeItems.length;
// remove elems from filteredItems
for ( var i=0; len && i < len; i++ ) {
var item = removeItems[i];
// remove item from collection
utils.removeFrom( this.filteredItems, item );
}
};
proto.shuffle = function() {
// update random sortData
for ( var i=0; i < this.items.length; i++ ) {
var item = this.items[i];
item.sortData.random = Math.random();
}
this.options.sortBy = 'random';
this._sort();
this._layout();
};
/**
* trigger fn without transition
* kind of hacky to have this in the first place
* @param {Function} fn
* @param {Array} args
* @returns ret
* @private
*/
proto._noTransition = function( fn, args ) {
// save transitionDuration before disabling
var transitionDuration = this.options.transitionDuration;
// disable transition
this.options.transitionDuration = 0;
// do it
var returnValue = fn.apply( this, args );
// re-enable transition for reveal
this.options.transitionDuration = transitionDuration;
return returnValue;
};
// ----- helper methods ----- //
/**
* getter method for getting filtered item elements
* @returns {Array} elems - collection of item elements
*/
proto.getFilteredItemElements = function() {
return this.filteredItems.map( function( item ) {
return item.element;
});
};
// ----- ----- //
return Isotope;
}));
/*!
* Packery layout mode PACKAGED v2.0.1
* sub-classes Packery
*/
/**
* Rect
* low-level utility class for basic geometry
*/
( function( window, factory ) {
// universal module definition
/* jshint strict: false */ /* globals define, module */
if ( typeof define == 'function' && define.amd ) {
// AMD
define( 'packery/js/rect',factory );
} else if ( typeof module == 'object' && module.exports ) {
// CommonJS
module.exports = factory();
} else {
// browser global
window.Packery = window.Packery || {};
window.Packery.Rect = factory();
}
}( window, function factory() {
// -------------------------- Rect -------------------------- //
function Rect( props ) {
// extend properties from defaults
for ( var prop in Rect.defaults ) {
this[ prop ] = Rect.defaults[ prop ];
}
for ( prop in props ) {
this[ prop ] = props[ prop ];
}
}
Rect.defaults = {
x: 0,
y: 0,
width: 0,
height: 0
};
var proto = Rect.prototype;
/**
* Determines whether or not this rectangle wholly encloses another rectangle or point.
* @param {Rect} rect
* @returns {Boolean}
**/
proto.contains = function( rect ) {
// points don't have width or height
var otherWidth = rect.width || 0;
var otherHeight = rect.height || 0;
return this.x <= rect.x &&
this.y <= rect.y &&
this.x + this.width >= rect.x + otherWidth &&
this.y + this.height >= rect.y + otherHeight;
};
/**
* Determines whether or not the rectangle intersects with another.
* @param {Rect} rect
* @returns {Boolean}
**/
proto.overlaps = function( rect ) {
var thisRight = this.x + this.width;
var thisBottom = this.y + this.height;
var rectRight = rect.x + rect.width;
var rectBottom = rect.y + rect.height;
// http://stackoverflow.com/a/306332
return this.x < rectRight &&
thisRight > rect.x &&
this.y < rectBottom &&
thisBottom > rect.y;
};
/**
* @param {Rect} rect - the overlapping rect
* @returns {Array} freeRects - rects representing the area around the rect
**/
proto.getMaximalFreeRects = function( rect ) {
// if no intersection, return false
if ( !this.overlaps( rect ) ) {
return false;
}
var freeRects = [];
var freeRect;
var thisRight = this.x + this.width;
var thisBottom = this.y + this.height;
var rectRight = rect.x + rect.width;
var rectBottom = rect.y + rect.height;
// top
if ( this.y < rect.y ) {
freeRect = new Rect({
x: this.x,
y: this.y,
width: this.width,
height: rect.y - this.y
});
freeRects.push( freeRect );
}
// right
if ( thisRight > rectRight ) {
freeRect = new Rect({
x: rectRight,
y: this.y,
width: thisRight - rectRight,
height: this.height
});
freeRects.push( freeRect );
}
// bottom
if ( thisBottom > rectBottom ) {
freeRect = new Rect({
x: this.x,
y: rectBottom,
width: this.width,
height: thisBottom - rectBottom
});
freeRects.push( freeRect );
}
// left
if ( this.x < rect.x ) {
freeRect = new Rect({
x: this.x,
y: this.y,
width: rect.x - this.x,
height: this.height
});
freeRects.push( freeRect );
}
return freeRects;
};
proto.canFit = function( rect ) {
return this.width >= rect.width && this.height >= rect.height;
};
return Rect;
}));
/**
* Packer
* bin-packing algorithm
*/
( function( window, factory ) {
// universal module definition
/* jshint strict: false */ /* globals define, module, require */
if ( typeof define == 'function' && define.amd ) {
// AMD
define( 'packery/js/packer',[ './rect' ], factory );
} else if ( typeof module == 'object' && module.exports ) {
// CommonJS
module.exports = factory(
require('./rect')
);
} else {
// browser global
var Packery = window.Packery = window.Packery || {};
Packery.Packer = factory( Packery.Rect );
}
}( window, function factory( Rect ) {
// -------------------------- Packer -------------------------- //
/**
* @param {Number} width
* @param {Number} height
* @param {String} sortDirection
* topLeft for vertical, leftTop for horizontal
*/
function Packer( width, height, sortDirection ) {
this.width = width || 0;
this.height = height || 0;
this.sortDirection = sortDirection || 'downwardLeftToRight';
this.reset();
}
var proto = Packer.prototype;
proto.reset = function() {
this.spaces = [];
var initialSpace = new Rect({
x: 0,
y: 0,
width: this.width,
height: this.height
});
this.spaces.push( initialSpace );
// set sorter
this.sorter = sorters[ this.sortDirection ] || sorters.downwardLeftToRight;
};
// change x and y of rect to fit with in Packer's available spaces
proto.pack = function( rect ) {
for ( var i=0; i < this.spaces.length; i++ ) {
var space = this.spaces[i];
if ( space.canFit( rect ) ) {
this.placeInSpace( rect, space );
break;
}
}
};
proto.columnPack = function( rect ) {
for ( var i=0; i < this.spaces.length; i++ ) {
var space = this.spaces[i];
var canFitInSpaceColumn = space.x <= rect.x &&
space.x + space.width >= rect.x + rect.width &&
space.height >= rect.height - 0.01; // fudge number for rounding error
if ( canFitInSpaceColumn ) {
rect.y = space.y;
this.placed( rect );
break;
}
}
};
proto.rowPack = function( rect ) {
for ( var i=0; i < this.spaces.length; i++ ) {
var space = this.spaces[i];
var canFitInSpaceRow = space.y <= rect.y &&
space.y + space.height >= rect.y + rect.height &&
space.width >= rect.width - 0.01; // fudge number for rounding error
if ( canFitInSpaceRow ) {
rect.x = space.x;
this.placed( rect );
break;
}
}
};
proto.placeInSpace = function( rect, space ) {
// place rect in space
rect.x = space.x;
rect.y = space.y;
this.placed( rect );
};
// update spaces with placed rect
proto.placed = function( rect ) {
// update spaces
var revisedSpaces = [];
for ( var i=0; i < this.spaces.length; i++ ) {
var space = this.spaces[i];
var newSpaces = space.getMaximalFreeRects( rect );
// add either the original space or the new spaces to the revised spaces
if ( newSpaces ) {
revisedSpaces.push.apply( revisedSpaces, newSpaces );
} else {
revisedSpaces.push( space );
}
}
this.spaces = revisedSpaces;
this.mergeSortSpaces();
};
proto.mergeSortSpaces = function() {
// remove redundant spaces
Packer.mergeRects( this.spaces );
this.spaces.sort( this.sorter );
};
// add a space back
proto.addSpace = function( rect ) {
this.spaces.push( rect );
this.mergeSortSpaces();
};
// -------------------------- utility functions -------------------------- //
/**
* Remove redundant rectangle from array of rectangles
* @param {Array} rects: an array of Rects
* @returns {Array} rects: an array of Rects
**/
Packer.mergeRects = function( rects ) {
var i = 0;
var rect = rects[i];
rectLoop:
while ( rect ) {
var j = 0;
var compareRect = rects[ i + j ];
while ( compareRect ) {
if ( compareRect == rect ) {
j++; // next
} else if ( compareRect.contains( rect ) ) {
// remove rect
rects.splice( i, 1 );
rect = rects[i]; // set next rect
continue rectLoop; // bail on compareLoop
} else if ( rect.contains( compareRect ) ) {
// remove compareRect
rects.splice( i + j, 1 );
} else {
j++;
}
compareRect = rects[ i + j ]; // set next compareRect
}
i++;
rect = rects[i];
}
return rects;
};
// -------------------------- sorters -------------------------- //
// functions for sorting rects in order
var sorters = {
// top down, then left to right
downwardLeftToRight: function( a, b ) {
return a.y - b.y || a.x - b.x;
},
// left to right, then top down
rightwardTopToBottom: function( a, b ) {
return a.x - b.x || a.y - b.y;
}
};
// -------------------------- -------------------------- //
return Packer;
}));
/**
* Packery Item Element
**/
( function( window, factory ) {
// universal module definition
/* jshint strict: false */ /* globals define, module, require */
if ( typeof define == 'function' && define.amd ) {
// AMD
define( 'packery/js/item',[
'outlayer/outlayer',
'./rect'
],
factory );
} else if ( typeof module == 'object' && module.exports ) {
// CommonJS
module.exports = factory(
require('outlayer'),
require('./rect')
);
} else {
// browser global
window.Packery.Item = factory(
window.Outlayer,
window.Packery.Rect
);
}
}( window, function factory( Outlayer, Rect ) {
// -------------------------- Item -------------------------- //
var docElemStyle = document.documentElement.style;
var transformProperty = typeof docElemStyle.transform == 'string' ?
'transform' : 'WebkitTransform';
// sub-class Item
var Item = function PackeryItem() {
Outlayer.Item.apply( this, arguments );
};
var proto = Item.prototype = Object.create( Outlayer.Item.prototype );
var __create = proto._create;
proto._create = function() {
// call default _create logic
__create.call( this );
this.rect = new Rect();
};
var _moveTo = proto.moveTo;
proto.moveTo = function( x, y ) {
// don't shift 1px while dragging
var dx = Math.abs( this.position.x - x );
var dy = Math.abs( this.position.y - y );
var canHackGoTo = this.layout.dragItemCount && !this.isPlacing &&
!this.isTransitioning && dx < 1 && dy < 1;
if ( canHackGoTo ) {
this.goTo( x, y );
return;
}
_moveTo.apply( this, arguments );
};
// -------------------------- placing -------------------------- //
proto.enablePlacing = function() {
this.removeTransitionStyles();
// remove transform property from transition
if ( this.isTransitioning && transformProperty ) {
this.element.style[ transformProperty ] = 'none';
}
this.isTransitioning = false;
this.getSize();
this.layout._setRectSize( this.element, this.rect );
this.isPlacing = true;
};
proto.disablePlacing = function() {
this.isPlacing = false;
};
// ----- ----- //
// remove element from DOM
proto.removeElem = function() {
this.element.parentNode.removeChild( this.element );
// add space back to packer
this.layout.packer.addSpace( this.rect );
this.emitEvent( 'remove', [ this ] );
};
// ----- dropPlaceholder ----- //
proto.showDropPlaceholder = function() {
var dropPlaceholder = this.dropPlaceholder;
if ( !dropPlaceholder ) {
// create dropPlaceholder
dropPlaceholder = this.dropPlaceholder = document.createElement('div');
dropPlaceholder.className = 'packery-drop-placeholder';
dropPlaceholder.style.position = 'absolute';
}
dropPlaceholder.style.width = this.size.width + 'px';
dropPlaceholder.style.height = this.size.height + 'px';
this.positionDropPlaceholder();
this.layout.element.appendChild( dropPlaceholder );
};
proto.positionDropPlaceholder = function() {
this.dropPlaceholder.style[ transformProperty ] = 'translate(' +
this.rect.x + 'px, ' + this.rect.y + 'px)';
};
proto.hideDropPlaceholder = function() {
this.layout.element.removeChild( this.dropPlaceholder );
};
// ----- ----- //
return Item;
}));
/*!
* Packery v2.0.0
* Gapless, draggable grid layouts
*
* Licensed GPLv3 for open source use
* or Packery Commercial License for commercial use
*
* http://packery.metafizzy.co
* Copyright 2016 Metafizzy
*/
( function( window, factory ) {
// universal module definition
/* jshint strict: false */ /* globals define, module, require */
if ( typeof define == 'function' && define.amd ) {
// AMD
define( 'packery/js/packery',[
'get-size/get-size',
'outlayer/outlayer',
'./rect',
'./packer',
'./item'
],
factory );
} else if ( typeof module == 'object' && module.exports ) {
// CommonJS
module.exports = factory(
require('get-size'),
require('outlayer'),
require('./rect'),
require('./packer'),
require('./item')
);
} else {
// browser global
window.Packery = factory(
window.getSize,
window.Outlayer,
window.Packery.Rect,
window.Packery.Packer,
window.Packery.Item
);
}
}( window, function factory( getSize, Outlayer, Rect, Packer, Item ) {
// ----- Rect ----- //
// allow for pixel rounding errors IE8-IE11 & Firefox; #227
Rect.prototype.canFit = function( rect ) {
return this.width >= rect.width - 1 && this.height >= rect.height - 1;
};
// -------------------------- Packery -------------------------- //
// create an Outlayer layout class
var Packery = Outlayer.create('packery');
Packery.Item = Item;
var proto = Packery.prototype;
proto._create = function() {
// call super
Outlayer.prototype._create.call( this );
// initial properties
this.packer = new Packer();
// packer for drop targets
this.shiftPacker = new Packer();
this.isEnabled = true;
this.dragItemCount = 0;
// create drag handlers
var _this = this;
this.handleDraggabilly = {
dragStart: function() {
_this.itemDragStart( this.element );
},
dragMove: function() {
_this.itemDragMove( this.element, this.position.x, this.position.y );
},
dragEnd: function() {
_this.itemDragEnd( this.element );
}
};
this.handleUIDraggable = {
start: function handleUIDraggableStart( event, ui ) {
// HTML5 may trigger dragstart, dismiss HTML5 dragging
if ( !ui ) {
return;
}
_this.itemDragStart( event.currentTarget );
},
drag: function handleUIDraggableDrag( event, ui ) {
if ( !ui ) {
return;
}
_this.itemDragMove( event.currentTarget, ui.position.left, ui.position.top );
},
stop: function handleUIDraggableStop( event, ui ) {
if ( !ui ) {
return;
}
_this.itemDragEnd( event.currentTarget );
}
};
};
// ----- init & layout ----- //
/**
* logic before any new layout
*/
proto._resetLayout = function() {
this.getSize();
this._getMeasurements();
// reset packer
var width, height, sortDirection;
// packer settings, if horizontal or vertical
if ( this._getOption('horizontal') ) {
width = Infinity;
height = this.size.innerHeight + this.gutter;
sortDirection = 'rightwardTopToBottom';
} else {
width = this.size.innerWidth + this.gutter;
height = Infinity;
sortDirection = 'downwardLeftToRight';
}
this.packer.width = this.shiftPacker.width = width;
this.packer.height = this.shiftPacker.height = height;
this.packer.sortDirection = this.shiftPacker.sortDirection = sortDirection;
this.packer.reset();
// layout
this.maxY = 0;
this.maxX = 0;
};
/**
* update columnWidth, rowHeight, & gutter
* @private
*/
proto._getMeasurements = function() {
this._getMeasurement( 'columnWidth', 'width' );
this._getMeasurement( 'rowHeight', 'height' );
this._getMeasurement( 'gutter', 'width' );
};
proto._getItemLayoutPosition = function( item ) {
this._setRectSize( item.element, item.rect );
if ( this.isShifting || this.dragItemCount > 0 ) {
var packMethod = this._getPackMethod();
this.packer[ packMethod ]( item.rect );
} else {
this.packer.pack( item.rect );
}
this._setMaxXY( item.rect );
return item.rect;
};
proto.shiftLayout = function() {
this.isShifting = true;
this.layout();
delete this.isShifting;
};
proto._getPackMethod = function() {
return this._getOption('horizontal') ? 'rowPack' : 'columnPack';
};
/**
* set max X and Y value, for size of container
* @param {Packery.Rect} rect
* @private
*/
proto._setMaxXY = function( rect ) {
this.maxX = Math.max( rect.x + rect.width, this.maxX );
this.maxY = Math.max( rect.y + rect.height, this.maxY );
};
/**
* set the width and height of a rect, applying columnWidth and rowHeight
* @param {Element} elem
* @param {Packery.Rect} rect
*/
proto._setRectSize = function( elem, rect ) {
var size = getSize( elem );
var w = size.outerWidth;
var h = size.outerHeight;
// size for columnWidth and rowHeight, if available
// only check if size is non-zero, #177
if ( w || h ) {
w = this._applyGridGutter( w, this.columnWidth );
h = this._applyGridGutter( h, this.rowHeight );
}
// rect must fit in packer
rect.width = Math.min( w, this.packer.width );
rect.height = Math.min( h, this.packer.height );
};
/**
* fits item to columnWidth/rowHeight and adds gutter
* @param {Number} measurement - item width or height
* @param {Number} gridSize - columnWidth or rowHeight
* @returns measurement
*/
proto._applyGridGutter = function( measurement, gridSize ) {
// just add gutter if no gridSize
if ( !gridSize ) {
return measurement + this.gutter;
}
gridSize += this.gutter;
// fit item to columnWidth/rowHeight
var remainder = measurement % gridSize;
var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
measurement = Math[ mathMethod ]( measurement / gridSize ) * gridSize;
return measurement;
};
proto._getContainerSize = function() {
if ( this._getOption('horizontal') ) {
return {
width: this.maxX - this.gutter
};
} else {
return {
height: this.maxY - this.gutter
};
}
};
// -------------------------- stamp -------------------------- //
/**
* makes space for element
* @param {Element} elem
*/
proto._manageStamp = function( elem ) {
var item = this.getItem( elem );
var rect;
if ( item && item.isPlacing ) {
rect = item.rect;
} else {
var offset = this._getElementOffset( elem );
rect = new Rect({
x: this._getOption('originLeft') ? offset.left : offset.right,
y: this._getOption('originTop') ? offset.top : offset.bottom
});
}
this._setRectSize( elem, rect );
// save its space in the packer
this.packer.placed( rect );
this._setMaxXY( rect );
};
// -------------------------- methods -------------------------- //
function verticalSorter( a, b ) {
return a.position.y - b.position.y || a.position.x - b.position.x;
}
function horizontalSorter( a, b ) {
return a.position.x - b.position.x || a.position.y - b.position.y;
}
proto.sortItemsByPosition = function() {
var sorter = this._getOption('horizontal') ? horizontalSorter : verticalSorter;
this.items.sort( sorter );
};
/**
* Fit item element in its current position
* Packery will position elements around it
* useful for expanding elements
*
* @param {Element} elem
* @param {Number} x - horizontal destination position, optional
* @param {Number} y - vertical destination position, optional
*/
proto.fit = function( elem, x, y ) {
var item = this.getItem( elem );
if ( !item ) {
return;
}
// stamp item to get it out of layout
this.stamp( item.element );
// set placing flag
item.enablePlacing();
this.updateShiftTargets( item );
// fall back to current position for fitting
x = x === undefined ? item.rect.x: x;
y = y === undefined ? item.rect.y: y;
// position it best at its destination
this.shift( item, x, y );
this._bindFitEvents( item );
item.moveTo( item.rect.x, item.rect.y );
// layout everything else
this.shiftLayout();
// return back to regularly scheduled programming
this.unstamp( item.element );
this.sortItemsByPosition();
item.disablePlacing();
};
/**
* emit event when item is fit and other items are laid out
* @param {Packery.Item} item
* @private
*/
proto._bindFitEvents = function( item ) {
var _this = this;
var ticks = 0;
function onLayout() {
ticks++;
if ( ticks != 2 ) {
return;
}
_this.dispatchEvent( 'fitComplete', null, [ item ] );
}
// when item is laid out
item.once( 'layout', onLayout );
// when all items are laid out
this.once( 'layoutComplete', onLayout );
};
// -------------------------- resize -------------------------- //
// debounced, layout on resize
proto.resize = function() {
// don't trigger if size did not change
// or if resize was unbound. See #285, outlayer#9
if ( !this.isResizeBound || !this.needsResizeLayout() ) {
return;
}
if ( this.options.shiftPercentResize ) {
this.resizeShiftPercentLayout();
} else {
this.layout();
}
};
/**
* check if layout is needed post layout
* @returns Boolean
*/
proto.needsResizeLayout = function() {
var size = getSize( this.element );
var innerSize = this._getOption('horizontal') ? 'innerHeight' : 'innerWidth';
return size[ innerSize ] != this.size[ innerSize ];
};
proto.resizeShiftPercentLayout = function() {
var items = this._getItemsForLayout( this.items );
var isHorizontal = this._getOption('horizontal');
var coord = isHorizontal ? 'y' : 'x';
var measure = isHorizontal ? 'height' : 'width';
var segmentName = isHorizontal ? 'rowHeight' : 'columnWidth';
var innerSize = isHorizontal ? 'innerHeight' : 'innerWidth';
// proportional re-align items
var previousSegment = this[ segmentName ];
previousSegment = previousSegment && previousSegment + this.gutter;
if ( previousSegment ) {
this._getMeasurements();
var currentSegment = this[ segmentName ] + this.gutter;
items.forEach( function( item ) {
var seg = Math.round( item.rect[ coord ] / previousSegment );
item.rect[ coord ] = seg * currentSegment;
});
} else {
var currentSize = getSize( this.element )[ innerSize ] + this.gutter;
var previousSize = this.packer[ measure ];
items.forEach( function( item ) {
item.rect[ coord ] = ( item.rect[ coord ] / previousSize ) * currentSize;
});
}
this.shiftLayout();
};
// -------------------------- drag -------------------------- //
/**
* handle an item drag start event
* @param {Element} elem
*/
proto.itemDragStart = function( elem ) {
if ( !this.isEnabled ) {
return;
}
this.stamp( elem );
// this.ignore( elem );
var item = this.getItem( elem );
if ( !item ) {
return;
}
item.enablePlacing();
item.showDropPlaceholder();
this.dragItemCount++;
this.updateShiftTargets( item );
};
proto.updateShiftTargets = function( dropItem ) {
this.shiftPacker.reset();
// pack stamps
this._getBoundingRect();
var isOriginLeft = this._getOption('originLeft');
var isOriginTop = this._getOption('originTop');
this.stamps.forEach( function( stamp ) {
// ignore dragged item
var item = this.getItem( stamp );
if ( item && item.isPlacing ) {
return;
}
var offset = this._getElementOffset( stamp );
var rect = new Rect({
x: isOriginLeft ? offset.left : offset.right,
y: isOriginTop ? offset.top : offset.bottom
});
this._setRectSize( stamp, rect );
// save its space in the packer
this.shiftPacker.placed( rect );
}, this );
// reset shiftTargets
var isHorizontal = this._getOption('horizontal');
var segmentName = isHorizontal ? 'rowHeight' : 'columnWidth';
var measure = isHorizontal ? 'height' : 'width';
this.shiftTargetKeys = [];
this.shiftTargets = [];
var boundsSize;
var segment = this[ segmentName ];
segment = segment && segment + this.gutter;
if ( segment ) {
var segmentSpan = Math.ceil( dropItem.rect[ measure ] / segment );
var segs = Math.floor( ( this.shiftPacker[ measure ] + this.gutter ) / segment );
boundsSize = ( segs - segmentSpan ) * segment;
// add targets on top
for ( var i=0; i < segs; i++ ) {
this._addShiftTarget( i * segment, 0, boundsSize );
}
} else {
boundsSize = ( this.shiftPacker[ measure ] + this.gutter ) - dropItem.rect[ measure ];
this._addShiftTarget( 0, 0, boundsSize );
}
// pack each item to measure where shiftTargets are
var items = this._getItemsForLayout( this.items );
var packMethod = this._getPackMethod();
items.forEach( function( item ) {
var rect = item.rect;
this._setRectSize( item.element, rect );
this.shiftPacker[ packMethod ]( rect );
// add top left corner
this._addShiftTarget( rect.x, rect.y, boundsSize );
// add bottom left / top right corner
var cornerX = isHorizontal ? rect.x + rect.width : rect.x;
var cornerY = isHorizontal ? rect.y : rect.y + rect.height;
this._addShiftTarget( cornerX, cornerY, boundsSize );
if ( segment ) {
// add targets for each column on bottom / row on right
var segSpan = Math.round( rect[ measure ] / segment );
for ( var i=1; i < segSpan; i++ ) {
var segX = isHorizontal ? cornerX : rect.x + segment * i;
var segY = isHorizontal ? rect.y + segment * i : cornerY;
this._addShiftTarget( segX, segY, boundsSize );
}
}
}, this );
};
proto._addShiftTarget = function( x, y, boundsSize ) {
var checkCoord = this._getOption('horizontal') ? y : x;
if ( checkCoord !== 0 && checkCoord > boundsSize ) {
return;
}
// create string for a key, easier to keep track of what targets
var key = x + ',' + y;
var hasKey = this.shiftTargetKeys.indexOf( key ) != -1;
if ( hasKey ) {
return;
}
this.shiftTargetKeys.push( key );
this.shiftTargets.push({ x: x, y: y });
};
// -------------------------- drop -------------------------- //
proto.shift = function( item, x, y ) {
var shiftPosition;
var minDistance = Infinity;
var position = { x: x, y: y };
this.shiftTargets.forEach( function( target ) {
var distance = getDistance( target, position );
if ( distance < minDistance ) {
shiftPosition = target;
minDistance = distance;
}
});
item.rect.x = shiftPosition.x;
item.rect.y = shiftPosition.y;
};
function getDistance( a, b ) {
var dx = b.x - a.x;
var dy = b.y - a.y;
return Math.sqrt( dx * dx + dy * dy );
}
// -------------------------- drag move -------------------------- //
var DRAG_THROTTLE_TIME = 120;
/**
* handle an item drag move event
* @param {Element} elem
* @param {Number} x - horizontal change in position
* @param {Number} y - vertical change in position
*/
proto.itemDragMove = function( elem, x, y ) {
var item = this.isEnabled && this.getItem( elem );
if ( !item ) {
return;
}
x -= this.size.paddingLeft;
y -= this.size.paddingTop;
var _this = this;
function onDrag() {
_this.shift( item, x, y );
item.positionDropPlaceholder();
_this.layout();
}
// throttle
var now = new Date();
if ( this._itemDragTime && now - this._itemDragTime < DRAG_THROTTLE_TIME ) {
clearTimeout( this.dragTimeout );
this.dragTimeout = setTimeout( onDrag, DRAG_THROTTLE_TIME );
} else {
onDrag();
this._itemDragTime = now;
}
};
// -------------------------- drag end -------------------------- //
/**
* handle an item drag end event
* @param {Element} elem
*/
proto.itemDragEnd = function( elem ) {
var item = this.isEnabled && this.getItem( elem );
if ( !item ) {
return;
}
clearTimeout( this.dragTimeout );
item.element.classList.add('is-positioning-post-drag');
var completeCount = 0;
var _this = this;
function onDragEndLayoutComplete() {
completeCount++;
if ( completeCount != 2 ) {
return;
}
// reset drag item
item.element.classList.remove('is-positioning-post-drag');
item.hideDropPlaceholder();
_this.dispatchEvent( 'dragItemPositioned', null, [ item ] );
}
item.once( 'layout', onDragEndLayoutComplete );
this.once( 'layoutComplete', onDragEndLayoutComplete );
item.moveTo( item.rect.x, item.rect.y );
this.layout();
this.dragItemCount = Math.max( 0, this.dragItemCount - 1 );
this.sortItemsByPosition();
item.disablePlacing();
this.unstamp( item.element );
};
/**
* binds Draggabilly events
* @param {Draggabilly} draggie
*/
proto.bindDraggabillyEvents = function( draggie ) {
this._bindDraggabillyEvents( draggie, 'on' );
};
proto.unbindDraggabillyEvents = function( draggie ) {
this._bindDraggabillyEvents( draggie, 'off' );
};
proto._bindDraggabillyEvents = function( draggie, method ) {
var handlers = this.handleDraggabilly;
draggie[ method ]( 'dragStart', handlers.dragStart );
draggie[ method ]( 'dragMove', handlers.dragMove );
draggie[ method ]( 'dragEnd', handlers.dragEnd );
};
/**
* binds jQuery UI Draggable events
* @param {jQuery} $elems
*/
proto.bindUIDraggableEvents = function( $elems ) {
this._bindUIDraggableEvents( $elems, 'on' );
};
proto.unbindUIDraggableEvents = function( $elems ) {
this._bindUIDraggableEvents( $elems, 'off' );
};
proto._bindUIDraggableEvents = function( $elems, method ) {
var handlers = this.handleUIDraggable;
$elems
[ method ]( 'dragstart', handlers.start )
[ method ]( 'drag', handlers.drag )
[ method ]( 'dragstop', handlers.stop );
};
// ----- destroy ----- //
var _destroy = proto.destroy;
proto.destroy = function() {
_destroy.apply( this, arguments );
// disable flag; prevent drag events from triggering. #72
this.isEnabled = false;
};
// ----- ----- //
Packery.Rect = Rect;
Packery.Packer = Packer;
return Packery;
}));
/*!
* Packery layout mode v2.0.1
* sub-classes Packery
*/
/*jshint browser: true, strict: true, undef: true, unused: true */
( function( window, factory ) {
// universal module definition
if ( typeof define == 'function' && define.amd ) {
// AMD
define( [
'isotope-layout/js/layout-mode',
'packery/js/packery'
],
factory );
} else if ( typeof module == 'object' && module.exports ) {
// CommonJS
module.exports = factory(
require('isotope-layout/js/layout-mode'),
require('packery')
);
} else {
// browser global
factory(
window.Isotope.LayoutMode,
window.Packery
);
}
}( window, function factor( LayoutMode, Packery ) {
// create an Outlayer layout class
var PackeryMode = LayoutMode.create('packery');
var proto = PackeryMode.prototype;
var keepModeMethods = {
_getElementOffset: true,
_getMeasurement: true
};
// inherit Packery prototype
for ( var method in Packery.prototype ) {
// do not inherit mode methods
if ( !keepModeMethods[ method ] ) {
proto[ method ] = Packery.prototype[ method ];
}
}
// set packer in _resetLayout
var _resetLayout = proto._resetLayout;
proto._resetLayout = function() {
this.packer = this.packer || new Packery.Packer();
this.shiftPacker = this.shiftPacker || new Packery.Packer();
_resetLayout.apply( this, arguments );
};
var _getItemLayoutPosition = proto._getItemLayoutPosition;
proto._getItemLayoutPosition = function( item ) {
// set packery rect
item.rect = item.rect || new Packery.Rect();
return _getItemLayoutPosition.call( this, item );
};
// needsResizeLayout for vertical or horizontal
var _needsResizeLayout = proto.needsResizeLayout;
proto.needsResizeLayout = function() {
if ( this._getOption('horizontal') ) {
return this.needsVerticalResizeLayout();
} else {
return _needsResizeLayout.call( this );
}
};
// point to mode options for horizontal
var _getOption = proto._getOption;
proto._getOption = function( option ) {
if ( option == 'horizontal' ) {
return this.options.isHorizontal !== undefined ?
this.options.isHorizontal : this.options.horizontal;
}
return _getOption.apply( this.isotope, arguments );
};
return PackeryMode;
}));
/*!
* cellsByRows layout mode for Isotope
* v1.1.3
* http://isotope.metafizzy.co/layout-modes/cellsbyrow.html
*/
/*jshint browser: true, devel: false, strict: true, undef: true, unused: true */
( function( window, factory ) {
// universal module definition
/* jshint strict: false */ /*globals define, module, require */
if ( typeof define === 'function' && define.amd ) {
// AMD
define( [
'isotope/js/layout-mode'
],
factory );
} else if ( typeof exports === 'object' ) {
// CommonJS
module.exports = factory(
require('isotope-layout/js/layout-mode')
);
} else {
// browser global
factory(
window.Isotope.LayoutMode
);
}
}( window, function factory( LayoutMode ) {
'use strict';
var CellsByRow = LayoutMode.create( 'cellsByRow' );
var proto = CellsByRow.prototype;
proto._resetLayout = function() {
// reset properties
this.itemIndex = 0;
// measurements
this.getColumnWidth();
this.getRowHeight();
// set cols
this.cols = Math.floor( this.isotope.size.innerWidth / this.columnWidth );
this.cols = Math.max( this.cols, 1 );
};
proto._getItemLayoutPosition = function( item ) {
item.getSize();
var col = this.itemIndex % this.cols;
var row = Math.floor( this.itemIndex / this.cols );
// center item within cell
var x = ( col + 0.5 ) * this.columnWidth - item.size.outerWidth / 2;
var y = ( row + 0.5 ) * this.rowHeight - item.size.outerHeight / 2;
this.itemIndex++;
return { x: x, y: y };
};
proto._getContainerSize = function() {
return {
height: Math.ceil( this.itemIndex / this.cols ) * this.rowHeight
};
};
return CellsByRow;
}));
/*global jQuery: true */
/*!
--------------------------------
Infinite Scroll
--------------------------------
+ https://github.com/paulirish/infinite-scroll
+ version 2.1.0
+ Copyright 2011/12 Paul Irish & Luke Shumard
+ Licensed under the MIT license
+ Documentation: http://infinite-scroll.com/
*/
// Uses AMD or browser globals to create a jQuery plugin.
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else {
// Browser globals
factory(jQuery);
}
}(function ($, undefined) {
'use strict';
$.infinitescroll = function infscr(options, callback, element) {
this.element = $(element);
// Flag the object in the event of a failed creation
if (!this._create(options, callback)) {
this.failed = true;
}
};
$.infinitescroll.defaults = {
loading: {
finished: undefined,
finishedMsg: "Congratulations, you've reached the end of the internet.",
img: 'data:image/gif;base64,R0lGODlh3AATAPQeAPDy+MnQ6LW/4N3h8MzT6rjC4sTM5r/I5NHX7N7j8c7U6tvg8OLl8uXo9Ojr9b3G5MfP6Ovu9tPZ7PT1+vX2+tbb7vf4+8/W69jd7rC73vn5/O/x+K243ai02////wAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQECgD/ACwAAAAA3AATAAAF/6AnjmRpnmiqrmzrvnAsz3Rt33iu73zv/8CgcEj0BAScpHLJbDqf0Kh0Sq1ar9isdioItAKGw+MAKYMFhbF63CW438f0mg1R2O8EuXj/aOPtaHx7fn96goR4hmuId4qDdX95c4+RBIGCB4yAjpmQhZN0YGYGXitdZBIVGAsLoq4BBKQDswm1CQRkcG6ytrYKubq8vbfAcMK9v7q7EMO1ycrHvsW6zcTKsczNz8HZw9vG3cjTsMIYqQkCLBwHCgsMDQ4RDAYIqfYSFxDxEfz88/X38Onr16+Bp4ADCco7eC8hQYMAEe57yNCew4IVBU7EGNDiRn8Z831cGLHhSIgdFf9chIeBg7oA7gjaWUWTVQAGE3LqBDCTlc9WOHfm7PkTqNCh54rePDqB6M+lR536hCpUqs2gVZM+xbrTqtGoWqdy1emValeXKzggYBBB5y1acFNZmEvXAoN2cGfJrTv3bl69Ffj2xZt3L1+/fw3XRVw4sGDGcR0fJhxZsF3KtBTThZxZ8mLMgC3fRatCbYMNFCzwLEqLgE4NsDWs/tvqdezZf13Hvk2A9Szdu2X3pg18N+68xXn7rh1c+PLksI/Dhe6cuO3ow3NfV92bdArTqC2Ebd3A8vjf5QWfH6Bg7Nz17c2fj69+fnq+8N2Lty+fuP78/eV2X13neIcCeBRwxorbZrA1ANoCDGrgoG8RTshahQ9iSKEEzUmYIYfNWViUhheCGJyIP5E4oom7WWjgCeBFAJNv1DVV01MAdJhhjdkplWNzO/5oXI846njjVEIqR2OS2B1pE5PVscajkxhMycqLJghQSwT40PgfAl4GqNSXYdZXJn5gSkmmmmJu1aZYb14V51do+pTOCmA40AqVCIhG5IJ9PvYnhIFOxmdqhpaI6GeHCtpooisuutmg+Eg62KOMKuqoTaXgicQWoIYq6qiklmoqFV0UoeqqrLbq6quwxirrrLTWauutJ4QAACH5BAUKABwALAcABADOAAsAAAX/IPd0D2dyRCoUp/k8gpHOKtseR9yiSmGbuBykler9XLAhkbDavXTL5k2oqFqNOxzUZPU5YYZd1XsD72rZpBjbeh52mSNnMSC8lwblKZGwi+0QfIJ8CncnCoCDgoVnBHmKfByGJimPkIwtiAeBkH6ZHJaKmCeVnKKTHIihg5KNq4uoqmEtcRUtEREMBggtEr4QDrjCuRC8h7/BwxENeicSF8DKy82pyNLMOxzWygzFmdvD2L3P0dze4+Xh1Arkyepi7dfFvvTtLQkZBC0T/FX3CRgCMOBHsJ+EHYQY7OinAGECgQsB+Lu3AOK+CewcWjwxQeJBihtNGHSoQOE+iQ3//4XkwBBhRZMcUS6YSXOAwIL8PGqEaSJCiYt9SNoCmnJPAgUVLChdaoFBURN8MAzl2PQphwQLfDFd6lTowglHve6rKpbjhK7/pG5VinZP1qkiz1rl4+tr2LRwWU64cFEihwEtZgbgR1UiHaMVvxpOSwBA37kzGz9e8G+B5MIEKLutOGEsAH2ATQwYfTmuX8aETWdGPZmiZcccNSzeTCA1Sw0bdiitC7LBWgu8jQr8HRzqgpK6gX88QbrB14z/kF+ELpwB8eVQj/JkqdylAudji/+ts3039vEEfK8Vz2dlvxZKG0CmbkKDBvllRd6fCzDvBLKBDSCeffhRJEFebFk1k/Mv9jVIoIJZSeBggwUaNeB+Qk34IE0cXlihcfRxkOAJFFhwGmKlmWDiakZhUJtnLBpnWWcnKaAZcxI0piFGGLBm1mc90kajSCveeBVWKeYEoU2wqeaQi0PetoE+rr14EpVC7oAbAUHqhYExbn2XHHsVqbcVew9tx8+XJKk5AZsqqdlddGpqAKdbAYBn1pcczmSTdWvdmZ17c1b3FZ99vnTdCRFM8OEcAhLwm1NdXnWcBBSMRWmfkWZqVlsmLIiAp/o1gGV2vpS4lalGYsUOqXrddcKCmK61aZ8SjEpUpVFVoCpTj4r661Km7kBHjrDyc1RAIQAAIfkEBQoAGwAsBwAEAM4ACwAABf/gtmUCd4goQQgFKj6PYKi0yrrbc8i4ohQt12EHcal+MNSQiCP8gigdz7iCioaCIvUmZLp8QBzW0EN2vSlCuDtFKaq4RyHzQLEKZNdiQDhRDVooCwkbfm59EAmKi4SGIm+AjIsKjhsqB4mSjT2IOIOUnICeCaB/mZKFNTSRmqVpmJqklSqskq6PfYYCDwYHDC4REQwGCBLGxxIQDsHMwhAIX8bKzcENgSLGF9PU1j3Sy9zX2NrgzQziChLk1BHWxcjf7N046tvN82715czn9Pryz6Ilc4ACj4EBOCZM8KEnAYYADBRKnACAYUMFv1wotIhCEcaJCisqwJFgAUSQGyX/kCSVUUTIdKMwJlyo0oXHlhskwrTJciZHEXsgaqS4s6PJiCAr1uzYU8kBBSgnWFqpoMJMUjGtDmUwkmfVmVypakWhEKvXsS4nhLW5wNjVroJIoc05wSzTr0PtiigpYe4EC2vj4iWrFu5euWIMRBhacaVJhYQBEFjA9jHjyQ0xEABwGceGAZYjY0YBOrRLCxUp29QM+bRkx5s7ZyYgVbTqwwti2ybJ+vLtDYpycyZbYOlptxdx0kV+V7lC5iJAyyRrwYKxAdiz82ng0/jnAdMJFz0cPi104Ec1Vj9/M6F173vKL/feXv156dw11tlqeMMnv4V5Ap53GmjQQH97nFfg+IFiucfgRX5Z8KAgbUlQ4IULIlghhhdOSB6AgX0IVn8eReghen3NRIBsRgnH4l4LuEidZBjwRpt6NM5WGwoW0KSjCwX6yJSMab2GwwAPDXfaBCtWpluRTQqC5JM5oUZAjUNS+VeOLWpJEQ7VYQANW0INJSZVDFSnZphjSikfmzE5N4EEbQI1QJmnWXCmHulRp2edwDXF43txukenJwvI9xyg9Q26Z3MzGUcBYFEChZh6DVTq34AU8Iflh51Sd+CnKFYQ6mmZkhqfBKfSxZWqA9DZanWjxmhrWwi0qtCrt/43K6WqVjjpmhIqgEGvculaGKklKstAACEAACH5BAUKABwALAcABADOAAsAAAX/ICdyQmaMYyAUqPgIBiHPxNpy79kqRXH8wAPsRmDdXpAWgWdEIYm2llCHqjVHU+jjJkwqBTecwItShMXkEfNWSh8e1NGAcLgpDGlRgk7EJ/6Ae3VKfoF/fDuFhohVeDeCfXkcCQqDVQcQhn+VNDOYmpSWaoqBlUSfmowjEA+iEAEGDRGztAwGCDcXEA60tXEiCrq8vREMEBLIyRLCxMWSHMzExnbRvQ2Sy7vN0zvVtNfU2tLY3rPgLdnDvca4VQS/Cpk3ABwSLQkYAQwT/P309vcI7OvXr94jBQMJ/nskkGA/BQBRLNDncAIAiDcG6LsxAWOLiQzmeURBKWSLCQbv/1F0eDGinJUKR47YY1IEgQASKk7Yc7ACRwZm7mHweRJoz59BJUogisKCUaFMR0x4SlJBVBFTk8pZivTR0K73rN5wqlXEAq5Fy3IYgHbEzQ0nLy4QSoCjXLoom96VOJEeCosK5n4kkFfqXjl94wa+l1gvAcGICbewAOAxY8l/Ky/QhAGz4cUkGxu2HNozhwMGBnCUqUdBg9UuW9eUynqSwLHIBujePef1ZGQZXcM+OFuEBeBhi3OYgLyqcuaxbT9vLkf4SeqyWxSQpKGB2gQpm1KdWbu72rPRzR9Ne2Nu9Kzr/1Jqj0yD/fvqP4aXOt5sW/5qsXXVcv1Nsp8IBUAmgswGF3llGgeU1YVXXKTN1FlhWFXW3gIE+DVChApysACHHo7Q4A35lLichh+ROBmLKAzgYmYEYDAhCgxKGOOMn4WR4kkDaoBBOxJtdNKQxFmg5JIWIBnQc07GaORfUY4AEkdV6jHlCEISSZ5yTXpp1pbGZbkWmcuZmQCaE6iJ0FhjMaDjTMsgZaNEHFRAQVp3bqXnZED1qYcECOz5V6BhSWCoVJQIKuKQi2KFKEkEFAqoAo7uYSmO3jk61wUUMKmknJ4SGimBmAa0qVQBhAAAIfkEBQoAGwAsBwAEAM4ACwAABf/gJm5FmRlEqhJC+bywgK5pO4rHI0D3pii22+Mg6/0Ej96weCMAk7cDkXf7lZTTnrMl7eaYoy10JN0ZFdco0XAuvKI6qkgVFJXYNwjkIBcNBgR8TQoGfRsJCRuCYYQQiI+ICosiCoGOkIiKfSl8mJkHZ4U9kZMbKaI3pKGXmJKrngmug4WwkhA0lrCBWgYFCCMQFwoQDRHGxwwGCBLMzRLEx8iGzMMO0cYNeCMKzBDW19lnF9DXDIY/48Xg093f0Q3s1dcR8OLe8+Y91OTv5wrj7o7B+7VNQqABIoRVCMBggsOHE36kSoCBIcSH3EbFangxogJYFi8CkJhqQciLJEf/LDDJEeJIBT0GsOwYUYJGBS0fjpQAMidGmyVP6sx4Y6VQhzs9VUwkwqaCCh0tmKoFtSMDmBOf9phg4SrVrROuasRQAaxXpVUhdsU6IsECZlvX3kwLUWzRt0BHOLTbNlbZG3vZinArge5Dvn7wbqtQkSYAAgtKmnSsYKVKo2AfW048uaPmG386i4Q8EQMBAIAnfB7xBxBqvapJ9zX9WgRS2YMpnvYMGdPK3aMjt/3dUcNI4blpj7iwkMFWDXDvSmgAlijrt9RTR78+PS6z1uAJZIe93Q8g5zcsWCi/4Y+C8bah5zUv3vv89uft30QP23punGCx5954oBBwnwYaNCDY/wYrsYeggnM9B2Fpf8GG2CEUVWhbWAtGouEGDy7Y4IEJVrbSiXghqGKIo7z1IVcXIkKWWR361QOLWWnIhwERpLaaCCee5iMBGJQmJGyPFTnbkfHVZGRtIGrg5HALEJAZbu39BuUEUmq1JJQIPtZilY5hGeSWsSk52G9XqsmgljdIcABytq13HyIM6RcUA+r1qZ4EBF3WHWB29tBgAzRhEGhig8KmqKFv8SeCeo+mgsF7YFXa1qWSbkDpom/mqR1PmHCqJ3fwNRVXjC7S6CZhFVCQ2lWvZiirhQq42SACt25IK2hv8TprriUV1usGgeka7LFcNmCldMLi6qZMgFLgpw16Cipb7bC1knXsBiEAACH5BAUKABsALAcABADOAAsAAAX/4FZsJPkUmUGsLCEUTywXglFuSg7fW1xAvNWLF6sFFcPb42C8EZCj24EJdCp2yoegWsolS0Uu6fmamg8n8YYcLU2bXSiRaXMGvqV6/KAeJAh8VgZqCX+BexCFioWAYgqNi4qAR4ORhRuHY408jAeUhAmYYiuVlpiflqGZa5CWkzc5fKmbbhIpsAoQDRG8vQwQCBLCwxK6vb5qwhfGxxENahvCEA7NzskSy7vNzzzK09W/PNHF1NvX2dXcN8K55cfh69Luveol3vO8zwi4Yhj+AQwmCBw4IYclDAAJDlQggVOChAoLKkgFkSCAHDwWLKhIEOONARsDKryogFPIiAUb/95gJNIiw4wnI778GFPhzBKFOAq8qLJEhQpiNArjMcHCmlTCUDIouTKBhApELSxFWiGiVKY4E2CAekPgUphDu0742nRrVLJZnyrFSqKQ2ohoSYAMW6IoDpNJ4bLdILTnAj8KUF7UeENjAKuDyxIgOuGiOI0EBBMgLNew5AUrDTMGsFixwBIaNCQuAXJB57qNJ2OWm2Aj4skwCQCIyNkhhtMkdsIuodE0AN4LJDRgfLPtn5YDLdBlraAByuUbBgxQwICxMOnYpVOPej074OFdlfc0TqC62OIbcppHjV4o+LrieWhfT8JC/I/T6W8oCl29vQ0XjLdBaA3s1RcPBO7lFvpX8BVoG4O5jTXRQRDuJ6FDTzEWF1/BCZhgbyAKE9qICYLloQYOFtahVRsWYlZ4KQJHlwHS/IYaZ6sZd9tmu5HQm2xi1UaTbzxYwJk/wBF5g5EEYOBZeEfGZmNdFyFZmZIR4jikbLThlh5kUUVJGmRT7sekkziRWUIACABk3T4qCsedgO4xhgGcY7q5pHJ4klBBTQRJ0CeHcoYHHUh6wgfdn9uJdSdMiebGJ0zUPTcoS286FCkrZxnYoYYKWLkBowhQoBeaOlZAgVhLidrXqg2GiqpQpZ4apwSwRtjqrB3muoF9BboaXKmshlqWqsWiGt2wphJkQbAU5hoCACH5BAUKABsALAcABADOAAsAAAX/oGFw2WZuT5oZROsSQnGaKjRvilI893MItlNOJ5v5gDcFrHhKIWcEYu/xFEqNv6B1N62aclysF7fsZYe5aOx2yL5aAUGSaT1oTYMBwQ5VGCAJgYIJCnx1gIOBhXdwiIl7d0p2iYGQUAQBjoOFSQR/lIQHnZ+Ue6OagqYzSqSJi5eTpTxGcjcSChANEbu8DBAIEsHBChe5vL13G7fFuscRDcnKuM3H0La3EA7Oz8kKEsXazr7Cw9/Gztar5uHHvte47MjktznZ2w0G1+D3BgirAqJmJMAQgMGEgwgn5Ei0gKDBhBMALGRYEOJBb5QcWlQo4cbAihZz3GgIMqFEBSM1/4ZEOWPAgpIIJXYU+PIhRG8ja1qU6VHlzZknJNQ6UanCjQkWCIGSUGEjAwVLjc44+DTqUQtPPS5gejUrTa5TJ3g9sWCr1BNUWZI161StiQUDmLYdGfesibQ3XMq1OPYthrwuA2yU2LBs2cBHIypYQPPlYAKFD5cVvNPtW8eVGbdcQADATsiNO4cFAPkvHpedPzc8kUcPgNGgZ5RNDZG05reoE9s2vSEP79MEGiQGy1qP8LA4ZcdtsJE48ONoLTBtTV0B9LsTnPceoIDBDQvS7W7vfjVY3q3eZ4A339J4eaAmKqU/sV58HvJh2RcnIBsDUw0ABqhBA5aV5V9XUFGiHfVeAiWwoFgJJrIXRH1tEMiDFV4oHoAEGlaWhgIGSGBO2nFomYY3mKjVglidaNYJGJDkWW2xxTfbjCbVaOGNqoX2GloR8ZeTaECS9pthRGJH2g0b3Agbk6hNANtteHD2GJUucfajCQBy5OOTQ25ZgUPvaVVQmbKh9510/qQpwXx3SQdfk8tZJOd5b6JJFplT3ZnmmX3qd5l1eg5q00HrtUkUn0AKaiGjClSAgKLYZcgWXwocGRcCFGCKwSB6ceqphwmYRUFYT/1WKlOdUpipmxW0mlCqHjYkAaeoZlqrqZ4qd+upQKaapn/AmgAegZ8KUtYtFAQQAgAh+QQFCgAbACwHAAQAzgALAAAF/+C2PUcmiCiZGUTrEkKBis8jQEquKwU5HyXIbEPgyX7BYa5wTNmEMwWsSXsqFbEh8DYs9mrgGjdK6GkPY5GOeU6ryz7UFopSQEzygOGhJBjoIgMDBAcBM0V/CYqLCQqFOwobiYyKjn2TlI6GKC2YjJZknouaZAcQlJUHl6eooJwKooobqoewrJSEmyKdt59NhRKFMxLEEA4RyMkMEAjDEhfGycqAG8TQx9IRDRDE3d3R2ctD1RLg0ttKEnbY5wZD3+zJ6M7X2RHi9Oby7u/r9g38UFjTh2xZJBEBMDAboogAgwkQI07IMUORwocSJwCgWDFBAIwZOaJIsOBjRogKJP8wTODw5ESVHVtm3AhzpEeQElOuNDlTZ0ycEUWKWFASqEahGwYUPbnxoAgEdlYSqDBkgoUNClAlIHbSAoOsqCRQnQHxq1axVb06FWFxLIqyaze0Tft1JVqyE+pWXMD1pF6bYl3+HTqAWNW8cRUFzmih0ZAAB2oGKukSAAGGRHWJgLiR6AylBLpuHKKUMlMCngMpDSAa9QIUggZVVvDaJobLeC3XZpvgNgCmtPcuwP3WgmXSq4do0DC6o2/guzcseECtUoO0hmcsGKDgOt7ssBd07wqesAIGZC1YIBa7PQHvb1+SFo+++HrJSQfB33xfav3i5eX3Hnb4CTJgegEq8tH/YQEOcIJzbm2G2EoYRLgBXFpVmFYDcREV4HIcnmUhiGBRouEMJGJGzHIspqgdXxK0yCKHRNXoIX4uorCdTyjkyNtdPWrA4Up82EbAbzMRxxZRR54WXVLDIRmRcag5d2R6ugl3ZXzNhTecchpMhIGVAKAYpgJjjsSklBEd99maZoo535ZvdamjBEpusJyctg3h4X8XqodBMx0tiNeg/oGJaKGABpogS40KSqiaEgBqlQWLUtqoVQnytekEjzo0hHqhRorppOZt2p923M2AAV+oBtpAnnPNoB6HaU6mAAIU+IXmi3j2mtFXuUoHKwXpzVrsjcgGOauKEjQrwq157hitGq2NoWmjh7z6Wmxb0m5w66+2VRAuXN/yFUAIACH5BAUKABsALAcABADOAAsAAAX/4CZuRiaM45MZqBgIRbs9AqTcuFLE7VHLOh7KB5ERdjJaEaU4ClO/lgKWjKKcMiJQ8KgumcieVdQMD8cbBeuAkkC6LYLhOxoQ2PF5Ys9PKPBMen17f0CCg4VSh32JV4t8jSNqEIOEgJKPlkYBlJWRInKdiJdkmQlvKAsLBxdABA4RsbIMBggtEhcQsLKxDBC2TAS6vLENdJLDxMZAubu8vjIbzcQRtMzJz79S08oQEt/guNiyy7fcvMbh4OezdAvGrakLAQwyABsELQkY9BP+//ckyPDD4J9BfAMh1GsBoImMeQUN+lMgUJ9CiRMa5msxoB9Gh/o8GmxYMZXIgxtR/yQ46S/gQAURR0pDwYDfywoyLPip5AdnCwsMFPBU4BPFhKBDi444quCmDKZOfwZ9KEGpCKgcN1jdALSpPqIYsabS+nSqvqplvYqQYAeDPgwKwjaMtiDl0oaqUAyo+3TuWwUAMPpVCfee0cEjVBGQq2ABx7oTWmQk4FglZMGN9fGVDMCuiH2AOVOu/PmyxM630gwM0CCn6q8LjVJ8GXvpa5Uwn95OTC/nNxkda1/dLSK475IjCD6dHbK1ZOa4hXP9DXs5chJ00UpVm5xo2qRpoxptwF2E4/IbJpB/SDz9+q9b1aNfQH08+p4a8uvX8B53fLP+ycAfemjsRUBgp1H20K+BghHgVgt1GXZXZpZ5lt4ECjxYR4ScUWiShEtZqBiIInRGWnERNnjiBglw+JyGnxUmGowsyiiZg189lNtPGACjV2+S9UjbU0JWF6SPvEk3QZEqsZYTk3UAaRSUnznJI5LmESCdBVSyaOWUWLK4I5gDUYVeV1T9l+FZClCAUVA09uSmRHBCKAECFEhW51ht6rnmWBXkaR+NjuHpJ40D3DmnQXt2F+ihZxlqVKOfQRACACH5BAUKABwALAcABADOAAsAAAX/ICdyUCkUo/g8mUG8MCGkKgspeC6j6XEIEBpBUeCNfECaglBcOVfJFK7YQwZHQ6JRZBUqTrSuVEuD3nI45pYjFuWKvjjSkCoRaBUMWxkwBGgJCXspQ36Bh4EEB0oKhoiBgyNLjo8Ki4QElIiWfJqHnISNEI+Ql5J9o6SgkqKkgqYihamPkW6oNBgSfiMMDQkGCBLCwxIQDhHIyQwQCGMKxsnKVyPCF9DREQ3MxMPX0cu4wt7J2uHWx9jlKd3o39MiuefYEcvNkuLt5O8c1ePI2tyELXGQwoGDAQf+iEC2xByDCRAjTlAgIUWCBRgCPJQ4AQBFXAs0coT40WLIjRxL/47AcHLkxIomRXL0CHPERZkpa4q4iVKiyp0tR/7kwHMkTUBBJR5dOCEBAVcKKtCAyOHpowXCpk7goABqBZdcvWploACpBKkpIJI1q5OD2rIWE0R1uTZu1LFwbWL9OlKuWb4c6+o9i3dEgw0RCGDUG9KlRw56gDY2qmCByZBaASi+TACA0TucAaTteCcy0ZuOK3N2vJlx58+LRQyY3Xm0ZsgjZg+oPQLi7dUcNXi0LOJw1pgNtB7XG6CBy+U75SYfPTSQAgZTNUDnQHt67wnbZyvwLgKiMN3oCZB3C76tdewpLFgIP2C88rbi4Y+QT3+8S5USMICZXWj1pkEDeUU3lOYGB3alSoEiMIjgX4WlgNF2EibIwQIXauWXSRg2SAOHIU5IIIMoZkhhWiJaiFVbKo6AQEgQXrTAazO1JhkBrBG3Y2Y6EsUhaGn95hprSN0oWpFE7rhkeaQBchGOEWnwEmc0uKWZj0LeuNV3W4Y2lZHFlQCSRjTIl8uZ+kG5HU/3sRlnTG2ytyadytnD3HrmuRcSn+0h1dycexIK1KCjYaCnjCCVqOFFJTZ5GkUUjESWaUIKU2lgCmAKKQIUjHapXRKE+t2og1VgankNYnohqKJ2CmKplso6GKz7WYCgqxeuyoF8u9IQAgA7',
msg: null,
msgText: 'Loading the next set of posts...',
selector: null,
speed: 'fast',
start: undefined
},
state: {
isDuringAjax: false,
isInvalidPage: false,
isDestroyed: false,
isDone: false, // For when it goes all the way through the archive.
isPaused: false,
isBeyondMaxPage: false,
currPage: 1
},
debug: false,
behavior: undefined,
binder: $(window), // used to cache the selector
nextSelector: 'div.navigation a:first',
navSelector: 'div.navigation',
contentSelector: null, // rename to pageFragment
extraScrollPx: 150,
itemSelector: 'div.post',
animate: false,
pathParse: undefined,
dataType: 'html',
appendCallback: true,
bufferPx: 40,
errorCallback: function () { },
infid: 0, //Instance ID
pixelsFromNavToBottom: undefined,
path: undefined, // Either parts of a URL as an array (e.g. ["/page/", "/"] or a function that takes in the page number and returns a URL
prefill: false, // When the document is smaller than the window, load data until the document is larger or links are exhausted
maxPage: undefined // to manually control maximum page (when maxPage is undefined, maximum page limitation is not work)
};
$.infinitescroll.prototype = {
/*
----------------------------
Private methods
----------------------------
*/
// Bind or unbind from scroll
_binding: function infscr_binding(binding) {
var instance = this,
opts = instance.options;
opts.v = '2.0b2.120520';
// if behavior is defined and this function is extended, call that instead of default
if (!!opts.behavior && this['_binding_'+opts.behavior] !== undefined) {
this['_binding_'+opts.behavior].call(this);
return;
}
if (binding !== 'bind' && binding !== 'unbind') {
this._debug('Binding value ' + binding + ' not valid');
return false;
}
if (binding === 'unbind') {
(this.options.binder).unbind('smartscroll.infscr.' + instance.options.infid);
} else {
(this.options.binder)[binding]('smartscroll.infscr.' + instance.options.infid, function () {
instance.scroll();
});
}
this._debug('Binding', binding);
},
// Fundamental aspects of the plugin are initialized
_create: function infscr_create(options, callback) {
// Add custom options to defaults
var opts = $.extend(true, {}, $.infinitescroll.defaults, options);
this.options = opts;
var $window = $(window);
var instance = this;
// Validate selectors
if (!instance._validate(options)) {
return false;
}
// Validate page fragment path
var path = $(opts.nextSelector).attr('href');
if (!path) {
this._debug('Navigation selector not found');
return false;
}
// Set the path to be a relative URL from root.
opts.path = opts.path || this._determinepath(path);
// contentSelector is 'page fragment' option for .load() / .ajax() calls
opts.contentSelector = opts.contentSelector || this.element;
// loading.selector - if we want to place the load message in a specific selector, defaulted to the contentSelector
opts.loading.selector = opts.loading.selector || opts.contentSelector;
// Define loading.msg
opts.loading.msg = opts.loading.msg || $('
' + opts.loading.msgText + '
');
// Preload loading.img
(new Image()).src = opts.loading.img;
// distance from nav links to bottom
// computed as: height of the document + top offset of container - top offset of nav link
if(opts.pixelsFromNavToBottom === undefined) {
opts.pixelsFromNavToBottom = $(document).height() - $(opts.navSelector).offset().top;
this._debug('pixelsFromNavToBottom: ' + opts.pixelsFromNavToBottom);
}
var self = this;
// determine loading.start actions
opts.loading.start = opts.loading.start || function() {
$(opts.navSelector).hide();
opts.loading.msg
.appendTo(opts.loading.selector)
.show(opts.loading.speed, $.proxy(function() {
this.beginAjax(opts);
}, self));
};
// determine loading.finished actions
opts.loading.finished = opts.loading.finished || function() {
if (!opts.state.isBeyondMaxPage)
opts.loading.msg.fadeOut(opts.loading.speed);
};
// callback loading
opts.callback = function(instance, data, url) {
if (!!opts.behavior && instance['_callback_'+opts.behavior] !== undefined) {
instance['_callback_'+opts.behavior].call($(opts.contentSelector)[0], data, url);
}
if (callback) {
callback.call($(opts.contentSelector)[0], data, opts, url);
}
if (opts.prefill) {
$window.bind('resize.infinite-scroll', instance._prefill);
}
};
if (options.debug) {
// Tell IE9 to use its built-in console
if (Function.prototype.bind && (typeof console === 'object' || typeof console === 'function') && typeof console.log === 'object') {
['log','info','warn','error','assert','dir','clear','profile','profileEnd']
.forEach(function (method) {
console[method] = this.call(console[method], console);
}, Function.prototype.bind);
}
}
this._setup();
// Setups the prefill method for use
if (opts.prefill) {
this._prefill();
}
// Return true to indicate successful creation
return true;
},
_prefill: function infscr_prefill() {
var instance = this;
var $window = $(window);
function needsPrefill() {
return ( $(instance.options.contentSelector).height() <= $window.height() );
}
this._prefill = function() {
if (needsPrefill()) {
instance.scroll();
}
$window.bind('resize.infinite-scroll', function() {
if (needsPrefill()) {
$window.unbind('resize.infinite-scroll');
instance.scroll();
}
});
};
// Call self after setting up the new function
this._prefill();
},
// Console log wrapper
_debug: function infscr_debug() {
if (true !== this.options.debug) {
return;
}
if (typeof console !== 'undefined' && typeof console.log === 'function') {
// Modern browsers
// Single argument, which is a string
if ((Array.prototype.slice.call(arguments)).length === 1 && typeof Array.prototype.slice.call(arguments)[0] === 'string') {
console.log( (Array.prototype.slice.call(arguments)).toString() );
} else {
console.log( Array.prototype.slice.call(arguments) );
}
} else if (!Function.prototype.bind && typeof console !== 'undefined' && typeof console.log === 'object') {
// IE8
Function.prototype.call.call(console.log, console, Array.prototype.slice.call(arguments));
}
},
// find the number to increment in the path.
_determinepath: function infscr_determinepath(path) {
var opts = this.options;
// if behavior is defined and this function is extended, call that instead of default
if (!!opts.behavior && this['_determinepath_'+opts.behavior] !== undefined) {
return this['_determinepath_'+opts.behavior].call(this,path);
}
if (!!opts.pathParse) {
this._debug('pathParse manual');
return opts.pathParse(path, this.options.state.currPage+1);
} else if (path.match(/^(.*?)\b2\b(.*?$)/)) {
path = path.match(/^(.*?)\b2\b(.*?$)/).slice(1);
// if there is any 2 in the url at all.
} else if (path.match(/^(.*?)2(.*?$)/)) {
// page= is used in django:
// http://www.infinite-scroll.com/changelog/comment-page-1/#comment-127
if (path.match(/^(.*?page=)2(\/.*|$)/)) {
path = path.match(/^(.*?page=)2(\/.*|$)/).slice(1);
return path;
}
path = path.match(/^(.*?)2(.*?$)/).slice(1);
} else {
// page= is used in drupal too but second page is page=1 not page=2:
// thx Jerod Fritz, vladikoff
if (path.match(/^(.*?page=)1(\/.*|$)/)) {
path = path.match(/^(.*?page=)1(\/.*|$)/).slice(1);
return path;
} else {
this._debug("Sorry, we couldn't parse your Next (Previous Posts) URL. Verify your the css selector points to the correct A tag. If you still get this error: yell, scream, and kindly ask for help at infinite-scroll.com.");
// Get rid of isInvalidPage to allow permalink to state
opts.state.isInvalidPage = true; //prevent it from running on this page.
}
}
this._debug('determinePath', path);
return path;
},
// Custom error
_error: function infscr_error(xhr) {
var opts = this.options;
// if behavior is defined and this function is extended, call that instead of default
if (!!opts.behavior && this['_error_'+opts.behavior] !== undefined) {
this['_error_'+opts.behavior].call(this,xhr);
return;
}
if (xhr !== 'destroy' && xhr !== 'end') {
xhr = 'unknown';
}
this._debug('Error', xhr);
if (xhr === 'end' || opts.state.isBeyondMaxPage) {
this._showdonemsg();
}
opts.state.isDone = true;
opts.state.currPage = 1; // if you need to go back to this instance
opts.state.isPaused = false;
opts.state.isBeyondMaxPage = false;
this._binding('unbind');
},
// Load Callback
_loadcallback: function infscr_loadcallback(box, data, url) {
var opts = this.options,
callback = this.options.callback, // GLOBAL OBJECT FOR CALLBACK
result = (opts.state.isDone) ? 'done' : (!opts.appendCallback) ? 'no-append' : 'append',
frag;
// if behavior is defined and this function is extended, call that instead of default
if (!!opts.behavior && this['_loadcallback_'+opts.behavior] !== undefined) {
this['_loadcallback_'+opts.behavior].call(this,box,data);
return;
}
switch (result) {
case 'done':
this._showdonemsg();
return false;
case 'no-append':
if (opts.dataType === 'html') {
data = '