You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
13 KiB
JavaScript

(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){var transition=require("../lib/index");window.transition=transition},{"../lib/index":3}],2:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=exports.easeInOutBounce=exports.easeOutBounce=exports.easeInBounce=exports.easeInOutElastic=exports.easeOutElastic=exports.easeInElastic=exports.easeInOutBack=exports.easeOutBack=exports.easeInBack=exports.easeInOutQuint=exports.easeOutQuint=exports.easeInQuint=exports.easeInOutQuart=exports.easeOutQuart=exports.easeInQuart=exports.easeInOutCubic=exports.easeOutCubic=exports.easeInCubic=exports.easeInOutQuad=exports.easeOutQuad=exports.easeInQuad=exports.easeInOutSine=exports.easeOutSine=exports.easeInSine=exports.linear=void 0;var linear=[[[0,1],"",[.33,.67]],[[1,0],[.67,.33]]];exports.linear=linear;var easeInSine=[[[0,1]],[[.538,.564],[.169,.912],[.88,.196]],[[1,0]]];exports.easeInSine=easeInSine;var easeOutSine=[[[0,1]],[[.444,.448],[.169,.736],[.718,.16]],[[1,0]]];exports.easeOutSine=easeOutSine;var easeInOutSine=[[[0,1]],[[.5,.5],[.2,1],[.8,0]],[[1,0]]];exports.easeInOutSine=easeInOutSine;var easeInQuad=[[[0,1]],[[.55,.584],[.231,.904],[.868,.264]],[[1,0]]];exports.easeInQuad=easeInQuad;var easeOutQuad=[[[0,1]],[[.413,.428],[.065,.816],[.76,.04]],[[1,0]]];exports.easeOutQuad=easeOutQuad;var easeInOutQuad=[[[0,1]],[[.5,.5],[.3,.9],[.7,.1]],[[1,0]]];exports.easeInOutQuad=easeInOutQuad;var easeInCubic=[[[0,1]],[[.679,.688],[.366,.992],[.992,.384]],[[1,0]]];exports.easeInCubic=easeInCubic;var easeOutCubic=[[[0,1]],[[.321,.312],[.008,.616],[.634,.008]],[[1,0]]];exports.easeOutCubic=easeOutCubic;var easeInOutCubic=[[[0,1]],[[.5,.5],[.3,1],[.7,0]],[[1,0]]];exports.easeInOutCubic=easeInOutCubic;var easeInQuart=[[[0,1]],[[.812,.74],[.611,.988],[1.013,.492]],[[1,0]]];exports.easeInQuart=easeInQuart;var easeOutQuart=[[[0,1]],[[.152,.244],[.001,.448],[.285,-.02]],[[1,0]]];exports.easeOutQuart=easeOutQuart;var easeInOutQuart=[[[0,1]],[[.5,.5],[.4,1],[.6,0]],[[1,0]]];exports.easeInOutQuart=easeInOutQuart;var easeInQuint=[[[0,1]],[[.857,.856],[.714,1],[1,.712]],[[1,0]]];exports.easeInQuint=easeInQuint;var easeOutQuint=[[[0,1]],[[.108,.2],[.001,.4],[.214,-.012]],[[1,0]]];exports.easeOutQuint=easeOutQuint;var easeInOutQuint=[[[0,1]],[[.5,.5],[.5,1],[.5,0]],[[1,0]]];exports.easeInOutQuint=easeInOutQuint;var easeInBack=[[[0,1]],[[.667,.896],[.38,1.184],[.955,.616]],[[1,0]]];exports.easeInBack=easeInBack;var easeOutBack=[[[0,1]],[[.335,.028],[.061,.22],[.631,-.18]],[[1,0]]];exports.easeOutBack=easeOutBack;var easeInOutBack=[[[0,1]],[[.5,.5],[.4,1.4],[.6,-.4]],[[1,0]]];exports.easeInOutBack=easeInOutBack;var easeInElastic=[[[0,1]],[[.474,.964],[.382,.988],[.557,.952]],[[.619,1.076],[.565,1.088],[.669,1.08]],[[.77,.916],[.712,.924],[.847,.904]],[[.911,1.304],[.872,1.316],[.961,1.34]],[[1,0]]];exports.easeInElastic=easeInElastic;var easeOutElastic=[[[0,1]],[[.073,-.32],[.034,-.328],[.104,-.344]],[[.191,.092],[.11,.06],[.256,.08]],[[.31,-.076],[.26,-.068],[.357,-.076]],[[.432,.032],[.362,.028],[.683,-.004]],[[1,0]]];exports.easeOutElastic=easeOutElastic;var easeInOutElastic=[[[0,1]],[[.21,.94],[.167,.884],[.252,.98]],[[.299,1.104],[.256,1.092],[.347,1.108]],[[.5,.496],[.451,.672],[.548,.324]],[[.696,-.108],[.652,-.112],[.741,-.124]],[[.805,.064],[.756,.012],[.866,.096]],[[1,0]]];exports.easeInOutElastic=easeInOutElastic;var easeInBounce=[[[0,1]],[[.148,1],[.075,.868],[.193,.848]],[[.326,1],[.276,.836],[.405,.712]],[[.6,1],[.511,.708],[.671,.348]],[[1,0]]];exports.easeInBounce=easeInBounce;var easeOutBounce=[[[0,1]],[[.357,.004],[.27,.592],[.376,.252]],[[.604,-.004],[.548,.312],[.669,.184]],[[.82,0],[.749,.184],[.905,.132]],[[1,0]]];exports.easeOutBounce=easeOutBounce;var easeInOutBounce=[[[0,1]],[[.102,1],[.05,.864],[.117,.86]],[[.216,.996],[.208,.844],[.227,.808]],[[.347,.996],[.343,.8],[.48,.292]],[[.635,.004],[.511,.676],[.656,.208]],[[.787,0],[.76,.2],[.795,.144]],[[.905,-.004],[.899,.164],[.944,.144]],[[1,0]]];exports.easeInOutBounce=easeInOutBounce;var _default=new Map([["linear",linear],["easeInSine",easeInSine],["easeOutSine",easeOutSine],["easeInOutSine",easeInOutSine],["easeInQuad",easeInQuad],["easeOutQuad",easeOutQuad],["easeInOutQuad",easeInOutQuad],["easeInCubic",easeInCubic],["easeOutCubic",easeOutCubic],["easeInOutCubic",easeInOutCubic],["easeInQuart",easeInQuart],["easeOutQuart",easeOutQuart],["easeInOutQuart",easeInOutQuart],["easeInQuint",easeInQuint],["easeOutQuint",easeOutQuint],["easeInOutQuint",easeInOutQuint],["easeInBack",easeInBack],["easeOutBack",easeOutBack],["easeInOutBack",easeInOutBack],["easeInElastic",easeInElastic],["easeOutElastic",easeOutElastic],["easeInOutElastic",easeInOutElastic],["easeInBounce",easeInBounce],["easeOutBounce",easeOutBounce],["easeInOutBounce",easeInOutBounce]]);exports["default"]=_default},{}],3:[function(require,module,exports){"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.transition=transition;exports.injectNewCurve=injectNewCurve;exports["default"]=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _typeof2=_interopRequireDefault(require("@babel/runtime/helpers/typeof"));var _curves=_interopRequireDefault(require("./config/curves"));var defaultTransitionBC="linear";function transition(tBC){var startState=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var endState=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;var frameNum=arguments.length>3&&arguments[3]!==undefined?arguments[3]:30;var deep=arguments.length>4&&arguments[4]!==undefined?arguments[4]:false;if(!checkParams.apply(void 0,arguments))return false;try{var bezierCurve=getBezierCurve(tBC);var frameStateProgress=getFrameStateProgress(bezierCurve,frameNum);if(!deep||typeof endState==="number")return getTransitionState(startState,endState,frameStateProgress);return recursionTransitionState(startState,endState,frameStateProgress)}catch(_unused){console.warn("Transition parameter may be abnormal!");return[endState]}}function checkParams(tBC){var startState=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var endState=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var frameNum=arguments.length>3&&arguments[3]!==undefined?arguments[3]:30;if(!tBC||startState===false||endState===false||!frameNum){console.error("transition: Missing Parameters!");return false}if((0,_typeof2["default"])(startState)!==(0,_typeof2["default"])(endState)){console.error("transition: Inconsistent Status Types!");return false}var stateType=(0,_typeof2["default"])(endState);if(stateType==="string"||stateType==="boolean"||!tBC.length){console.error("transition: Unsupported Data Type of State!");return false}if(!_curves["default"].has(tBC)&&!(tBC instanceof Array)){console.warn("transition: Transition curve not found, default curve will be used!")}return true}function getBezierCurve(tBC){var bezierCurve="";if(_curves["default"].has(tBC)){bezierCurve=_curves["default"].get(tBC)}else if(tBC instanceof Array){bezierCurve=tBC}else{bezierCurve=_curves["default"].get(defaultTransitionBC)}return bezierCurve}function getFrameStateProgress(bezierCurve,frameNum){var tMinus=1/(frameNum-1);var tState=new Array(frameNum).fill(0).map(function(t,i){return i*tMinus});var frameState=tState.map(function(t){return getFrameStateFromT(bezierCurve,t)});return frameState}function getFrameStateFromT(bezierCurve,t){var tBezierCurvePoint=getBezierCurvePointFromT(bezierCurve,t);var bezierCurvePointT=getBezierCurvePointTFromReT(tBezierCurvePoint,t);return getBezierCurveTState(tBezierCurvePoint,bezierCurvePointT)}function getBezierCurvePointFromT(bezierCurve,t){var lastIndex=bezierCurve.length-1;var begin="",end="";bezierCurve.findIndex(function(item,i){if(i===lastIndex)return;begin=item;end=bezierCurve[i+1];var currentMainPointX=begin[0][0];var nextMainPointX=end[0][0];return t>=currentMainPointX&&t<nextMainPointX});var p0=begin[0];var p1=begin[2]||begin[0];var p2=end[1]||end[0];var p3=end[0];return[p0,p1,p2,p3]}function getBezierCurvePointTFromReT(bezierCurve,t){var reBeginX=bezierCurve[0][0];var reEndX=bezierCurve[3][0];var xMinus=reEndX-reBeginX;var tMinus=t-reBeginX;return tMinus/xMinus}function getBezierCurveTState(_ref,t){var _ref2=(0,_slicedToArray2["default"])(_ref,4),_ref2$=(0,_slicedToArray2["default"])(_ref2[0],2),p0=_ref2$[1],_ref2$2=(0,_slicedToArray2["default"])(_ref2[1],2),p1=_ref2$2[1],_ref2$3=(0,_slicedToArray2["default"])(_ref2[2],2),p2=_ref2$3[1],_ref2$4=(0,_slicedToArray2["default"])(_ref2[3],2),p3=_ref2$4[1];var pow=Math.pow;var tMinus=1-t;var result1=p0*pow(tMinus,3);var result2=3*p1*t*pow(tMinus,2);var result3=3*p2*pow(t,2)*tMinus;var result4=p3*pow(t,3);return 1-(result1+result2+result3+result4)}function getTransitionState(begin,end,frameState){var stateType="object";if(typeof begin==="number")stateType="number";if(begin instanceof Array)stateType="array";if(stateType==="number")return getNumberTransitionState(begin,end,frameState);if(stateType==="array")return getArrayTransitionState(begin,end,frameState);if(stateType==="object")return getObjectTransitionState(begin,end,frameState);return frameState.map(function(t){return end})}function getNumberTransitionState(begin,end,frameState){var minus=end-begin;return frameState.map(function(s){return begin+minus*s})}function getArrayTransitionState(begin,end,frameState){var minus=end.map(function(v,i){if(typeof v!=="number")return false;return v-begin[i]});return frameState.map(function(s){return minus.map(function(v,i){if(v===false)return end[i];return begin[i]+v*s})})}function getObjectTransitionState(begin,end,frameState){var keys=Object.keys(end);var beginValue=keys.map(function(k){return begin[k]});var endValue=keys.map(function(k){return end[k]});var arrayState=getArrayTransitionState(beginValue,endValue,frameState);return arrayState.map(function(item){var frameData={};item.forEach(function(v,i){return frameData[keys[i]]=v});return frameData})}function recursionTransitionState(begin,end,frameState){var state=getTransitionState(begin,end,frameState);var _loop=function _loop(key){var bTemp=begin[key];var eTemp=end[key];if((0,_typeof2["default"])(eTemp)!=="object")return"continue";var data=recursionTransitionState(bTemp,eTemp,frameState);state.forEach(function(fs,i){return fs[key]=data[i]})};for(var key in end){var _ret=_loop(key);if(_ret==="continue")continue}return state}function injectNewCurve(key,curve){if(!key||!curve){console.error("InjectNewCurve Missing Parameters!");return}_curves["default"].set(key,curve)}var _default=transition;exports["default"]=_default},{"./config/curves":2,"@babel/runtime/helpers/interopRequireDefault":5,"@babel/runtime/helpers/slicedToArray":8,"@babel/runtime/helpers/typeof":9}],4:[function(require,module,exports){function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}module.exports=_arrayWithHoles},{}],5:[function(require,module,exports){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}module.exports=_interopRequireDefault},{}],6:[function(require,module,exports){function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}module.exports=_iterableToArrayLimit},{}],7:[function(require,module,exports){function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}module.exports=_nonIterableRest},{}],8:[function(require,module,exports){var arrayWithHoles=require("./arrayWithHoles");var iterableToArrayLimit=require("./iterableToArrayLimit");var nonIterableRest=require("./nonIterableRest");function _slicedToArray(arr,i){return arrayWithHoles(arr)||iterableToArrayLimit(arr,i)||nonIterableRest()}module.exports=_slicedToArray},{"./arrayWithHoles":4,"./iterableToArrayLimit":6,"./nonIterableRest":7}],9:[function(require,module,exports){function _typeof2(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof2=function _typeof2(obj){return typeof obj}}else{_typeof2=function _typeof2(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj}}return _typeof2(obj)}function _typeof(obj){if(typeof Symbol==="function"&&_typeof2(Symbol.iterator)==="symbol"){module.exports=_typeof=function _typeof(obj){return _typeof2(obj)}}else{module.exports=_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":_typeof2(obj)}}return _typeof(obj)}module.exports=_typeof},{}]},{},[1]);