first commit

This commit is contained in:
2024-07-15 11:28:08 +02:00
commit f52d538ea5
21891 changed files with 6161164 additions and 0 deletions

View File

@@ -0,0 +1,993 @@
/**
* http://animejs.com
* JavaScript animation engine
* @version v2.2.0
* @author Julian Garnier
* @copyright ©2017 Julian Garnier
* Released under the MIT license
**/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], factory);
} else if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
root.anime = factory();
}
}(this, () => {
// Defaults
const defaultInstanceSettings = {
update: undefined,
begin: undefined,
run: undefined,
complete: undefined,
loop: 1,
direction: 'normal',
autoplay: true,
offset: 0
}
const defaultTweenSettings = {
duration: 1000,
delay: 0,
easing: 'easeOutElastic',
elasticity: 500,
round: 0
}
const validTransforms = ['translateX', 'translateY', 'translateZ', 'rotate', 'rotateX', 'rotateY', 'rotateZ', 'scale', 'scaleX', 'scaleY', 'scaleZ', 'skewX', 'skewY', 'perspective'];
let transformString;
// Utils
function stringContains(str, text) {
return str.indexOf(text) > -1;
}
const is = {
arr: a => Array.isArray(a),
obj: a => stringContains(Object.prototype.toString.call(a), 'Object'),
pth: a => is.obj(a) && a.hasOwnProperty('totalLength'),
svg: a => a instanceof SVGElement,
dom: a => a.nodeType || is.svg(a),
str: a => typeof a === 'string',
fnc: a => typeof a === 'function',
und: a => typeof a === 'undefined',
hex: a => /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(a),
rgb: a => /^rgb/.test(a),
hsl: a => /^hsl/.test(a),
col: a => (is.hex(a) || is.rgb(a) || is.hsl(a))
}
// BezierEasing https://github.com/gre/bezier-easing
const bezier = (() => {
const kSplineTableSize = 11;
const kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);
function A (aA1, aA2) { return 1.0 - 3.0 * aA2 + 3.0 * aA1 };
function B (aA1, aA2) { return 3.0 * aA2 - 6.0 * aA1 };
function C (aA1) { return 3.0 * aA1 };
function calcBezier (aT, aA1, aA2) { return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT };
function getSlope (aT, aA1, aA2) { return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1) };
function binarySubdivide (aX, aA, aB, mX1, mX2) {
let currentX, currentT, i = 0;
do {
currentT = aA + (aB - aA) / 2.0;
currentX = calcBezier(currentT, mX1, mX2) - aX;
if (currentX > 0.0) { aB = currentT } else { aA = currentT };
} while (Math.abs(currentX) > 0.0000001 && ++i < 10);
return currentT;
}
function newtonRaphsonIterate (aX, aGuessT, mX1, mX2) {
for (let i = 0; i < 4; ++i) {
const currentSlope = getSlope(aGuessT, mX1, mX2);
if (currentSlope === 0.0) return aGuessT;
const currentX = calcBezier(aGuessT, mX1, mX2) - aX;
aGuessT -= currentX / currentSlope;
}
return aGuessT;
}
function bezier(mX1, mY1, mX2, mY2) {
if (!(0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1)) return;
let sampleValues = new Float32Array(kSplineTableSize);
if (mX1 !== mY1 || mX2 !== mY2) {
for (let i = 0; i < kSplineTableSize; ++i) {
sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
}
}
function getTForX(aX) {
let intervalStart = 0.0;
let currentSample = 1;
const lastSample = kSplineTableSize - 1;
for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {
intervalStart += kSampleStepSize;
}
--currentSample;
const dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
const guessForT = intervalStart + dist * kSampleStepSize;
const initialSlope = getSlope(guessForT, mX1, mX2);
if (initialSlope >= 0.001) {
return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
} else if (initialSlope === 0.0) {
return guessForT;
} else {
return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
}
}
return x => {
if (mX1 === mY1 && mX2 === mY2) return x;
if (x === 0) return 0;
if (x === 1) return 1;
return calcBezier(getTForX(x), mY1, mY2);
}
}
return bezier;
})();
const easings = (() => {
const names = ['Quad', 'Cubic', 'Quart', 'Quint', 'Sine', 'Expo', 'Circ', 'Back', 'Elastic'];
// Elastic easing adapted from jQueryUI http://api.jqueryui.com/easings/
function elastic(t, p) {
return t === 0 || t === 1 ? t :
-Math.pow(2, 10 * (t - 1)) * Math.sin((((t - 1) - (p / (Math.PI * 2.0) * Math.asin(1))) * (Math.PI * 2)) / p );
}
// Approximated Penner equations http://matthewlein.com/ceaser/
const equations = {
In: [
[0.550, 0.085, 0.680, 0.530], /* InQuad */
[0.550, 0.055, 0.675, 0.190], /* InCubic */
[0.895, 0.030, 0.685, 0.220], /* InQuart */
[0.755, 0.050, 0.855, 0.060], /* InQuint */
[0.470, 0.000, 0.745, 0.715], /* InSine */
[0.950, 0.050, 0.795, 0.035], /* InExpo */
[0.600, 0.040, 0.980, 0.335], /* InCirc */
[0.600, -0.280, 0.735, 0.045], /* InBack */
elastic /* InElastic */
], Out: [
[0.250, 0.460, 0.450, 0.940], /* OutQuad */
[0.215, 0.610, 0.355, 1.000], /* OutCubic */
[0.165, 0.840, 0.440, 1.000], /* OutQuart */
[0.230, 1.000, 0.320, 1.000], /* OutQuint */
[0.390, 0.575, 0.565, 1.000], /* OutSine */
[0.190, 1.000, 0.220, 1.000], /* OutExpo */
[0.075, 0.820, 0.165, 1.000], /* OutCirc */
[0.175, 0.885, 0.320, 1.275], /* OutBack */
(t, f) => 1 - elastic(1 - t, f) /* OutElastic */
], InOut: [
[0.455, 0.030, 0.515, 0.955], /* InOutQuad */
[0.645, 0.045, 0.355, 1.000], /* InOutCubic */
[0.770, 0.000, 0.175, 1.000], /* InOutQuart */
[0.860, 0.000, 0.070, 1.000], /* InOutQuint */
[0.445, 0.050, 0.550, 0.950], /* InOutSine */
[1.000, 0.000, 0.000, 1.000], /* InOutExpo */
[0.785, 0.135, 0.150, 0.860], /* InOutCirc */
[0.680, -0.550, 0.265, 1.550], /* InOutBack */
(t, f) => t < .5 ? elastic(t * 2, f) / 2 : 1 - elastic(t * -2 + 2, f) / 2 /* InOutElastic */
]
}
let functions = {
linear: bezier(0.250, 0.250, 0.750, 0.750)
}
for (let type in equations) {
equations[type].forEach((f, i) => {
functions['ease'+type+names[i]] = is.fnc(f) ? f : bezier.apply(this, f);
});
}
return functions;
})();
// Strings
function stringToHyphens(str) {
return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
}
function selectString(str) {
if (is.col(str)) return;
try {
let nodes = document.querySelectorAll(str);
return nodes;
} catch(e) {
return;
}
}
// Arrays
function filterArray(arr, callback) {
const len = arr.length;
const thisArg = arguments.length >= 2 ? arguments[1] : void 0;
let result = [];
for (let i = 0; i < len; i++) {
if (i in arr) {
const val = arr[i];
if (callback.call(thisArg, val, i, arr)) {
result.push(val);
}
}
}
return result;
}
function flattenArray(arr) {
return arr.reduce((a, b) => a.concat(is.arr(b) ? flattenArray(b) : b), []);
}
function toArray(o) {
if (is.arr(o)) return o;
if (is.str(o)) o = selectString(o) || o;
if (o instanceof NodeList || o instanceof HTMLCollection) return [].slice.call(o);
return [o];
}
function arrayContains(arr, val) {
return arr.some(a => a === val);
}
// Objects
function cloneObject(o) {
let clone = {};
for (let p in o) clone[p] = o[p];
return clone;
}
function replaceObjectProps(o1, o2) {
let o = cloneObject(o1);
for (let p in o1) o[p] = o2.hasOwnProperty(p) ? o2[p] : o1[p];
return o;
}
function mergeObjects(o1, o2) {
let o = cloneObject(o1);
for (let p in o2) o[p] = is.und(o1[p]) ? o2[p] : o1[p];
return o;
}
// Colors
function rgbToRgba(rgbValue) {
const rgb = /rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(rgbValue);
return rgb ? `rgba(${rgb[1]},1)` : rgbValue;
}
function hexToRgba(hexValue) {
const rgx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
const hex = hexValue.replace(rgx, (m, r, g, b) => r + r + g + g + b + b );
const rgb = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
const r = parseInt(rgb[1], 16);
const g = parseInt(rgb[2], 16);
const b = parseInt(rgb[3], 16);
return `rgba(${r},${g},${b},1)`;
}
function hslToRgba(hslValue) {
const hsl = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(hslValue) || /hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(hslValue);
const h = parseInt(hsl[1]) / 360;
const s = parseInt(hsl[2]) / 100;
const l = parseInt(hsl[3]) / 100;
const a = hsl[4] || 1;
function hue2rgb(p, q, t) {
if (t < 0) t += 1;
if (t > 1) t -= 1;
if (t < 1/6) return p + (q - p) * 6 * t;
if (t < 1/2) return q;
if (t < 2/3) return p + (q - p) * (2/3 - t) * 6;
return p;
}
let r, g, b;
if (s == 0) {
r = g = b = l;
} else {
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
const p = 2 * l - q;
r = hue2rgb(p, q, h + 1/3);
g = hue2rgb(p, q, h);
b = hue2rgb(p, q, h - 1/3);
}
return `rgba(${r * 255},${g * 255},${b * 255},${a})`;
}
function colorToRgb(val) {
if (is.rgb(val)) return rgbToRgba(val);
if (is.hex(val)) return hexToRgba(val);
if (is.hsl(val)) return hslToRgba(val);
}
// Units
function getUnit(val) {
const split = /([\+\-]?[0-9#\.]+)(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(val);
if (split) return split[2];
}
function getTransformUnit(propName) {
if (stringContains(propName, 'translate') || propName === 'perspective') return 'px';
if (stringContains(propName, 'rotate') || stringContains(propName, 'skew')) return 'deg';
}
// Values
function minMaxValue(val, min, max) {
return Math.min(Math.max(val, min), max);
}
function getFunctionValue(val, animatable) {
if (!is.fnc(val)) return val;
return val(animatable.target, animatable.id, animatable.total);
}
function getCSSValue(el, prop) {
if (prop in el.style) {
return getComputedStyle(el).getPropertyValue(stringToHyphens(prop)) || '0';
}
}
function getAnimationType(el, prop) {
if (is.dom(el) && arrayContains(validTransforms, prop)) return 'transform';
if (is.dom(el) && (el.getAttribute(prop) || (is.svg(el) && el[prop]))) return 'attribute';
if (is.dom(el) && (prop !== 'transform' && getCSSValue(el, prop))) return 'css';
if (el[prop] != null) return 'object';
}
function getTransformValue(el, propName) {
const defaultUnit = getTransformUnit(propName);
const defaultVal = stringContains(propName, 'scale') ? 1 : 0 + defaultUnit;
const str = el.style.transform;
if (!str) return defaultVal;
let match = [];
let props = [];
let values = [];
const rgx = /(\w+)\((.+?)\)/g;
while (match = rgx.exec(str)) {
props.push(match[1]);
values.push(match[2]);
}
const value = filterArray(values, (val, i) => props[i] === propName);
return value.length ? value[0] : defaultVal;
}
function getOriginalTargetValue(target, propName) {
switch (getAnimationType(target, propName)) {
case 'transform': return getTransformValue(target, propName);
case 'css': return getCSSValue(target, propName);
case 'attribute': return target.getAttribute(propName);
}
return target[propName] || 0;
}
function getRelativeValue(to, from) {
const operator = /^(\*=|\+=|-=)/.exec(to);
if (!operator) return to;
const u = getUnit(to) || 0;
const x = parseFloat(from);
const y = parseFloat(to.replace(operator[0], ''));
switch (operator[0][0]) {
case '+': return x + y + u;
case '-': return x - y + u;
case '*': return x * y + u;
}
}
function validateValue(val, unit) {
if (is.col(val)) return colorToRgb(val);
const originalUnit = getUnit(val);
const unitLess = originalUnit ? val.substr(0, val.length - originalUnit.length) : val;
return unit && !/\s/g.test(val) ? unitLess + unit : unitLess;
}
// getTotalLength() equivalent for circle, rect, polyline, polygon and line shapes.
// adapted from https://gist.github.com/SebLambla/3e0550c496c236709744
function getDistance(p1, p2) {
return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2));
}
function getCircleLength(el) {
return 2 * Math.PI * el.getAttribute('r');
}
function getRectLength(el) {
return (el.getAttribute('width') * 2) + (el.getAttribute('height') * 2);
}
function getLineLength(el) {
return getDistance(
{x: el.getAttribute('x1'), y: el.getAttribute('y1')},
{x: el.getAttribute('x2'), y: el.getAttribute('y2')}
);
}
function getPolylineLength(el) {
const points = el.points;
let totalLength = 0;
let previousPos;
for (let i = 0 ; i < points.numberOfItems; i++) {
const currentPos = points.getItem(i);
if (i > 0) totalLength += getDistance(previousPos, currentPos);
previousPos = currentPos;
}
return totalLength;
}
function getPolygonLength(el) {
const points = el.points;
return getPolylineLength(el) + getDistance(points.getItem(points.numberOfItems - 1), points.getItem(0));
}
// Path animation
function getTotalLength(el) {
if (el.getTotalLength) return el.getTotalLength();
switch(el.tagName.toLowerCase()) {
case 'circle': return getCircleLength(el);
case 'rect': return getRectLength(el);
case 'line': return getLineLength(el);
case 'polyline': return getPolylineLength(el);
case 'polygon': return getPolygonLength(el);
}
}
function setDashoffset(el) {
const pathLength = getTotalLength(el);
el.setAttribute('stroke-dasharray', pathLength);
return pathLength;
}
// Motion path
function getPath(path, percent) {
const el = is.str(path) ? selectString(path)[0] : path;
const p = percent || 100;
return function(prop) {
return {
el: el,
property: prop,
totalLength: getTotalLength(el) * (p / 100)
}
}
}
function getPathProgress(path, progress) {
function point(offset = 0) {
const l = progress + offset >= 1 ? progress + offset : 0;
return path.el.getPointAtLength(l);
}
const p = point();
const p0 = point(-1);
const p1 = point(+1);
switch (path.property) {
case 'x': return p.x;
case 'y': return p.y;
case 'angle': return Math.atan2(p1.y - p0.y, p1.x - p0.x) * 180 / Math.PI;
}
}
// Decompose value
function decomposeValue(val, unit) {
const rgx = /-?\d*\.?\d+/g;
const value = validateValue((is.pth(val) ? val.totalLength : val), unit) + '';
return {
original: value,
numbers: value.match(rgx) ? value.match(rgx).map(Number) : [0],
strings: (is.str(val) || unit) ? value.split(rgx) : []
}
}
// Animatables
function parseTargets(targets) {
const targetsArray = targets ? (flattenArray(is.arr(targets) ? targets.map(toArray) : toArray(targets))) : [];
return filterArray(targetsArray, (item, pos, self) => self.indexOf(item) === pos);
}
function getAnimatables(targets) {
const parsed = parseTargets(targets);
return parsed.map((t, i) => {
return {target: t, id: i, total: parsed.length};
});
}
// Properties
function normalizePropertyTweens(prop, tweenSettings) {
let settings = cloneObject(tweenSettings);
if (is.arr(prop)) {
const l = prop.length;
const isFromTo = (l === 2 && !is.obj(prop[0]));
if (!isFromTo) {
// Duration divided by the number of tweens
if (!is.fnc(tweenSettings.duration)) settings.duration = tweenSettings.duration / l;
} else {
// Transform [from, to] values shorthand to a valid tween value
prop = {value: prop};
}
}
return toArray(prop).map((v, i) => {
// Default delay value should be applied only on the first tween
const delay = !i ? tweenSettings.delay : 0;
// Use path object as a tween value
let obj = is.obj(v) && !is.pth(v) ? v : {value: v};
// Set default delay value
if (is.und(obj.delay)) obj.delay = delay;
return obj;
}).map(k => mergeObjects(k, settings));
}
function getProperties(instanceSettings, tweenSettings, params) {
let properties = [];
const settings = mergeObjects(instanceSettings, tweenSettings);
for (let p in params) {
if (!settings.hasOwnProperty(p) && p !== 'targets') {
properties.push({
name: p,
offset: settings['offset'],
tweens: normalizePropertyTweens(params[p], tweenSettings)
});
}
}
return properties;
}
// Tweens
function normalizeTweenValues(tween, animatable) {
let t = {};
for (let p in tween) {
let value = getFunctionValue(tween[p], animatable);
if (is.arr(value)) {
value = value.map(v => getFunctionValue(v, animatable));
if (value.length === 1) value = value[0];
}
t[p] = value;
}
t.duration = parseFloat(t.duration);
t.delay = parseFloat(t.delay);
return t;
}
function normalizeEasing(val) {
return is.arr(val) ? bezier.apply(this, val) : easings[val];
}
function normalizeTweens(prop, animatable) {
let previousTween;
return prop.tweens.map(t => {
let tween = normalizeTweenValues(t, animatable);
const tweenValue = tween.value;
const originalValue = getOriginalTargetValue(animatable.target, prop.name);
const previousValue = previousTween ? previousTween.to.original : originalValue;
const from = is.arr(tweenValue) ? tweenValue[0] : previousValue;
const to = getRelativeValue(is.arr(tweenValue) ? tweenValue[1] : tweenValue, from);
const unit = getUnit(to) || getUnit(from) || getUnit(originalValue);
tween.from = decomposeValue(from, unit);
tween.to = decomposeValue(to, unit);
tween.start = previousTween ? previousTween.end : prop.offset;
tween.end = tween.start + tween.delay + tween.duration;
tween.easing = normalizeEasing(tween.easing);
tween.elasticity = (1000 - minMaxValue(tween.elasticity, 1, 999)) / 1000;
tween.isPath = is.pth(tweenValue);
tween.isColor = is.col(tween.from.original);
if (tween.isColor) tween.round = 1;
previousTween = tween;
return tween;
});
}
// Tween progress
const setTweenProgress = {
css: (t, p, v) => t.style[p] = v,
attribute: (t, p, v) => t.setAttribute(p, v),
object: (t, p, v) => t[p] = v,
transform: (t, p, v, transforms, id) => {
if (!transforms[id]) transforms[id] = [];
transforms[id].push(`${p}(${v})`);
}
}
// Animations
function createAnimation(animatable, prop) {
const animType = getAnimationType(animatable.target, prop.name);
if (animType) {
const tweens = normalizeTweens(prop, animatable);
return {
type: animType,
property: prop.name,
animatable: animatable,
tweens: tweens,
duration: tweens[tweens.length - 1].end,
delay: tweens[0].delay
}
}
}
function getAnimations(animatables, properties) {
return filterArray(flattenArray(animatables.map(animatable => {
return properties.map(prop => {
return createAnimation(animatable, prop);
});
})), a => !is.und(a));
}
// Create Instance
function getInstanceTimings(type, animations, instanceSettings, tweenSettings) {
const isDelay = (type === 'delay');
if (animations.length) {
return (isDelay ? Math.min : Math.max).apply(Math, animations.map(anim => anim[type]));
} else {
return isDelay ? tweenSettings.delay : instanceSettings.offset + tweenSettings.delay + tweenSettings.duration;
}
}
function createNewInstance(params) {
const instanceSettings = replaceObjectProps(defaultInstanceSettings, params);
const tweenSettings = replaceObjectProps(defaultTweenSettings, params);
const animatables = getAnimatables(params.targets);
const properties = getProperties(instanceSettings, tweenSettings, params);
const animations = getAnimations(animatables, properties);
return mergeObjects(instanceSettings, {
children: [],
animatables: animatables,
animations: animations,
duration: getInstanceTimings('duration', animations, instanceSettings, tweenSettings),
delay: getInstanceTimings('delay', animations, instanceSettings, tweenSettings)
});
}
// Core
let activeInstances = [];
let raf = 0;
const engine = (() => {
function play() { raf = requestAnimationFrame(step); };
function step(t) {
const activeLength = activeInstances.length;
if (activeLength) {
let i = 0;
while (i < activeLength) {
if (activeInstances[i]) activeInstances[i].tick(t);
i++;
}
play();
} else {
cancelAnimationFrame(raf);
raf = 0;
}
}
return play;
})();
// Public Instance
function anime(params = {}) {
let now, startTime, lastTime = 0;
let resolve = null;
function makePromise() {
return window.Promise && new Promise(_resolve => resolve = _resolve);
}
let promise = makePromise();
let instance = createNewInstance(params);
function toggleInstanceDirection() {
instance.reversed = !instance.reversed;
}
function adjustTime(time) {
return instance.reversed ? instance.duration - time : time;
}
function syncInstanceChildren(time) {
const children = instance.children;
const childrenLength = children.length;
if (time >= instance.currentTime) {
for (let i = 0; i < childrenLength; i++) children[i].seek(time);
} else {
for (let i = childrenLength; i--;) children[i].seek(time);
}
}
function setAnimationsProgress(insTime) {
let i = 0;
let transforms = {};
const animations = instance.animations;
const animationsLength = animations.length;
while (i < animationsLength) {
const anim = animations[i];
const animatable = anim.animatable;
const tweens = anim.tweens;
const tweenLength = tweens.length - 1;
let tween = tweens[tweenLength];
// Only check for keyframes if there is more than one tween
if (tweenLength) tween = filterArray(tweens, t => (insTime < t.end))[0] || tween;
const elapsed = minMaxValue(insTime - tween.start - tween.delay, 0, tween.duration) / tween.duration;
const eased = isNaN(elapsed) ? 1 : tween.easing(elapsed, tween.elasticity);
const strings = tween.to.strings;
const round = tween.round;
let numbers = [];
let progress;
const toNumbersLength = tween.to.numbers.length;
for (let n = 0; n < toNumbersLength; n++) {
let value;
const toNumber = tween.to.numbers[n];
const fromNumber = tween.from.numbers[n];
if (!tween.isPath) {
value = fromNumber + (eased * (toNumber - fromNumber));
} else {
value = getPathProgress(tween.value, eased * toNumber);
}
if (round) {
if (!(tween.isColor && n > 2)) {
value = Math.round(value * round) / round;
}
}
numbers.push(value);
}
// Manual Array.reduce for better performances
const stringsLength = strings.length;
if (!stringsLength) {
progress = numbers[0];
} else {
progress = strings[0];
for (let s = 0; s < stringsLength; s++) {
const a = strings[s];
const b = strings[s + 1];
const n = numbers[s];
if (!isNaN(n)) {
if (!b) {
progress += n + ' ';
} else {
progress += n + b;
}
}
}
}
setTweenProgress[anim.type](animatable.target, anim.property, progress, transforms, animatable.id);
anim.currentValue = progress;
i++;
}
const transformsLength = Object.keys(transforms).length;
if (transformsLength) {
for (let id = 0; id < transformsLength; id++) {
if (!transformString) {
const t = 'transform';
transformString = (getCSSValue(document.body, t) ? t : `-webkit-${t}`);
}
instance.animatables[id].target.style[transformString] = transforms[id].join(' ');
}
}
instance.currentTime = insTime;
instance.progress = (insTime / instance.duration) * 100;
}
function setCallback(cb) {
if (instance[cb]) instance[cb](instance);
}
function countIteration() {
if (instance.remaining && instance.remaining !== true) {
instance.remaining--;
}
}
function setInstanceProgress(engineTime) {
const insDuration = instance.duration;
const insOffset = instance.offset;
const insStart = insOffset + instance.delay;
const insCurrentTime = instance.currentTime;
const insReversed = instance.reversed;
const insTime = adjustTime(engineTime);
if (instance.children.length) syncInstanceChildren(insTime);
if (insTime >= insStart || !insDuration) {
if (!instance.began) {
instance.began = true;
setCallback('begin');
}
setCallback('run');
}
if (insTime > insOffset && insTime < insDuration) {
setAnimationsProgress(insTime);
} else {
if (insTime <= insOffset && insCurrentTime !== 0) {
setAnimationsProgress(0);
if (insReversed) countIteration();
}
if ((insTime >= insDuration && insCurrentTime !== insDuration) || !insDuration) {
setAnimationsProgress(insDuration);
if (!insReversed) countIteration();
}
}
setCallback('update');
if (engineTime >= insDuration) {
if (instance.remaining) {
startTime = now;
if (instance.direction === 'alternate') toggleInstanceDirection();
} else {
instance.pause();
if (!instance.completed) {
instance.completed = true;
setCallback('complete');
if ('Promise' in window) {
resolve();
promise = makePromise();
}
}
}
lastTime = 0;
}
}
instance.reset = function() {
const direction = instance.direction;
const loops = instance.loop;
instance.currentTime = 0;
instance.progress = 0;
instance.paused = true;
instance.began = false;
instance.completed = false;
instance.reversed = direction === 'reverse';
instance.remaining = direction === 'alternate' && loops === 1 ? 2 : loops;
setAnimationsProgress(0);
for (let i = instance.children.length; i--; ){
instance.children[i].reset();
}
}
instance.tick = function(t) {
now = t;
if (!startTime) startTime = now;
const engineTime = (lastTime + now - startTime) * anime.speed;
setInstanceProgress(engineTime);
}
instance.seek = function(time) {
setInstanceProgress(adjustTime(time));
}
instance.pause = function() {
const i = activeInstances.indexOf(instance);
if (i > -1) activeInstances.splice(i, 1);
instance.paused = true;
}
instance.play = function() {
if (!instance.paused) return;
instance.paused = false;
startTime = 0;
lastTime = adjustTime(instance.currentTime);
activeInstances.push(instance);
if (!raf) engine();
}
instance.reverse = function() {
toggleInstanceDirection();
startTime = 0;
lastTime = adjustTime(instance.currentTime);
}
instance.restart = function() {
instance.pause();
instance.reset();
instance.play();
}
instance.finished = promise;
instance.reset();
if (instance.autoplay) instance.play();
return instance;
}
// Remove targets from animation
function removeTargets(targets) {
const targetsArray = parseTargets(targets);
for (let i = activeInstances.length; i--;) {
const instance = activeInstances[i];
const animations = instance.animations;
for (let a = animations.length; a--;) {
if (arrayContains(targetsArray, animations[a].animatable.target)) {
animations.splice(a, 1);
if (!animations.length) instance.pause();
}
}
}
}
// Timeline
function timeline(params) {
let tl = anime(params);
tl.pause();
tl.duration = 0;
tl.add = function(instancesParams) {
tl.children.forEach(i => { i.began = true; i.completed = true; });
toArray(instancesParams).forEach(instanceParams => {
let insParams = mergeObjects(instanceParams, replaceObjectProps(defaultTweenSettings, params || {}));
insParams.targets = insParams.targets || params.targets;
const tlDuration = tl.duration;
const insOffset = insParams.offset;
insParams.autoplay = false;
insParams.direction = tl.direction;
insParams.offset = is.und(insOffset) ? tlDuration : getRelativeValue(insOffset, tlDuration);
tl.began = true;
tl.completed = true;
tl.seek(insParams.offset);
const ins = anime(insParams);
ins.began = true;
ins.completed = true;
if (ins.duration > tlDuration) tl.duration = ins.duration;
tl.children.push(ins);
});
tl.seek(0);
tl.reset();
if (tl.autoplay) tl.restart();
return tl;
}
return tl;
}
anime.version = '2.2.0';
anime.speed = 1;
anime.running = activeInstances;
anime.remove = removeTargets;
anime.getValue = getOriginalTargetValue;
anime.path = getPath;
anime.setDashoffset = setDashoffset;
anime.bezier = bezier;
anime.easings = easings;
anime.timeline = timeline;
anime.random = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
return anime;
}));

View File

@@ -0,0 +1,33 @@
/*
2017 Julian Garnier
Released under the MIT license
*/
var $jscomp={scope:{}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(e,r,p){if(p.get||p.set)throw new TypeError("ES3 does not support getters and setters.");e!=Array.prototype&&e!=Object.prototype&&(e[r]=p.value)};$jscomp.getGlobal=function(e){return"undefined"!=typeof window&&window===e?e:"undefined"!=typeof global&&null!=global?global:e};$jscomp.global=$jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX="jscomp_symbol_";
$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.symbolCounter_=0;$jscomp.Symbol=function(e){return $jscomp.SYMBOL_PREFIX+(e||"")+$jscomp.symbolCounter_++};
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var e=$jscomp.global.Symbol.iterator;e||(e=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[e]&&$jscomp.defineProperty(Array.prototype,e,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(e){var r=0;return $jscomp.iteratorPrototype(function(){return r<e.length?{done:!1,value:e[r++]}:{done:!0}})};
$jscomp.iteratorPrototype=function(e){$jscomp.initSymbolIterator();e={next:e};e[$jscomp.global.Symbol.iterator]=function(){return this};return e};$jscomp.array=$jscomp.array||{};$jscomp.iteratorFromArray=function(e,r){$jscomp.initSymbolIterator();e instanceof String&&(e+="");var p=0,m={next:function(){if(p<e.length){var u=p++;return{value:r(u,e[u]),done:!1}}m.next=function(){return{done:!0,value:void 0}};return m.next()}};m[Symbol.iterator]=function(){return m};return m};
$jscomp.polyfill=function(e,r,p,m){if(r){p=$jscomp.global;e=e.split(".");for(m=0;m<e.length-1;m++){var u=e[m];u in p||(p[u]={});p=p[u]}e=e[e.length-1];m=p[e];r=r(m);r!=m&&null!=r&&$jscomp.defineProperty(p,e,{configurable:!0,writable:!0,value:r})}};$jscomp.polyfill("Array.prototype.keys",function(e){return e?e:function(){return $jscomp.iteratorFromArray(this,function(e){return e})}},"es6-impl","es3");var $jscomp$this=this;
(function(e,r){"function"===typeof define&&define.amd?define([],r):"object"===typeof module&&module.exports?module.exports=r():e.anime=r()})(this,function(){function e(a){if(!h.col(a))try{return document.querySelectorAll(a)}catch(c){}}function r(a,c){for(var d=a.length,b=2<=arguments.length?arguments[1]:void 0,f=[],n=0;n<d;n++)if(n in a){var k=a[n];c.call(b,k,n,a)&&f.push(k)}return f}function p(a){return a.reduce(function(a,d){return a.concat(h.arr(d)?p(d):d)},[])}function m(a){if(h.arr(a))return a;
h.str(a)&&(a=e(a)||a);return a instanceof NodeList||a instanceof HTMLCollection?[].slice.call(a):[a]}function u(a,c){return a.some(function(a){return a===c})}function C(a){var c={},d;for(d in a)c[d]=a[d];return c}function D(a,c){var d=C(a),b;for(b in a)d[b]=c.hasOwnProperty(b)?c[b]:a[b];return d}function z(a,c){var d=C(a),b;for(b in c)d[b]=h.und(a[b])?c[b]:a[b];return d}function T(a){a=a.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(a,c,d,k){return c+c+d+d+k+k});var c=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);
a=parseInt(c[1],16);var d=parseInt(c[2],16),c=parseInt(c[3],16);return"rgba("+a+","+d+","+c+",1)"}function U(a){function c(a,c,b){0>b&&(b+=1);1<b&&--b;return b<1/6?a+6*(c-a)*b:.5>b?c:b<2/3?a+(c-a)*(2/3-b)*6:a}var d=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(a)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(a);a=parseInt(d[1])/360;var b=parseInt(d[2])/100,f=parseInt(d[3])/100,d=d[4]||1;if(0==b)f=b=a=f;else{var n=.5>f?f*(1+b):f+b-f*b,k=2*f-n,f=c(k,n,a+1/3),b=c(k,n,a);a=c(k,n,a-1/3)}return"rgba("+
255*f+","+255*b+","+255*a+","+d+")"}function y(a){if(a=/([\+\-]?[0-9#\.]+)(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(a))return a[2]}function V(a){if(-1<a.indexOf("translate")||"perspective"===a)return"px";if(-1<a.indexOf("rotate")||-1<a.indexOf("skew"))return"deg"}function I(a,c){return h.fnc(a)?a(c.target,c.id,c.total):a}function E(a,c){if(c in a.style)return getComputedStyle(a).getPropertyValue(c.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase())||"0"}function J(a,c){if(h.dom(a)&&
u(W,c))return"transform";if(h.dom(a)&&(a.getAttribute(c)||h.svg(a)&&a[c]))return"attribute";if(h.dom(a)&&"transform"!==c&&E(a,c))return"css";if(null!=a[c])return"object"}function X(a,c){var d=V(c),d=-1<c.indexOf("scale")?1:0+d;a=a.style.transform;if(!a)return d;for(var b=[],f=[],n=[],k=/(\w+)\((.+?)\)/g;b=k.exec(a);)f.push(b[1]),n.push(b[2]);a=r(n,function(a,b){return f[b]===c});return a.length?a[0]:d}function K(a,c){switch(J(a,c)){case "transform":return X(a,c);case "css":return E(a,c);case "attribute":return a.getAttribute(c)}return a[c]||
0}function L(a,c){var d=/^(\*=|\+=|-=)/.exec(a);if(!d)return a;var b=y(a)||0;c=parseFloat(c);a=parseFloat(a.replace(d[0],""));switch(d[0][0]){case "+":return c+a+b;case "-":return c-a+b;case "*":return c*a+b}}function F(a,c){return Math.sqrt(Math.pow(c.x-a.x,2)+Math.pow(c.y-a.y,2))}function M(a){a=a.points;for(var c=0,d,b=0;b<a.numberOfItems;b++){var f=a.getItem(b);0<b&&(c+=F(d,f));d=f}return c}function N(a){if(a.getTotalLength)return a.getTotalLength();switch(a.tagName.toLowerCase()){case "circle":return 2*
Math.PI*a.getAttribute("r");case "rect":return 2*a.getAttribute("width")+2*a.getAttribute("height");case "line":return F({x:a.getAttribute("x1"),y:a.getAttribute("y1")},{x:a.getAttribute("x2"),y:a.getAttribute("y2")});case "polyline":return M(a);case "polygon":var c=a.points;return M(a)+F(c.getItem(c.numberOfItems-1),c.getItem(0))}}function Y(a,c){function d(b){b=void 0===b?0:b;return a.el.getPointAtLength(1<=c+b?c+b:0)}var b=d(),f=d(-1),n=d(1);switch(a.property){case "x":return b.x;case "y":return b.y;
case "angle":return 180*Math.atan2(n.y-f.y,n.x-f.x)/Math.PI}}function O(a,c){var d=/-?\d*\.?\d+/g,b;b=h.pth(a)?a.totalLength:a;if(h.col(b))if(h.rgb(b)){var f=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(b);b=f?"rgba("+f[1]+",1)":b}else b=h.hex(b)?T(b):h.hsl(b)?U(b):void 0;else f=(f=y(b))?b.substr(0,b.length-f.length):b,b=c&&!/\s/g.test(b)?f+c:f;b+="";return{original:b,numbers:b.match(d)?b.match(d).map(Number):[0],strings:h.str(a)||c?b.split(d):[]}}function P(a){a=a?p(h.arr(a)?a.map(m):m(a)):[];return r(a,
function(a,d,b){return b.indexOf(a)===d})}function Z(a){var c=P(a);return c.map(function(a,b){return{target:a,id:b,total:c.length}})}function aa(a,c){var d=C(c);if(h.arr(a)){var b=a.length;2!==b||h.obj(a[0])?h.fnc(c.duration)||(d.duration=c.duration/b):a={value:a}}return m(a).map(function(a,b){b=b?0:c.delay;a=h.obj(a)&&!h.pth(a)?a:{value:a};h.und(a.delay)&&(a.delay=b);return a}).map(function(a){return z(a,d)})}function ba(a,c){var d={},b;for(b in a){var f=I(a[b],c);h.arr(f)&&(f=f.map(function(a){return I(a,
c)}),1===f.length&&(f=f[0]));d[b]=f}d.duration=parseFloat(d.duration);d.delay=parseFloat(d.delay);return d}function ca(a){return h.arr(a)?A.apply(this,a):Q[a]}function da(a,c){var d;return a.tweens.map(function(b){b=ba(b,c);var f=b.value,e=K(c.target,a.name),k=d?d.to.original:e,k=h.arr(f)?f[0]:k,w=L(h.arr(f)?f[1]:f,k),e=y(w)||y(k)||y(e);b.from=O(k,e);b.to=O(w,e);b.start=d?d.end:a.offset;b.end=b.start+b.delay+b.duration;b.easing=ca(b.easing);b.elasticity=(1E3-Math.min(Math.max(b.elasticity,1),999))/
1E3;b.isPath=h.pth(f);b.isColor=h.col(b.from.original);b.isColor&&(b.round=1);return d=b})}function ea(a,c){return r(p(a.map(function(a){return c.map(function(b){var c=J(a.target,b.name);if(c){var d=da(b,a);b={type:c,property:b.name,animatable:a,tweens:d,duration:d[d.length-1].end,delay:d[0].delay}}else b=void 0;return b})})),function(a){return!h.und(a)})}function R(a,c,d,b){var f="delay"===a;return c.length?(f?Math.min:Math.max).apply(Math,c.map(function(b){return b[a]})):f?b.delay:d.offset+b.delay+
b.duration}function fa(a){var c=D(ga,a),d=D(S,a),b=Z(a.targets),f=[],e=z(c,d),k;for(k in a)e.hasOwnProperty(k)||"targets"===k||f.push({name:k,offset:e.offset,tweens:aa(a[k],d)});a=ea(b,f);return z(c,{children:[],animatables:b,animations:a,duration:R("duration",a,c,d),delay:R("delay",a,c,d)})}function q(a){function c(){return window.Promise&&new Promise(function(a){return p=a})}function d(a){return g.reversed?g.duration-a:a}function b(a){for(var b=0,c={},d=g.animations,f=d.length;b<f;){var e=d[b],
k=e.animatable,h=e.tweens,n=h.length-1,l=h[n];n&&(l=r(h,function(b){return a<b.end})[0]||l);for(var h=Math.min(Math.max(a-l.start-l.delay,0),l.duration)/l.duration,w=isNaN(h)?1:l.easing(h,l.elasticity),h=l.to.strings,p=l.round,n=[],m=void 0,m=l.to.numbers.length,t=0;t<m;t++){var x=void 0,x=l.to.numbers[t],q=l.from.numbers[t],x=l.isPath?Y(l.value,w*x):q+w*(x-q);p&&(l.isColor&&2<t||(x=Math.round(x*p)/p));n.push(x)}if(l=h.length)for(m=h[0],w=0;w<l;w++)p=h[w+1],t=n[w],isNaN(t)||(m=p?m+(t+p):m+(t+" "));
else m=n[0];ha[e.type](k.target,e.property,m,c,k.id);e.currentValue=m;b++}if(b=Object.keys(c).length)for(d=0;d<b;d++)H||(H=E(document.body,"transform")?"transform":"-webkit-transform"),g.animatables[d].target.style[H]=c[d].join(" ");g.currentTime=a;g.progress=a/g.duration*100}function f(a){if(g[a])g[a](g)}function e(){g.remaining&&!0!==g.remaining&&g.remaining--}function k(a){var k=g.duration,n=g.offset,w=n+g.delay,r=g.currentTime,x=g.reversed,q=d(a);if(g.children.length){var u=g.children,v=u.length;
if(q>=g.currentTime)for(var G=0;G<v;G++)u[G].seek(q);else for(;v--;)u[v].seek(q)}if(q>=w||!k)g.began||(g.began=!0,f("begin")),f("run");if(q>n&&q<k)b(q);else if(q<=n&&0!==r&&(b(0),x&&e()),q>=k&&r!==k||!k)b(k),x||e();f("update");a>=k&&(g.remaining?(t=h,"alternate"===g.direction&&(g.reversed=!g.reversed)):(g.pause(),g.completed||(g.completed=!0,f("complete"),"Promise"in window&&(p(),m=c()))),l=0)}a=void 0===a?{}:a;var h,t,l=0,p=null,m=c(),g=fa(a);g.reset=function(){var a=g.direction,c=g.loop;g.currentTime=
0;g.progress=0;g.paused=!0;g.began=!1;g.completed=!1;g.reversed="reverse"===a;g.remaining="alternate"===a&&1===c?2:c;b(0);for(a=g.children.length;a--;)g.children[a].reset()};g.tick=function(a){h=a;t||(t=h);k((l+h-t)*q.speed)};g.seek=function(a){k(d(a))};g.pause=function(){var a=v.indexOf(g);-1<a&&v.splice(a,1);g.paused=!0};g.play=function(){g.paused&&(g.paused=!1,t=0,l=d(g.currentTime),v.push(g),B||ia())};g.reverse=function(){g.reversed=!g.reversed;t=0;l=d(g.currentTime)};g.restart=function(){g.pause();
g.reset();g.play()};g.finished=m;g.reset();g.autoplay&&g.play();return g}var ga={update:void 0,begin:void 0,run:void 0,complete:void 0,loop:1,direction:"normal",autoplay:!0,offset:0},S={duration:1E3,delay:0,easing:"easeOutElastic",elasticity:500,round:0},W="translateX translateY translateZ rotate rotateX rotateY rotateZ scale scaleX scaleY scaleZ skewX skewY perspective".split(" "),H,h={arr:function(a){return Array.isArray(a)},obj:function(a){return-1<Object.prototype.toString.call(a).indexOf("Object")},
pth:function(a){return h.obj(a)&&a.hasOwnProperty("totalLength")},svg:function(a){return a instanceof SVGElement},dom:function(a){return a.nodeType||h.svg(a)},str:function(a){return"string"===typeof a},fnc:function(a){return"function"===typeof a},und:function(a){return"undefined"===typeof a},hex:function(a){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(a)},rgb:function(a){return/^rgb/.test(a)},hsl:function(a){return/^hsl/.test(a)},col:function(a){return h.hex(a)||h.rgb(a)||h.hsl(a)}},A=function(){function a(a,
d,b){return(((1-3*b+3*d)*a+(3*b-6*d))*a+3*d)*a}return function(c,d,b,f){if(0<=c&&1>=c&&0<=b&&1>=b){var e=new Float32Array(11);if(c!==d||b!==f)for(var k=0;11>k;++k)e[k]=a(.1*k,c,b);return function(k){if(c===d&&b===f)return k;if(0===k)return 0;if(1===k)return 1;for(var h=0,l=1;10!==l&&e[l]<=k;++l)h+=.1;--l;var l=h+(k-e[l])/(e[l+1]-e[l])*.1,n=3*(1-3*b+3*c)*l*l+2*(3*b-6*c)*l+3*c;if(.001<=n){for(h=0;4>h;++h){n=3*(1-3*b+3*c)*l*l+2*(3*b-6*c)*l+3*c;if(0===n)break;var m=a(l,c,b)-k,l=l-m/n}k=l}else if(0===
n)k=l;else{var l=h,h=h+.1,g=0;do m=l+(h-l)/2,n=a(m,c,b)-k,0<n?h=m:l=m;while(1e-7<Math.abs(n)&&10>++g);k=m}return a(k,d,f)}}}}(),Q=function(){function a(a,b){return 0===a||1===a?a:-Math.pow(2,10*(a-1))*Math.sin(2*(a-1-b/(2*Math.PI)*Math.asin(1))*Math.PI/b)}var c="Quad Cubic Quart Quint Sine Expo Circ Back Elastic".split(" "),d={In:[[.55,.085,.68,.53],[.55,.055,.675,.19],[.895,.03,.685,.22],[.755,.05,.855,.06],[.47,0,.745,.715],[.95,.05,.795,.035],[.6,.04,.98,.335],[.6,-.28,.735,.045],a],Out:[[.25,
.46,.45,.94],[.215,.61,.355,1],[.165,.84,.44,1],[.23,1,.32,1],[.39,.575,.565,1],[.19,1,.22,1],[.075,.82,.165,1],[.175,.885,.32,1.275],function(b,c){return 1-a(1-b,c)}],InOut:[[.455,.03,.515,.955],[.645,.045,.355,1],[.77,0,.175,1],[.86,0,.07,1],[.445,.05,.55,.95],[1,0,0,1],[.785,.135,.15,.86],[.68,-.55,.265,1.55],function(b,c){return.5>b?a(2*b,c)/2:1-a(-2*b+2,c)/2}]},b={linear:A(.25,.25,.75,.75)},f={},e;for(e in d)f.type=e,d[f.type].forEach(function(a){return function(d,f){b["ease"+a.type+c[f]]=h.fnc(d)?
d:A.apply($jscomp$this,d)}}(f)),f={type:f.type};return b}(),ha={css:function(a,c,d){return a.style[c]=d},attribute:function(a,c,d){return a.setAttribute(c,d)},object:function(a,c,d){return a[c]=d},transform:function(a,c,d,b,f){b[f]||(b[f]=[]);b[f].push(c+"("+d+")")}},v=[],B=0,ia=function(){function a(){B=requestAnimationFrame(c)}function c(c){var b=v.length;if(b){for(var d=0;d<b;)v[d]&&v[d].tick(c),d++;a()}else cancelAnimationFrame(B),B=0}return a}();q.version="2.2.0";q.speed=1;q.running=v;q.remove=
function(a){a=P(a);for(var c=v.length;c--;)for(var d=v[c],b=d.animations,f=b.length;f--;)u(a,b[f].animatable.target)&&(b.splice(f,1),b.length||d.pause())};q.getValue=K;q.path=function(a,c){var d=h.str(a)?e(a)[0]:a,b=c||100;return function(a){return{el:d,property:a,totalLength:N(d)*(b/100)}}};q.setDashoffset=function(a){var c=N(a);a.setAttribute("stroke-dasharray",c);return c};q.bezier=A;q.easings=Q;q.timeline=function(a){var c=q(a);c.pause();c.duration=0;c.add=function(d){c.children.forEach(function(a){a.began=
!0;a.completed=!0});m(d).forEach(function(b){var d=z(b,D(S,a||{}));d.targets=d.targets||a.targets;b=c.duration;var e=d.offset;d.autoplay=!1;d.direction=c.direction;d.offset=h.und(e)?b:L(e,b);c.began=!0;c.completed=!0;c.seek(d.offset);d=q(d);d.began=!0;d.completed=!0;d.duration>b&&(c.duration=d.duration);c.children.push(d)});c.seek(0);c.reset();c.autoplay&&c.restart();return c};return c};q.random=function(a,c){return Math.floor(Math.random()*(c-a+1))+a};return q});

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
/**
* Name: Apple Maps-esque
*/
[{"featureType":"landscape.man_made","elementType":"geometry","stylers":[{"color":"#f7f1df"}]},{"featureType":"landscape.natural","elementType":"geometry","stylers":[{"color":"#d0e3b4"}]},{"featureType":"landscape.natural.terrain","elementType":"geometry","stylers":[{"visibility":"off"}]},{"featureType":"poi","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"poi.business","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"poi.medical","elementType":"geometry","stylers":[{"color":"#fbd3da"}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#bde6ab"}]},{"featureType":"road","elementType":"geometry.stroke","stylers":[{"visibility":"off"}]},{"featureType":"road","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":"#ffe15f"}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#efd151"}]},{"featureType":"road.arterial","elementType":"geometry.fill","stylers":[{"color":"#ffffff"}]},{"featureType":"road.local","elementType":"geometry.fill","stylers":[{"color":"black"}]},{"featureType":"transit.station.airport","elementType":"geometry.fill","stylers":[{"color":"#cfb2db"}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#a2daf2"}]}]

View File

@@ -0,0 +1,4 @@
/**
* Name: Blue Essence
*/
[{"featureType":"landscape.natural","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#e0efef"}]},{"featureType":"poi","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"hue":"#1900ff"},{"color":"#c0e8e8"}]},{"featureType":"road","elementType":"geometry","stylers":[{"lightness":100},{"visibility":"simplified"}]},{"featureType":"road","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"transit.line","elementType":"geometry","stylers":[{"visibility":"on"},{"lightness":700}]},{"featureType":"water","elementType":"all","stylers":[{"color":"#7dcdcd"}]}]

View File

@@ -0,0 +1,4 @@
/**
* Name: Blue Water
*/
[{"featureType":"administrative","elementType":"labels.text.fill","stylers":[{"color":"#444444"}]},{"featureType":"landscape","elementType":"all","stylers":[{"color":"#f2f2f2"}]},{"featureType":"poi","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"road","elementType":"all","stylers":[{"saturation":-100},{"lightness":45}]},{"featureType":"road.highway","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"road.arterial","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"all","stylers":[{"color":"#46bcec"},{"visibility":"on"}]}]

View File

@@ -0,0 +1,4 @@
/**
* Name: Light Dream
*/
[{"featureType":"landscape","stylers":[{"hue":"#FFBB00"},{"saturation":43.400000000000006},{"lightness":37.599999999999994},{"gamma":1}]},{"featureType":"road.highway","stylers":[{"hue":"#FFC200"},{"saturation":-61.8},{"lightness":45.599999999999994},{"gamma":1}]},{"featureType":"road.arterial","stylers":[{"hue":"#FF0300"},{"saturation":-100},{"lightness":51.19999999999999},{"gamma":1}]},{"featureType":"road.local","stylers":[{"hue":"#FF0300"},{"saturation":-100},{"lightness":52},{"gamma":1}]},{"featureType":"water","stylers":[{"hue":"#0078FF"},{"saturation":-13.200000000000003},{"lightness":2.4000000000000057},{"gamma":1}]},{"featureType":"poi","stylers":[{"hue":"#00FF6A"},{"saturation":-1.0989010989011234},{"lightness":11.200000000000017},{"gamma":1}]}]

View File

@@ -0,0 +1,4 @@
/**
* Name: Pale Dawn
*/
[{"featureType":"administrative","elementType":"all","stylers":[{"visibility":"on"},{"lightness":33}]},{"featureType":"landscape","elementType":"all","stylers":[{"color":"#f2e5d4"}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#c5dac6"}]},{"featureType":"poi.park","elementType":"labels","stylers":[{"visibility":"on"},{"lightness":20}]},{"featureType":"road","elementType":"all","stylers":[{"lightness":20}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"color":"#c5c6c6"}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#e4d7c6"}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#fbfaf7"}]},{"featureType":"water","elementType":"all","stylers":[{"visibility":"on"},{"color":"#acbcc9"}]}]

View File

@@ -0,0 +1,4 @@
/**
* Name: Paper
*/
[{"featureType":"administrative","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"landscape","elementType":"all","stylers":[{"visibility":"simplified"},{"hue":"#0066ff"},{"saturation":74},{"lightness":100}]},{"featureType":"poi","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"road","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"road.highway","elementType":"all","stylers":[{"visibility":"off"},{"weight":0.6},{"saturation":-85},{"lightness":61}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"visibility":"on"}]},{"featureType":"road.arterial","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"road.local","elementType":"all","stylers":[{"visibility":"on"}]},{"featureType":"transit","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"water","elementType":"all","stylers":[{"visibility":"simplified"},{"color":"#5f94ff"},{"lightness":26},{"gamma":5.86}]}]

View File

@@ -0,0 +1,4 @@
/**
* Name: Shades of Grey
*/
[{"featureType":"all","elementType":"labels.text.fill","stylers":[{"saturation":36},{"color":"#000000"},{"lightness":40}]},{"featureType":"all","elementType":"labels.text.stroke","stylers":[{"visibility":"on"},{"color":"#000000"},{"lightness":16}]},{"featureType":"all","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":"#000000"},{"lightness":20}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":"#000000"},{"lightness":17},{"weight":1.2}]},{"featureType":"landscape","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":20}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":21}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":"#000000"},{"lightness":17}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#000000"},{"lightness":29},{"weight":0.2}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":18}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":16}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":19}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":17}]}]

View File

@@ -0,0 +1,4 @@
/**
* Name: Subtle Grayscale
*/
[{"featureType":"administrative","elementType":"all","stylers":[{"saturation":"-100"}]},{"featureType":"administrative.province","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"landscape","elementType":"all","stylers":[{"saturation":-100},{"lightness":65},{"visibility":"on"}]},{"featureType":"poi","elementType":"all","stylers":[{"saturation":-100},{"lightness":"50"},{"visibility":"simplified"}]},{"featureType":"road","elementType":"all","stylers":[{"saturation":"-100"}]},{"featureType":"road.highway","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"road.arterial","elementType":"all","stylers":[{"lightness":"30"}]},{"featureType":"road.local","elementType":"all","stylers":[{"lightness":"40"}]},{"featureType":"transit","elementType":"all","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"water","elementType":"geometry","stylers":[{"hue":"#ffff00"},{"lightness":-25},{"saturation":-97}]},{"featureType":"water","elementType":"labels","stylers":[{"lightness":-25},{"saturation":-100}]}]

View File

@@ -0,0 +1,4 @@
/**
* Name: Ultra Light
*/
[{"featureType":"water","elementType":"geometry","stylers":[{"color":"#e9e9e9"},{"lightness":17}]},{"featureType":"landscape","elementType":"geometry","stylers":[{"color":"#f5f5f5"},{"lightness":20}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":"#ffffff"},{"lightness":17}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#ffffff"},{"lightness":29},{"weight":0.2}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#ffffff"},{"lightness":18}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#ffffff"},{"lightness":16}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#f5f5f5"},{"lightness":21}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#dedede"},{"lightness":21}]},{"elementType":"labels.text.stroke","stylers":[{"visibility":"on"},{"color":"#ffffff"},{"lightness":16}]},{"elementType":"labels.text.fill","stylers":[{"saturation":36},{"color":"#333333"},{"lightness":40}]},{"elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#f2f2f2"},{"lightness":19}]},{"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":"#fefefe"},{"lightness":20}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":"#fefefe"},{"lightness":17},{"weight":1.2}]}]

View File

@@ -0,0 +1,4 @@
/**
* Name: WY
*/
[{"featureType":"all","elementType":"geometry.fill","stylers":[{"weight":"2.00"}]},{"featureType":"all","elementType":"geometry.stroke","stylers":[{"color":"#9c9c9c"}]},{"featureType":"all","elementType":"labels.text","stylers":[{"visibility":"on"}]},{"featureType":"landscape","elementType":"all","stylers":[{"color":"#f2f2f2"}]},{"featureType":"landscape","elementType":"geometry.fill","stylers":[{"color":"#ffffff"}]},{"featureType":"landscape.man_made","elementType":"geometry.fill","stylers":[{"color":"#ffffff"}]},{"featureType":"poi","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"road","elementType":"all","stylers":[{"saturation":-100},{"lightness":45}]},{"featureType":"road","elementType":"geometry.fill","stylers":[{"color":"#eeeeee"}]},{"featureType":"road","elementType":"labels.text.fill","stylers":[{"color":"#7b7b7b"}]},{"featureType":"road","elementType":"labels.text.stroke","stylers":[{"color":"#ffffff"}]},{"featureType":"road.highway","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"road.arterial","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"all","stylers":[{"color":"#46bcec"},{"visibility":"on"}]},{"featureType":"water","elementType":"geometry.fill","stylers":[{"color":"#c8d7d4"}]},{"featureType":"water","elementType":"labels.text.fill","stylers":[{"color":"#070707"}]},{"featureType":"water","elementType":"labels.text.stroke","stylers":[{"color":"#ffffff"}]}]

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,757 @@
/* juxtapose - v2017-03-16-19-29-42 - 2017-03-16
* Copyright (c) 2017 Alex Duner and Northwestern University Knight Lab
*/
/* juxtapose - v1.1.2 - 2015-07-16
* Copyright (c) 2015 Alex Duner and Northwestern University Knight Lab
*/
(function (document, window) {
var juxtapose = {
sliders: [],
OPTIMIZATION_ACCEPTED: 1,
OPTIMIZATION_WAS_CONSTRAINED: 2
};
var flickr_key = "d90fc2d1f4acc584e08b8eaea5bf4d6c";
var FLICKR_SIZE_PREFERENCES = ['Large', 'Medium'];
function Graphic(properties, slider) {
var self = this;
this.image = new Image();
this.loaded = false;
this.image.onload = function() {
self.loaded = true;
slider._onLoaded();
};
this.image.src = properties.src;
this.label = properties.label || false;
this.credit = properties.credit || false;
}
function FlickrGraphic(properties, slider) {
var self = this;
this.image = new Image();
this.loaded = false;
this.image.onload = function() {
self.loaded = true;
slider._onLoaded();
};
this.flickrID = this.getFlickrID(properties.src);
this.callFlickrAPI(this.flickrID, self);
this.label = properties.label || false;
this.credit = properties.credit || false;
}
FlickrGraphic.prototype = {
getFlickrID: function(url) {
var idx = url.indexOf("flickr.com/photos/");
var pos = idx + "flickr.com/photos/".length;
var photo_info = url.substr(pos);
if (photo_info.indexOf('/') == -1) return null;
if (photo_info.indexOf('/') === 0) photo_info = photo_info.substr(1);
id = photo_info.split("/")[1];
return id;
},
callFlickrAPI: function(id, self) {
var url = 'https://api.flickr.com/services/rest/?method=flickr.photos.getSizes' +
'&api_key=' + flickr_key +
'&photo_id=' + id + '&format=json&nojsoncallback=1';
var request = new XMLHttpRequest();
request.open('GET', url, true);
request.onload = function() {
if (request.status >= 200 && request.status < 400){
data = JSON.parse(request.responseText);
var flickr_url = self.bestFlickrUrl(data.sizes.size);
self.setFlickrImage(flickr_url);
} else {
console.error("There was an error getting the picture from Flickr");
}
};
request.onerror = function() {
console.error("There was an error getting the picture from Flickr");
};
request.send();
},
setFlickrImage: function(src) {
this.image.src = src;
},
bestFlickrUrl: function(ary) {
var dict = {};
for (var i = 0; i < ary.length; i++) {
dict[ary[i].label] = ary[i].source;
}
for (var j = 0; j < FLICKR_SIZE_PREFERENCES.length; j++) {
if (FLICKR_SIZE_PREFERENCES[j] in dict) {
return dict[FLICKR_SIZE_PREFERENCES[j]];
}
}
return ary[0].source;
}
};
function getNaturalDimensions(DOMelement) {
if (DOMelement.naturalWidth && DOMelement.naturalHeight) {
return {width: DOMelement.naturalWidth, height: DOMelement.naturalHeight};
}
// http://www.jacklmoore.com/notes/naturalwidth-and-naturalheight-in-ie/
var img = new Image();
img.src = DOMelement.src;
return {width: img.width, height: img.height};
}
function getImageDimensions(img) {
var dimensions = {
width: getNaturalDimensions(img).width,
height: getNaturalDimensions(img).height,
aspect: function() { return (this.width / this.height); }
};
return dimensions;
}
function addClass(element, c) {
if (element.classList) {
element.classList.add(c);
} else {
element.className += " " + c;
}
}
function removeClass(element, c) {
element.className = element.className.replace(/(\S+)\s*/g, function (w, match) {
if (match === c) {
return '';
}
return w;
}).replace(/^\s+/, '');
}
function setText(element, text) {
if (document.body.textContent) {
element.textContent = text;
} else {
element.innerText = text;
}
}
function getComputedWidthAndHeight(element) {
if (window.getComputedStyle) {
return {
width: parseInt(getComputedStyle(element).width, 10),
height: parseInt(getComputedStyle(element).height, 10)
};
} else {
w = element.getBoundingClientRect().right - element.getBoundingClientRect().left;
h = element.getBoundingClientRect().bottom - element.getBoundingClientRect().top;
return {
width: parseInt(w, 10) || 0,
height: parseInt(h, 10) || 0
};
}
}
function viewport() {
var e = window, a = 'inner';
if ( !( 'innerWidth' in window ) ) {
a = 'client';
e = document.documentElement || document.body;
}
return { width : e[ a+'Width' ] , height : e[ a+'Height' ] }
}
function getPageX(e) {
var pageX;
if (e.pageX) {
pageX = e.pageX;
} else if (e.touches) {
pageX = e.touches[0].pageX;
} else {
pageX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
}
return pageX;
}
function getPageY(e) {
var pageY;
if (e.pageY) {
pageY = e.pageY;
} else if (e.touches) {
pageY = e.touches[0].pageY;
} else {
pageY = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
}
return pageY;
}
function checkFlickr(url) {
var idx = url.indexOf("flickr.com/photos/");
if (idx == -1) {
return false;
} else {
return true;
}
}
function getLeftPercent(slider, input) {
if (typeof(input) === "string" || typeof(input) === "number") {
leftPercent = parseInt(input, 10);
} else {
var sliderRect = slider.getBoundingClientRect();
var offset = {
top: sliderRect.top + document.body.scrollTop,
left: sliderRect.left + document.body.scrollLeft
};
var width = slider.offsetWidth;
var pageX = getPageX(input);
var relativeX = pageX - offset.left;
leftPercent = (relativeX / width) * 100;
}
return leftPercent;
}
function getTopPercent(slider, input) {
if (typeof(input) === "string" || typeof(input) === "number") {
topPercent = parseInt(input, 10);
} else {
var sliderRect = slider.getBoundingClientRect();
var offset = {
top: sliderRect.top + document.body.scrollTop,
left: sliderRect.left + document.body.scrollLeft
};
var width = slider.offsetHeight;
var pageY = getPageY(input);
var relativeY = pageY - offset.top;
topPercent = (relativeY / width) * 100;
}
return topPercent;
}
// values of BOOLEAN_OPTIONS are ignored. just used for 'in' test on keys
var BOOLEAN_OPTIONS = {'animate': true, 'showLabels': true, 'showCredits': true, 'makeResponsive': true };
function interpret_boolean(x) {
if (typeof(x) != 'string') {
return Boolean(x);
}
return !(x === 'false' || x === '');
}
function JXSlider(selector, images, options) {
this.selector = selector;
var i;
this.options = { // new options must have default values set here.
animate: true,
showLabels: true,
showCredits: true,
makeResponsive: true,
startingPosition: "50%",
mode: 'horizontal',
prevIcon: '',
nextIcon: '',
callback: null // pass a callback function if you like
};
for (i in this.options) {
if(i in options) {
if (i in BOOLEAN_OPTIONS) {
this.options[i] = interpret_boolean(options[i]);
} else {
this.options[i] = options[i];
}
}
}
if (images.length == 2) {
if(checkFlickr(images[0].src)) {
this.imgBefore = new FlickrGraphic(images[0], this);
} else {
this.imgBefore = new Graphic(images[0], this);
}
if(checkFlickr(images[1].src)) {
this.imgAfter = new FlickrGraphic(images[1], this);
} else {
this.imgAfter = new Graphic(images[1], this);
}
} else {
console.warn("The images parameter takes two Image objects.");
}
if (this.imgBefore.credit || this.imgAfter.credit) {
this.options.showCredits = true;
} else {
this.options.showCredits = false;
}
}
JXSlider.prototype = {
updateSlider: function(input, animate) {
var leftPercent, rightPercent;
if (this.options.mode === "vertical") {
leftPercent = getTopPercent(this.slider, input);
} else {
leftPercent = getLeftPercent(this.slider, input);
}
leftPercent = leftPercent.toFixed(2) + "%";
leftPercentNum = parseFloat(leftPercent);
rightPercent = (100 - leftPercentNum) + "%";
if (leftPercentNum > 0 && leftPercentNum < 100) {
removeClass(this.handle, 'transition');
removeClass(this.rightImage, 'transition');
removeClass(this.leftImage, 'transition');
if (this.options.animate && animate) {
addClass(this.handle, 'transition');
addClass(this.leftImage, 'transition');
addClass(this.rightImage, 'transition');
}
if (this.options.mode === "vertical") {
this.handle.style.top = leftPercent;
this.leftImage.style.height = leftPercent;
this.rightImage.style.height = rightPercent;
} else {
this.handle.style.left = leftPercent;
this.leftImage.style.width = leftPercent;
this.rightImage.style.width = rightPercent;
}
this.sliderPosition = leftPercent;
}
},
getPosition: function() {
return this.sliderPosition;
},
displayLabel: function(element, labelText) {
label = document.createElement("div");
label.className = 'jx-label';
label.setAttribute('tabindex', 0); //put the controller in the natural tab order of the document
setText(label, labelText);
element.appendChild(label);
},
displayCredits: function() {
credit = document.createElement("div");
credit.className = "jx-credit";
text = "<em>Photo Credits:</em>";
if (this.imgBefore.credit) { text += " <em>Before</em> " + this.imgBefore.credit; }
if (this.imgAfter.credit) { text += " <em>After</em> " + this.imgAfter.credit; }
credit.innerHTML = text;
this.wrapper.appendChild(credit);
},
setStartingPosition: function(s) {
this.options.startingPosition = s;
},
checkImages: function() {
if (getImageDimensions(this.imgBefore.image).aspect() ==
getImageDimensions(this.imgAfter.image).aspect()) {
return true;
} else {
return false;
}
},
calculateDims: function(width, height){
var ratio = getImageDimensions(this.imgBefore.image).aspect();
if (width) {
height = width / ratio;
} else if (height) {
width = height * ratio;
}
return {
width: width,
height: height,
ratio: ratio
};
},
responsivizeIframe: function(dims){
//Check the slider dimensions against the iframe (window) dimensions
if (dims.height < window.innerHeight){
//If the aspect ratio is greater than 1, imgs are landscape, so letterbox top and bottom
if (dims.ratio >= 1){
this.wrapper.style.paddingTop = parseInt((window.innerHeight - dims.height) / 2) + "px";
}
} else if (dims.height > window.innerHeight) {
/* If the image is too tall for the window, which happens at 100% width on large screens,
* force dimension recalculation based on height instead of width */
dims = this.calculateDims(0, window.innerHeight);
this.wrapper.style.paddingLeft = parseInt((window.innerWidth - dims.width) / 2) + "px";
}
if (this.options.showCredits) {
// accommodate the credits box within the iframe
dims.height -= 13;
}
return dims;
},
setWrapperDimensions: function() {
var wrapperWidth = getComputedWidthAndHeight(this.wrapper).width;
var wrapperHeight = getComputedWidthAndHeight(this.wrapper).height;
var dims = this.calculateDims(wrapperWidth, wrapperHeight);
// if window is in iframe, make sure images don't overflow boundaries
if (window.location !== window.parent.location && !this.options.makeResponsive) {
dims = this.responsivizeIframe(dims);
}
// this.wrapper.style.height = parseInt(dims.height) + "px";
// this.wrapper.style.width = parseInt(dims.width) + "px";
this.slider.style.height = parseInt(dims.height) + "px";
this.slider.style.width = parseInt(dims.width) + "px";
},
optimizeWrapper: function(maxWidth){
var result = juxtapose.OPTIMIZATION_ACCEPTED;
if ((this.imgBefore.image.naturalWidth >= maxWidth) && (this.imgAfter.image.naturalWidth >= maxWidth)) {
this.wrapper.style.width = maxWidth + "px";
result = juxtapose.OPTIMIZATION_WAS_CONSTRAINED;
} else if (this.imgAfter.image.naturalWidth < maxWidth) {
this.wrapper.style.width = this.imgAfter.image.naturalWidth + "px";
} else {
this.wrapper.style.width = this.imgBefore.image.naturalWidth + "px";
}
this.setWrapperDimensions();
return result;
},
_onLoaded: function() {
if (this.imgBefore && this.imgBefore.loaded === true &&
this.imgAfter && this.imgAfter.loaded === true) {
this.wrapper = document.querySelector(this.selector);
addClass(this.wrapper, 'juxtapose');
this.slider = document.createElement("div");
this.slider.className = 'jx-slider';
this.wrapper.appendChild(this.slider);
this.wrapper.style.width = getNaturalDimensions(this.imgBefore.image).width;
this.setWrapperDimensions();
if (this.options.mode != "horizontal") {
addClass(this.slider, this.options.mode);
}
this.handle = document.createElement("div");
this.handle.className = 'jx-handle';
this.rightImage = document.createElement("div");
this.rightImage.className = 'jx-image jx-right';
this.rightImage.appendChild(this.imgAfter.image);
this.leftImage = document.createElement("div");
this.leftImage.className = 'jx-image jx-left';
this.leftImage.appendChild(this.imgBefore.image);
this.labCredit = document.createElement("a");
this.labCredit.setAttribute('href', 'http://juxtapose.knightlab.com');
this.labCredit.setAttribute('target', '_blank');
this.labCredit.className = 'jx-knightlab';
this.labLogo = document.createElement("div");
this.labLogo.className = 'knightlab-logo';
this.labCredit.appendChild(this.labLogo);
this.projectName = document.createElement("span");
this.projectName.className = 'juxtapose-name';
setText(this.projectName, 'JuxtaposeJS');
this.labCredit.appendChild(this.projectName);
this.slider.appendChild(this.handle);
this.slider.appendChild(this.leftImage);
this.slider.appendChild(this.rightImage);
//this.slider.appendChild(this.labCredit);
this.leftArrow = document.createElement("div");
this.rightArrow = document.createElement("div");
this.control = document.createElement("div");
this.controller = document.createElement("div");
this.controllerPrev = document.createElement("i");
this.controllerNext = document.createElement("i");
this.leftArrow.className = 'jx-arrow jx-left';
this.rightArrow.className = 'jx-arrow jx-right';
this.control.className = 'jx-control';
this.controller.className = 'jx-controller';
this.controllerPrev.className = this.options.prevIcon;
this.controllerNext.className = this.options.nextIcon;
this.controller.setAttribute('tabindex', 0); //put the controller in the natural tab order of the document
this.controller.setAttribute('role', 'slider');
this.controller.setAttribute('aria-valuenow', 50);
this.controller.setAttribute('aria-valuemin', 0);
this.controller.setAttribute('aria-valuemax', 100);
this.handle.appendChild(this.leftArrow);
this.handle.appendChild(this.control);
this.handle.appendChild(this.rightArrow);
this.control.appendChild(this.controller);
this.controller.appendChild(this.controllerPrev);
this.controller.appendChild(this.controllerNext);
this._init();
}
},
_init: function() {
if (this.checkImages() === false) {
console.warn(this, "Check that the two images have the same aspect ratio for the slider to work correctly.");
}
this.updateSlider(this.options.startingPosition, false);
if (this.options.showLabels === true) {
if (this.imgBefore.label) { this.displayLabel(this.leftImage, this.imgBefore.label); }
if (this.imgAfter.label) { this.displayLabel(this.rightImage, this.imgAfter.label); }
}
if (this.options.showCredits === true) {
this.displayCredits();
}
var self = this;
// Set up Javascript Events
// On mousedown, call updateSlider then set animate to false
// (if animate is true, adds css transition when updating).
this.slider.addEventListener("mousedown", function(e) {
e = e || window.event;
e.preventDefault();
self.updateSlider(e, true);
animate = true;
this.addEventListener("mousemove", function(e) {
e = e || window.event;
e.preventDefault();
if (animate) { self.updateSlider(e, false); }
});
this.addEventListener('mouseup', function(e) {
e = e || window.event;
e.preventDefault();
e.stopPropagation();
this.removeEventListener('mouseup', arguments.callee);
animate = false;
});
});
this.slider.addEventListener("touchstart", function(e) {
e = e || window.event;
e.preventDefault();
e.stopPropagation();
self.updateSlider(e, true);
this.addEventListener("touchmove", function(e) {
e = e || window.event;
e.preventDefault();
e.stopPropagation();
self.updateSlider(event, false);
});
});
window.addEventListener( 'orientationchange', function() {
self.setWrapperDimensions();
});
window.addEventListener( 'resize', function() {
self.setWrapperDimensions();
});
/* keyboard accessibility */
this.handle.addEventListener("keydown", function (e) {
e = e || window.event;
var key = e.which || e.keyCode;
var ariaValue = parseFloat(this.style.left);
//move jx-controller left
if (key == 37) {
ariaValue = ariaValue - 1;
var leftStart = parseFloat(this.style.left) - 1;
self.updateSlider(leftStart, false);
self.controller.setAttribute('aria-valuenow', ariaValue);
}
//move jx-controller right
if (key == 39) {
ariaValue = ariaValue + 1;
var rightStart = parseFloat(this.style.left) + 1;
self.updateSlider(rightStart, false);
self.controller.setAttribute('aria-valuenow', ariaValue);
}
});
//toggle right-hand image visibility
this.leftImage.addEventListener("keydown", function (event) {
var key = event.which || event.keyCode;
if ((key == 13) || (key ==32)) {
self.updateSlider("90%", true);
self.controller.setAttribute('aria-valuenow', 90);
}
});
//toggle left-hand image visibility
this.rightImage.addEventListener("keydown", function (event) {
var key = event.which || event.keyCode;
if ((key == 13) || (key ==32)) {
self.updateSlider("10%", true);
self.controller.setAttribute('aria-valuenow', 10);
}
});
juxtapose.sliders.push(this);
if (this.options.callback && typeof(this.options.callback) == 'function') {
this.options.callback(this);
}
}
};
/*
Given an element that is configured with the proper data elements, make a slider out of it.
Normally this will just be used by scanPage.
*/
juxtapose.makeSlider = function (element, idx) {
if (typeof idx == 'undefined') {
idx = juxtapose.sliders.length; // not super threadsafe...
}
var w = element;
var images = w.querySelectorAll('img');
var options = {};
// don't set empty string into options, that's a false false.
if (w.getAttribute('data-animate')) {
options.animate = w.getAttribute('data-animate');
}
if (w.getAttribute('data-showlabels')) {
options.showLabels = w.getAttribute('data-showlabels');
}
if (w.getAttribute('data-showcredits')) {
options.showCredits = w.getAttribute('data-showcredits');
}
if (w.getAttribute('data-startingposition')) {
options.startingPosition = w.getAttribute('data-startingposition');
}
if (w.getAttribute('data-mode')) {
options.mode = w.getAttribute('data-mode');
}
if (w.getAttribute('data-makeresponsive')) {
options.mode = w.getAttribute('data-makeresponsive');
}
if (w.getAttribute('data-prev-icon')) {
options.prevIcon = w.getAttribute('data-prev-icon');
}
if (w.getAttribute('data-next-icon')) {
options.nextIcon = w.getAttribute('data-next-icon');
}
specificClass = 'juxtapose-' + idx;
addClass(element, specificClass);
selector = '.' + specificClass;
if (w.innerHTML) {
w.innerHTML = '';
} else {
w.innerText = '';
}
slider = new juxtapose.JXSlider(
selector,
[
{
src: images[0].src,
label: images[0].getAttribute('data-label'),
credit: images[0].getAttribute('data-credit')
},
{
src: images[1].src,
label: images[1].getAttribute('data-label'),
credit: images[1].getAttribute('data-credit')
}
],
options
);
};
//Enable HTML Implementation
juxtapose.scanPage = function( selector ) {
var elements = document.querySelectorAll( selector );
for (var i = 0; i < elements.length; i++) {
if ( 'true' !== elements[i].getAttribute( 'data-init' ) ) {
elements[i].setAttribute( 'data-init', 'true' );
juxtapose.makeSlider(elements[i], i);
}
}
};
juxtapose.JXSlider = JXSlider;
window.juxtapose = juxtapose;
}(document, window));
// addEventListener polyfill 1.0 / Eirik Backer / MIT Licence
(function(win, doc){
if(win.addEventListener)return; //No need to polyfill
function docHijack(p){var old = doc[p];doc[p] = function(v){return addListen(old(v));};}
function addEvent(on, fn, self){
return (self = this).attachEvent('on' + on, function(e) {
var e = e || win.event;
e.preventDefault = e.preventDefault || function(){e.returnValue = false;};
e.stopPropagation = e.stopPropagation || function(){e.cancelBubble = true;};
fn.call(self, e);
});
}
function addListen(obj, i){
if(i = obj.length)while(i--)obj[i].addEventListener = addEvent;
else obj.addEventListener = addEvent;
return obj;
}
addListen([doc, win]);
if('Element' in win)win.Element.prototype.addEventListener = addEvent; //IE8
else{ //IE < 8
doc.attachEvent('onreadystatechange', function(){addListen(doc.all);}); //Make sure we also init at domReady
docHijack('getElementsByTagName');
docHijack('getElementById');
docHijack('createElement');
addListen(doc.all);
}
})(window, document);

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,415 @@
/* jshint laxcomma: true */
var salvattore = (function (global, document, undefined) {
"use strict";
var self = {},
grids = [],
mediaRules = [],
mediaQueries = [],
add_to_dataset = function(element, key, value) {
// uses dataset function or a fallback for <ie10
if (element.dataset) {
element.dataset[key] = value;
} else {
element.setAttribute("data-" + key, value);
}
return;
};
self.obtainGridSettings = function obtainGridSettings(element) {
// returns the number of columns and the classes a column should have,
// from computing the style of the ::before pseudo-element of the grid.
var computedStyle = global.getComputedStyle(element, ":before")
, content = computedStyle.getPropertyValue("content").slice(1, -1)
, matchResult = content.match(/^\s*(\d+)(?:\s?\.(.+))?\s*$/)
, numberOfColumns = 1
, columnClasses = []
;
if (matchResult) {
numberOfColumns = matchResult[1];
columnClasses = matchResult[2];
columnClasses = columnClasses? columnClasses.split(".") : ["column"];
} else {
matchResult = content.match(/^\s*\.(.+)\s+(\d+)\s*$/);
if (matchResult) {
columnClasses = matchResult[1];
numberOfColumns = matchResult[2];
if (numberOfColumns) {
numberOfColumns = numberOfColumns.split(".");
}
}
}
return {
numberOfColumns: numberOfColumns,
columnClasses: columnClasses
};
};
self.addColumns = function addColumns(grid, items) {
// from the settings obtained, it creates columns with
// the configured classes and adds to them a list of items.
var settings = self.obtainGridSettings(grid)
, numberOfColumns = settings.numberOfColumns
, columnClasses = settings.columnClasses
, columnsItems = new Array(+numberOfColumns)
, columnsFragment = document.createDocumentFragment()
, i = numberOfColumns
, selector
;
while (i-- !== 0) {
selector = "[data-columns] > *:nth-child(" + numberOfColumns + "n-" + i + ")";
columnsItems.push(items.querySelectorAll(selector));
}
columnsItems.forEach(function append_to_grid_fragment(rows) {
var column = document.createElement("div")
, rowsFragment = document.createDocumentFragment()
;
column.className = columnClasses.join(" ");
Array.prototype.forEach.call(rows, function append_to_column(row) {
rowsFragment.appendChild(row);
});
column.appendChild(rowsFragment);
columnsFragment.appendChild(column);
});
grid.appendChild(columnsFragment);
add_to_dataset(grid, 'columns', numberOfColumns);
};
self.removeColumns = function removeColumns(grid) {
// removes all the columns from a grid, and returns a list
// of items sorted by the ordering of columns.
var range = document.createRange();
range.selectNodeContents(grid);
var columns = Array.prototype.filter.call(range.extractContents().childNodes, function filter_elements(node) {
return node instanceof global.HTMLElement;
});
var numberOfColumns = columns.length
, numberOfRowsInFirstColumn = columns[0].childNodes.length
, sortedRows = new Array(numberOfRowsInFirstColumn * numberOfColumns)
;
Array.prototype.forEach.call(columns, function iterate_columns(column, columnIndex) {
Array.prototype.forEach.call(column.children, function iterate_rows(row, rowIndex) {
sortedRows[rowIndex * numberOfColumns + columnIndex] = row;
});
});
var container = document.createElement("div");
add_to_dataset(container, 'columns', 0);
sortedRows.filter(function filter_non_null(child) {
return !!child;
}).forEach(function append_row(child) {
container.appendChild(child);
});
return container;
};
self.recreateColumns = function recreateColumns(grid) {
// removes all the columns from the grid, and adds them again,
// it is used when the number of columns change.
global.requestAnimationFrame(function render_after_css_mediaQueryChange() {
self.addColumns(grid, self.removeColumns(grid));
var columnsChange = new CustomEvent("columnsChange");
grid.dispatchEvent(columnsChange);
});
};
self.mediaQueryChange = function mediaQueryChange(mql) {
// recreates the columns when a media query matches the current state
// of the browser.
if (mql.matches) {
Array.prototype.forEach.call(grids, self.recreateColumns);
}
};
self.getCSSRules = function getCSSRules(stylesheet) {
// returns a list of css rules from a stylesheet
var cssRules;
try {
cssRules = stylesheet.sheet.cssRules || stylesheet.sheet.rules;
} catch (e) {
return [];
}
return cssRules || [];
};
self.getStylesheets = function getStylesheets() {
// returns a list of all the styles in the document (that are accessible).
var inlineStyleBlocks = Array.prototype.slice.call(document.querySelectorAll("style"));
inlineStyleBlocks.forEach(function(stylesheet, idx) {
if (stylesheet.type !== 'text/css' && stylesheet.type !== '') {
inlineStyleBlocks.splice(idx, 1);
}
});
return Array.prototype.concat.call(
inlineStyleBlocks,
Array.prototype.slice.call(document.querySelectorAll("link[rel='stylesheet']"))
);
};
self.mediaRuleHasColumnsSelector = function mediaRuleHasColumnsSelector(rules) {
// checks if a media query css rule has in its contents a selector that
// styles the grid.
var i, rule;
try {
i = rules.length;
}
catch (e) {
i = 0;
}
while (i--) {
rule = rules[i];
if (rule.selectorText && rule.selectorText.match(/\[data-columns\](.*)::?before$/)) {
return true;
}
}
return false;
};
self.scanMediaQueries = function scanMediaQueries() {
// scans all the stylesheets for selectors that style grids,
// if the matchMedia API is supported.
var newMediaRules = [];
if (!global.matchMedia) {
return;
}
self.getStylesheets().forEach(function extract_rules(stylesheet) {
Array.prototype.forEach.call(self.getCSSRules(stylesheet), function filter_by_column_selector(rule) {
// rule.media throws an 'not implemented error' in ie9 for import rules occasionally
try {
if (rule.media && rule.cssRules && self.mediaRuleHasColumnsSelector(rule.cssRules)) {
newMediaRules.push(rule);
}
} catch (e) {}
});
});
// remove matchMedia listeners from the old rules
var oldRules = mediaRules.filter(function (el) {
return newMediaRules.indexOf(el) === -1;
});
mediaQueries.filter(function (el) {
return oldRules.indexOf(el.rule) !== -1;
}).forEach(function (el) {
el.mql.removeListener(self.mediaQueryChange);
});
mediaQueries = mediaQueries.filter(function (el) {
return oldRules.indexOf(el.rule) === -1;
});
// add matchMedia listeners to the new rules
newMediaRules.filter(function (el) {
return mediaRules.indexOf(el) == -1;
}).forEach(function (rule) {
var mql = global.matchMedia(rule.media.mediaText);
mql.addListener(self.mediaQueryChange);
mediaQueries.push({rule: rule, mql:mql});
});
// swap mediaRules with the new set
mediaRules.length = 0;
mediaRules = newMediaRules;
};
self.rescanMediaQueries = function rescanMediaQueries() {
self.scanMediaQueries();
Array.prototype.forEach.call(grids, self.recreateColumns);
};
self.nextElementColumnIndex = function nextElementColumnIndex(grid, fragments) {
// returns the index of the column where the given element must be added.
var children = grid.children
, m = children.length
, lowestRowCount = 0
, child
, currentRowCount
, i
, index = 0
;
for (i = 0; i < m; i++) {
child = children[i];
currentRowCount = child.children.length + (fragments[i].children || fragments[i].childNodes).length;
if(lowestRowCount === 0) {
lowestRowCount = currentRowCount;
}
if(currentRowCount < lowestRowCount) {
index = i;
lowestRowCount = currentRowCount;
}
}
return index;
};
self.createFragmentsList = function createFragmentsList(quantity) {
// returns a list of fragments
var fragments = new Array(quantity)
, i = 0
;
while (i !== quantity) {
fragments[i] = document.createDocumentFragment();
i++;
}
return fragments;
};
self.appendElements = function appendElements(grid, elements) {
// adds a list of elements to the end of a grid
var columns = grid.children
, numberOfColumns = columns.length
, fragments = self.createFragmentsList(numberOfColumns)
;
Array.prototype.forEach.call(elements, function append_to_next_fragment(element) {
var columnIndex = self.nextElementColumnIndex(grid, fragments);
fragments[columnIndex].appendChild(element);
});
Array.prototype.forEach.call(columns, function insert_column(column, index) {
column.appendChild(fragments[index]);
});
};
self.prependElements = function prependElements(grid, elements) {
// adds a list of elements to the start of a grid
var columns = grid.children
, numberOfColumns = columns.length
, fragments = self.createFragmentsList(numberOfColumns)
, columnIndex = numberOfColumns - 1
;
elements.forEach(function append_to_next_fragment(element) {
var fragment = fragments[columnIndex];
fragment.insertBefore(element, fragment.firstChild);
if (columnIndex === 0) {
columnIndex = numberOfColumns - 1;
} else {
columnIndex--;
}
});
Array.prototype.forEach.call(columns, function insert_column(column, index) {
column.insertBefore(fragments[index], column.firstChild);
});
// populates a fragment with n columns till the right
var fragment = document.createDocumentFragment()
, numberOfColumnsToExtract = elements.length % numberOfColumns
;
while (numberOfColumnsToExtract-- !== 0) {
fragment.appendChild(grid.lastChild);
}
// adds the fragment to the left
grid.insertBefore(fragment, grid.firstChild);
};
self.registerGrid = function registerGrid (grid) {
if (global.getComputedStyle(grid).display === "none") {
return;
}
if ( 'true' === grid.getAttribute('data-inited') ) {
return;
}
grid.setAttribute( 'data-inited', 'true' );
// retrieve the list of items from the grid itself
var range = document.createRange();
range.selectNodeContents(grid);
var items = document.createElement("div");
items.appendChild(range.extractContents());
add_to_dataset(items, 'columns', 0);
self.addColumns(grid, items);
grids.push(grid);
};
self.init = function init() {
// adds required CSS rule to hide 'content' based
// configuration.
var css = document.createElement("style");
css.innerHTML = "[data-columns]::before{display:block;visibility:hidden;position:absolute;font-size:1px;}";
document.head.appendChild(css);
// scans all the grids in the document and generates
// columns from their configuration.
var gridElements = document.querySelectorAll("[data-columns]");
Array.prototype.forEach.call(gridElements, self.registerGrid);
self.scanMediaQueries();
};
self.init();
return {
appendElements: self.appendElements,
prependElements: self.prependElements,
registerGrid: self.registerGrid,
recreateColumns: self.recreateColumns,
rescanMediaQueries: self.rescanMediaQueries,
init: self.init,
// maintains backwards compatibility with underscore style method names
append_elements: self.appendElements,
prepend_elements: self.prependElements,
register_grid: self.registerGrid,
recreate_columns: self.recreateColumns,
rescan_media_queries: self.rescanMediaQueries
};
})(window, window.document);

View File

@@ -0,0 +1 @@
var salvattore=function(o,s,e){"use strict";var u={},n=[],a=[],i=[],d=function(e,t,r){e.dataset?e.dataset[t]=r:e.setAttribute("data-"+t,r)};return u.obtainGridSettings=function(e){var t=o.getComputedStyle(e,":before").getPropertyValue("content").slice(1,-1),r=t.match(/^\s*(\d+)(?:\s?\.(.+))?\s*$/),n=1,a=[];return r?(n=r[1],a=(a=r[2])?a.split("."):["column"]):(r=t.match(/^\s*\.(.+)\s+(\d+)\s*$/))&&(a=r[1],(n=r[2])&&(n=n.split("."))),{numberOfColumns:n,columnClasses:a}},u.addColumns=function(e,t){for(var r,n=u.obtainGridSettings(e),a=n.numberOfColumns,i=n.columnClasses,l=new Array(+a),o=s.createDocumentFragment(),c=a;0!=c--;)r="[data-columns] > *:nth-child("+a+"n-"+c+")",l.push(t.querySelectorAll(r));l.forEach(function(e){var t=s.createElement("div"),r=s.createDocumentFragment();t.className=i.join(" "),Array.prototype.forEach.call(e,function(e){r.appendChild(e)}),t.appendChild(r),o.appendChild(t)}),e.appendChild(o),d(e,"columns",a)},u.removeColumns=function(e){var t=s.createRange();t.selectNodeContents(e);var r=Array.prototype.filter.call(t.extractContents().childNodes,function(e){return e instanceof o.HTMLElement}),n=r.length,a=r[0].childNodes.length,i=new Array(a*n);Array.prototype.forEach.call(r,function(e,r){Array.prototype.forEach.call(e.children,function(e,t){i[t*n+r]=e})});var l=s.createElement("div");return d(l,"columns",0),i.filter(function(e){return!!e}).forEach(function(e){l.appendChild(e)}),l},u.recreateColumns=function(t){o.requestAnimationFrame(function(){u.addColumns(t,u.removeColumns(t));var e=new CustomEvent("columnsChange");t.dispatchEvent(e)})},u.mediaQueryChange=function(e){e.matches&&Array.prototype.forEach.call(n,u.recreateColumns)},u.getCSSRules=function(e){var t;try{t=e.sheet.cssRules||e.sheet.rules}catch(e){return[]}return t||[]},u.getStylesheets=function(){var r=Array.prototype.slice.call(s.querySelectorAll("style"));return r.forEach(function(e,t){"text/css"!==e.type&&""!==e.type&&r.splice(t,1)}),Array.prototype.concat.call(r,Array.prototype.slice.call(s.querySelectorAll("link[rel='stylesheet']")))},u.mediaRuleHasColumnsSelector=function(e){var t,r;try{t=e.length}catch(e){t=0}for(;t--;)if((r=e[t]).selectorText&&r.selectorText.match(/\[data-columns\](.*)::?before$/))return!0;return!1},u.scanMediaQueries=function(){var t=[];if(o.matchMedia){u.getStylesheets().forEach(function(e){Array.prototype.forEach.call(u.getCSSRules(e),function(e){try{e.media&&e.cssRules&&u.mediaRuleHasColumnsSelector(e.cssRules)&&t.push(e)}catch(e){}})});var r=a.filter(function(e){return-1===t.indexOf(e)});i.filter(function(e){return-1!==r.indexOf(e.rule)}).forEach(function(e){e.mql.removeListener(u.mediaQueryChange)}),i=i.filter(function(e){return-1===r.indexOf(e.rule)}),t.filter(function(e){return-1==a.indexOf(e)}).forEach(function(e){var t=o.matchMedia(e.media.mediaText);t.addListener(u.mediaQueryChange),i.push({rule:e,mql:t})}),a.length=0,a=t}},u.rescanMediaQueries=function(){u.scanMediaQueries(),Array.prototype.forEach.call(n,u.recreateColumns)},u.nextElementColumnIndex=function(e,t){var r,n,a=e.children,i=a.length,l=0,o=0;for(n=0;n<i;n++)r=a[n].children.length+(t[n].children||t[n].childNodes).length,0===l&&(l=r),r<l&&(o=n,l=r);return o},u.createFragmentsList=function(e){for(var t=new Array(e),r=0;r!==e;)t[r]=s.createDocumentFragment(),r++;return t},u.appendElements=function(r,e){var t=r.children,n=t.length,a=u.createFragmentsList(n);Array.prototype.forEach.call(e,function(e){var t=u.nextElementColumnIndex(r,a);a[t].appendChild(e)}),Array.prototype.forEach.call(t,function(e,t){e.appendChild(a[t])})},u.prependElements=function(e,t){var r=e.children,n=r.length,a=u.createFragmentsList(n),i=n-1;t.forEach(function(e){var t=a[i];t.insertBefore(e,t.firstChild),0===i?i=n-1:i--}),Array.prototype.forEach.call(r,function(e,t){e.insertBefore(a[t],e.firstChild)});for(var l=s.createDocumentFragment(),o=t.length%n;0!=o--;)l.appendChild(e.lastChild);e.insertBefore(l,e.firstChild)},u.registerGrid=function(e){if("none"!==o.getComputedStyle(e).display&&"true"!==e.getAttribute("data-inited")){e.setAttribute("data-inited","true");var t=s.createRange();t.selectNodeContents(e);var r=s.createElement("div");r.appendChild(t.extractContents()),d(r,"columns",0),u.addColumns(e,r),n.push(e)}},u.init=function(){var e=s.createElement("style");e.innerHTML="[data-columns]::before{display:block;visibility:hidden;position:absolute;font-size:1px;}",s.head.appendChild(e);var t=s.querySelectorAll("[data-columns]");Array.prototype.forEach.call(t,u.registerGrid),u.scanMediaQueries()},u.init(),{appendElements:u.appendElements,prependElements:u.prependElements,registerGrid:u.registerGrid,recreateColumns:u.recreateColumns,rescanMediaQueries:u.rescanMediaQueries,init:u.init,append_elements:u.appendElements,prepend_elements:u.prependElements,register_grid:u.registerGrid,recreate_columns:u.recreateColumns,rescan_media_queries:u.rescanMediaQueries}}(window,window.document);

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long