jimu-mobile
Version:
积木组件库助力移动端开发
362 lines (360 loc) • 17.1 kB
JavaScript
;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
/*
2017 Julian Garnier
Released under the MIT license
*/
var $jscomp$this = undefined;
(function (w, p) {
"function" === typeof define && define.amd ? define([], p) : "object" === (typeof module === "undefined" ? "undefined" : _typeof(module)) && module.exports ? module.exports = p() : w.anime = p();
})(undefined, function () {
function w(a) {
if (!g.col(a)) try {
return document.querySelectorAll(a);
} catch (c) {}
}function p(a) {
return a.reduce(function (a, d) {
return a.concat(g.arr(d) ? p(d) : d);
}, []);
}function x(a) {
if (g.arr(a)) return a;g.str(a) && (a = w(a) || a);return a instanceof NodeList || a instanceof HTMLCollection ? [].slice.call(a) : [a];
}function H(a, c) {
return a.some(function (a) {
return a === c;
});
}
function B(a) {
var c = {},
d;for (d in a) {
c[d] = a[d];
}return c;
}function C(a, c) {
var d = B(a),
b;for (b in a) {
d[b] = c.hasOwnProperty(b) ? c[b] : a[b];
}return d;
}function y(a, c) {
var d = B(a),
b;for (b in c) {
d[b] = g.und(a[b]) ? c[b] : a[b];
}return d;
}function W(a) {
a = a.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, function (a, c, d, h) {
return c + c + d + d + h + h;
});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 "rgb(" + a + "," + d + "," + c + ")";
}function X(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);a = parseInt(d[1]) / 360;var b = parseInt(d[2]) / 100,
d = parseInt(d[3]) / 100;if (0 == b) b = d = a = d;else {
var e = .5 > d ? d * (1 + b) : d + b - d * b,
k = 2 * d - e,
b = c(k, e, a + 1 / 3),
d = c(k, e, a);a = c(k, e, a - 1 / 3);
}return "rgb(" + 255 * b + "," + 255 * d + "," + 255 * a + ")";
}function v(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 Y(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 g.fnc(a) ? a(c.target, c.id, c.total) : a;
}function D(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 (g.dom(a) && H(Z, c)) return "transform";if (g.dom(a) && (a.getAttribute(c) || g.svg(a) && a[c])) return "attribute";if (g.dom(a) && "transform" !== c && D(a, c)) return "css";if (null != a[c]) return "object";
}function aa(a, c) {
var d = Y(c),
d = -1 < c.indexOf("scale") ? 1 : 0 + d;a = a.style.transform;if (!a) return d;for (var b = [], e = [], k = [], h = /(\w+)\((.+?)\)/g; b = h.exec(a);) {
e.push(b[1]), k.push(b[2]);
}a = k.filter(function (a, b) {
return e[b] === c;
});return a.length ? a[0] : d;
}function K(a, c) {
switch (J(a, c)) {case "transform":
return aa(a, c);case "css":
return D(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 = v(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 E(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 e = a.getItem(b);0 < b && (c += E(d, e));d = e;
}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 E({ 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) + E(c.getItem(c.numberOfItems - 1), c.getItem(0));}
}function F(a) {
return g.obj(a) && a.hasOwnProperty("totalLength");
}function ba(a, c) {
function d(b) {
b = void 0 === b ? 0 : b;return a.el.getPointAtLength(1 <= c + b ? c + b : 0);
}var b = d(),
e = d(-1),
k = d(1);switch (a.property) {case "x":
return b.x;case "y":
return b.y;case "angle":
return 180 * Math.atan2(k.y - e.y, k.x - e.x) / Math.PI;}
}function O(a, c) {
var d = /-?\d*\.?\d+/g,
b;b = F(a) ? a.totalLength : a;if (g.col(b)) b = g.rgb(b) ? b : g.hex(b) ? W(b) : g.hsl(b) ? X(b) : void 0;else {
var e = v(b),
e = e ? b.substr(0, b.length - e.length) : b;b = c && !/\s/g.test(b) ? e + c : e;
}b += "";return { original: b, numbers: b.match(d) ? b.match(d).map(Number) : [0], strings: g.str(a) || c ? b.split(d) : [] };
}function ca(a, c) {
return 0 === c.length ? a[0] : c.reduce(function (c, b, e) {
return c + a[e - 1] + (b ? b : " ");
});
}function P(a) {
return (a ? p(g.arr(a) ? a.map(x) : x(a)) : []).filter(function (a, d, b) {
return b.indexOf(a) === d;
});
}function da(a) {
var c = P(a);return c.map(function (a, b) {
return { target: a, id: b, total: c.length };
});
}function ea(a, c) {
var d = B(c);if (g.arr(a)) {
var b = a.length;2 !== b || g.obj(a[0]) ? g.fnc(c.duration) || (d.duration = c.duration / b) : a = { value: a };
}return x(a).map(function (a, b) {
b = b ? 0 : c.delay;a = g.obj(a) && !F(a) ? a : { value: a };g.und(a.delay) && (a.delay = b);return a;
}).map(function (a) {
return y(a, d);
});
}function fa(a, c) {
var d = {},
b;for (b in a) {
var e = I(a[b], c);g.arr(e) && (e = e.map(function (a) {
return I(a, c);
}), 1 === e.length && (e = e[0]));d[b] = e;
}d.duration = parseFloat(d.duration);d.delay = parseFloat(d.delay);
return d;
}function ga(a) {
return g.arr(a) ? z.apply(this, a) : Q[a];
}function ha(a, c) {
var d;return a.tweens.map(function (b) {
b = fa(b, c);var e = b.value,
k = K(c.target, a.name),
h = d ? d.to.original : k,
h = g.arr(e) ? e[0] : h,
m = L(g.arr(e) ? e[1] : e, h),
k = v(m) || v(h) || v(k);b.isPath = F(e);b.from = O(h, k);b.to = O(m, k);b.start = d ? d.end : a.offset;b.end = b.start + b.delay + b.duration;b.easing = ga(b.easing);b.elasticity = (1E3 - Math.min(Math.max(b.elasticity, 1), 999)) / 1E3;g.col(b.from.original) && (b.round = 1);return d = b;
});
}function ia(a, c) {
return p(a.map(function (a) {
return c.map(function (b) {
var c = J(a.target, b.name);if (c) {
var d = ha(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;
});
})).filter(function (a) {
return !g.und(a);
});
}function R(a, c, d) {
var b = "delay" === a ? Math.min : Math.max;return c.length ? b.apply(Math, c.map(function (b) {
return b[a];
})) : d[a];
}function ja(a) {
var c = C(ka, a),
d = C(S, a),
b = da(a.targets),
e = [],
g = y(c, d),
h;for (h in a) {
g.hasOwnProperty(h) || "targets" === h || e.push({ name: h, offset: g.offset, tweens: ea(a[h], d) });
}a = ia(b, e);return y(c, { children: [], animatables: b, animations: a, duration: R("duration", a, d), delay: R("delay", a, d) });
}function n(a) {
function c() {
return window.Promise && new Promise(function (a) {
return U = a;
});
}function d(a) {
return f.reversed ? f.duration - a : a;
}function b(a) {
for (var b = 0, c = {}, d = f.animations, e = {}; b < d.length;) {
var g = d[b],
h = g.animatable,
m = g.tweens;e.tween = m.filter(function (b) {
return a < b.end;
})[0] || m[m.length - 1];m = Math.min(Math.max(a - e.tween.start - e.tween.delay, 0), e.tween.duration) / e.tween.duration;e.eased = isNaN(m) ? 1 : e.tween.easing(m, e.tween.elasticity);e.round = e.tween.round;m = ca(e.tween.to.numbers.map(function (a) {
return function (b, c) {
c = a.tween.from.numbers[c];b = c + a.eased * (b - c);a.tween.isPath && (b = ba(a.tween.value, b));a.round && (b = Math.round(b * a.round) / a.round);return b;
};
}(e)), e.tween.to.strings);la[g.type](h.target, g.property, m, c, h.id);g.currentValue = m;b++;e = { tween: e.tween, eased: e.eased, round: e.round };
}if (c) for (var l in c) {
G || (G = D(document.body, "transform") ? "transform" : "-webkit-transform"), f.animatables[l].target.style[G] = c[l].join(" ");
}f.currentTime = a;f.progress = a / f.duration * 100;
}function e(a) {
if (f[a]) f[a](f);
}function g() {
f.remaining && !0 !== f.remaining && f.remaining--;
}function h(a) {
var h = f.duration,
k = f.offset,
n = f.delay,
T = f.currentTime,
q = f.reversed,
r = d(a);if (f.children.length) {
var p = f.children;if (r >= f.currentTime) for (var u = 0; u < p.length; u++) {
p[u].seek(r);
} else for (u = p.length; u--;) {
p[u].seek(r);
}
}r >= n && (e("run"), f.began || (f.began = !0, e("begin")));r > k && r < h ? b(r) : (r <= k && 0 !== T && (b(0), q && g()), r >= h && T !== h && (b(h), q || g()));e("update");a >= h && (f.remaining ? (t = m, "alternate" === f.direction && (f.reversed = !f.reversed)) : (f.pause(), f.completed || (f.completed = !0, e("complete"), "Promise" in window && (U(), V = c()))), l = 0);
}a = void 0 === a ? {} : a;var m,
t,
l = 0,
U = null,
V = c(),
f = ja(a);f.reset = function () {
var a = f.direction,
c = f.loop;f.currentTime = 0;f.progress = 0;f.paused = !0;f.began = !1;f.completed = !1;f.reversed = "reverse" === a;f.remaining = "alternate" === a && 1 === c ? 2 : c;b(0);for (a = f.children.length; a--;) {
f.children[a].reset();
}
};f.tick = function (a) {
m = a;t || (t = m);h((l + m - t) * n.speed);
};f.seek = function (a) {
h(d(a));
};
f.pause = function () {
var a = q.indexOf(f);-1 < a && q.splice(a, 1);f.paused = !0;
};f.play = function () {
f.paused && (f.paused = !1, t = 0, l = d(f.currentTime), q.push(f), A || ma());
};f.reverse = function () {
f.reversed = !f.reversed;t = 0;l = d(f.currentTime);
};f.restart = function () {
f.pause();f.reset();f.play();
};f.finished = V;f.reset();f.autoplay && f.play();return f;
}var ka = { 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 },
Z = "translateX translateY translateZ rotate rotateX rotateY rotateZ scale scaleX scaleY scaleZ skewX skewY perspective".split(" "),
G,
g = { arr: function arr(a) {
return Array.isArray(a);
}, obj: function obj(a) {
return -1 < Object.prototype.toString.call(a).indexOf("Object");
}, svg: function svg(a) {
return a instanceof SVGElement;
}, dom: function dom(a) {
return a.nodeType || g.svg(a);
}, str: function str(a) {
return "string" === typeof a;
}, fnc: function fnc(a) {
return "function" === typeof a;
}, und: function und(a) {
return "undefined" === typeof a;
}, hex: function hex(a) {
return (/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(a)
);
},
rgb: function rgb(a) {
return (/^rgb/.test(a)
);
}, hsl: function hsl(a) {
return (/^hsl/.test(a)
);
}, col: function col(a) {
return g.hex(a) || g.rgb(a) || g.hsl(a);
} },
z = 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, e) {
if (0 <= c && 1 >= c && 0 <= b && 1 >= b) {
var g = new Float32Array(11);if (c !== d || b !== e) for (var h = 0; 11 > h; ++h) {
g[h] = a(.1 * h, c, b);
}return function (h) {
if (c === d && b === e) return h;if (0 === h) return 0;if (1 === h) return 1;for (var m = 0, l = 1; 10 !== l && g[l] <= h; ++l) {
m += .1;
}--l;var l = m + (h - g[l]) / (g[l + 1] - g[l]) * .1,
k = 3 * (1 - 3 * b + 3 * c) * l * l + 2 * (3 * b - 6 * c) * l + 3 * c;if (.001 <= k) {
for (m = 0; 4 > m; ++m) {
k = 3 * (1 - 3 * b + 3 * c) * l * l + 2 * (3 * b - 6 * c) * l + 3 * c;if (0 === k) break;var n = a(l, c, b) - h,
l = l - n / k;
}h = l;
} else if (0 === k) h = l;else {
var l = m,
m = m + .1,
f = 0;do {
n = l + (m - l) / 2, k = a(n, c, b) - h, 0 < k ? m = n : l = n;
} while (1e-7 < Math.abs(k) && 10 > ++f);h = n;
}return a(h, d, e);
};
}
};
}(),
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: z(.25, .25, .75, .75) },
e = {},
k;for (k in d) {
e.type = k, d[e.type].forEach(function (a) {
return function (d, e) {
b["ease" + a.type + c[e]] = g.fnc(d) ? d : z.apply($jscomp$this, d);
};
}(e)), e = { type: e.type };
}return b;
}(),
la = { css: function css(a, c, d) {
return a.style[c] = d;
}, attribute: function attribute(a, c, d) {
return a.setAttribute(c, d);
}, object: function object(a, c, d) {
return a[c] = d;
}, transform: function transform(a, c, d, b, e) {
b[e] || (b[e] = []);b[e].push(c + "(" + d + ")");
} },
q = [],
A = 0,
ma = function () {
function a() {
A = requestAnimationFrame(c);
}function c(c) {
var b = q.length;if (b) {
for (var d = 0; d < b;) {
q[d] && q[d].tick(c), d++;
}a();
} else cancelAnimationFrame(A), A = 0;
}return a;
}();n.version = "2.1.0";n.speed = 1;n.running = q;n.remove = function (a) {
a = P(a);for (var c = q.length; c--;) {
for (var d = q[c], b = d.animations, e = b.length; e--;) {
H(a, b[e].animatable.target) && (b.splice(e, 1), b.length || d.pause());
}
}
};n.getValue = K;n.path = function (a, c) {
var d = g.str(a) ? w(a)[0] : a,
b = c || 100;return function (a) {
return { el: d, property: a, totalLength: N(d) * (b / 100) };
};
};n.setDashoffset = function (a) {
var c = N(a);a.setAttribute("stroke-dasharray", c);return c;
};n.bezier = z;n.easings = Q;n.timeline = function (a) {
var c = n(a);c.pause();c.duration = 0;c.add = function (d) {
c.children.forEach(function (a) {
a.began = !0;a.completed = !0;
});x(d).forEach(function (b) {
var d = y(b, C(S, a || {}));d.targets = d.targets || a.targets;b = c.duration;var k = d.offset;d.autoplay = !1;d.offset = g.und(k) ? b : L(k, b);c.began = !0;c.completed = !0;c.seek(d.offset);d = n(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;
};n.random = function (a, c) {
return Math.floor(Math.random() * (c - a + 1)) + a;
};return n;
});