UNPKG

es6tween-parser-html

Version:

Executing Tweening via HTML Attribute and JSON Plugin

1 lines 1.79 kB
!function(e,t){"use strict";"function"==typeof define&&define.amd?define(["es6-tween"],function(e){return t(e)}):"undefined"!=typeof module&&module.exports&&require("es6-tween")?module.exports=t(require("es6-tween")):"undefined"!=typeof exports&&exports.TWEEN?t(exports.TWEEN):"undefined"!=typeof window&&window.TWEEN&&t(window.TWEEN)}(0,function(e){"use strict";e.Plugins;var t=e.Tween,n=e.Selector,r=e.Easing;e.isRunning()||e.autoPlay(!0);for(var o={from:"anim-from",to:"anim-to",opts:"anim-opts",onEv:"anim-on",targ:"anim-target"},i=function(e,t){if(-1!==e.indexOf(".")){var n=(e=e.split(".")).shift();return void 0!==t[n]?e.reduce(function(e,t){return void 0!==e[t]?e[t]:e},t[n]):t}return t},f={Infinity:1/0,true:!0,false:!1,NaN:NaN},u=/([A-Za-z]+)/g,a=function(e){return"string"==typeof e&&void 0!==f[e]?f[e]:u.test(e)?-1!==e.indexOf(".")&&-1===e.indexOf(",")?-1!==e.indexOf("In")||-1!==e.indexOf("Out")?i(e,r):e:-1!==e.indexOf(",")?e.split(",").map(a):e:parseFloat(e)},s=function(e,n,r,o,i,f){if(e&&void 0!==e.length)for(var u=0,a=e.length;u<a;u++)s(e[u],n,r,o,void 0!==i.length?i[u]:i,f);else{var d=t.fromTo(e,n,r,o);f?i.addEventListener(f,function(){d.start()}):d.start()}},d=void 0!==document.all?document.all:document.querySelectorAll?document.querySelectorAll("*"):[],l=0,p=d.length;l<p;l++){var c=d[l],g=c,m=c.getAttribute(o.from),v=c.getAttribute(o.to),N=c.getAttribute(o.opts),E=c.getAttribute(o.onEv),O=c.getAttribute(o.targ),x=m?JSON.parse(m):null,w=v?JSON.parse(v):null,y=N?JSON.parse(N):{};if(x||w){for(var A in y)y[A]=a(y[A]);O&&(c=n(O,!0)),s(c,x,w,y,g,E)}}e.parseJSON=function(e){"string"==typeof e&&(e=JSON.parse(e));for(var t in e){var r=e[t],o=r.from,i=r.to,f=r.opts,u=n(t,!0),d=u,l=r.on,p=r.target;if(o||i){for(var c in f)f[c]=a(f[c]);p&&(u=n(p,!0)),s(u,o,i,f,d,l)}}}});