@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
3 lines • 17.2 kB
JavaScript
/* @license */
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`kendo.core.min.js`)):typeof define==`function`&&define.amd?define([`exports`,`kendo.core.min`],t):(e=typeof globalThis<`u`?globalThis:e||self,t((e.kendo=e.kendo||{},e.kendo._globals=e.kendo._globals||{},e.kendo._globals.Fx={}),e.kendo._globals.Core))})(this,function(e,t){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let n={id:`fx`,name:`Effects`,category:`framework`,description:`Required for animation effects in all Kendo UI widgets.`,depends:[`core`]};(function(e,t){let n=window.kendo,r=n.effects,i=e.each,a=e.extend,o=n.support,s=/matrix3?d?\s*\(.*,\s*([\d\.\-]+)\w*?,\s*([\d\.\-]+)\w*?,\s*([\d\.\-]+)\w*?,\s*([\d\.\-]+)\w*?/i,c=/translatex?$/i,l=/(zoom|fade|expand)(\w+)/,u=/(zoom|fade|expand)/,d=[`perspective`,`rotate`,`rotatex`,`rotatey`,`rotatez`,`rotate3d`,`scale`,`scalex`,`scaley`,`scalez`,`scale3d`,`skew`,`skewx`,`skewy`,`translate`,`translatex`,`translatey`,`translatez`,`translate3d`,`matrix`,`matrix3d`],f=[`rotate`,`scale`,`scalex`,`scaley`,`skew`,`skewx`,`skewy`,`translate`,`translatex`,`translatey`,`matrix`],p=Math.round,m=`auto`,h=`width`,g=`height`,_=`hidden`,v=`origin`,y=`abortId`,b=`overflow`,x=`position`,S=`completeCallback`,C=`transitionend`,w=`transition`,T=`transform`,E=`perspective`,D=`1500px`,O=`perspective(`+D+`)`,k={left:{reverse:`right`,property:`left`,transition:`translatex`,vertical:!1,modifier:-1},right:{reverse:`left`,property:`left`,transition:`translatex`,vertical:!1,modifier:1},down:{reverse:`up`,property:`top`,transition:`translatey`,vertical:!0,modifier:1},up:{reverse:`down`,property:`top`,transition:`translatey`,vertical:!0,modifier:-1},top:{reverse:`bottom`},bottom:{reverse:`top`},in:{reverse:`out`,modifier:-1},out:{reverse:`in`,modifier:1},vertical:{reverse:`vertical`},horizontal:{reverse:`horizontal`}};n.directions=k,a(e.fn,{kendoStop:function(e,t){return r.stopQueue(this,e||!1,t||!1)}}),n.toggleClass=function(e,t,n,r){return t&&(t=t.split(` `),n=a({exclusive:`all`,duration:400,ease:`ease-out`},n),e.css(w,n.exclusive+` `+n.duration+`ms `+n.ease),setTimeout(function(){e.css(w,``).css(g)},n.duration),i(t,function(t,n){e.toggleClass(n,r)})),e},n.parseEffects=function(e,t){var n={};return typeof e==`string`?i(e.split(` `),function(e,r){var i=!u.test(r),a=r.replace(l,function(e,t,n){return t+`:`+n.toLowerCase()}).split(`:`),o=a[1],s={};a.length>1&&(s.direction=t&&i?k[o].reverse:o),n[a[0]]=s}):i(e,function(e){var r=this.direction;r&&t&&!u.test(e)&&(this.direction=k[r].reverse),n[e]=this}),n};function A(e){return parseInt(e,10)}function j(e){var t=[];for(var n in e)t.push(n);return t}function M(e){for(var t in e)d.indexOf(t)!=-1&&f.indexOf(t)==-1&&delete e[t];return e}function N(e,t){var n=[],r={},i,a,s,c;for(a in t)i=a.toLowerCase(),c=d.indexOf(i)!=-1,!o.hasHW3D&&c&&f.indexOf(i)==-1?delete t[a]:(s=t[a],c?n.push(a+`(`+s+`)`):r[a]=s);return n.length&&(r[T]=n.join(` `)),r}a(r,{transition:function(t,n,r){let i,o=0,s=t.data(`keys`)||[],c;r=a({duration:200,ease:`ease-out`,complete:null,exclusive:`all`},r);let l=!1,u=function(){l||(l=!0,c&&=(clearTimeout(c),null),t.removeData(y).dequeue().css(w,``).css(w),r.complete.call(t))};r.duration=e.fx&&e.fx.speeds[r.duration]||r.duration,i=N(t,n),e.merge(s,j(i)),e.hasOwnProperty(`uniqueSort`)?t.data(`keys`,e.uniqueSort(s)).height():t.data(`keys`,e.unique(s)).height(),t.css(w,r.exclusive+` `+r.duration+`ms `+r.ease).css(w),t.css(i).css(T),t.one(C,u),r.duration!==0&&(o=500),c=setTimeout(u,r.duration+o),t.data(y,c),t.data(S,u)},stopQueue:function(e,t,r){var i,a=e.data(`keys`),o=!r&&a,s=e.data(S);return o&&(i=n.getComputedStyles(e[0],a)),s&&s(),o&&e.css(i),e.removeData(`keys`).stop(t)}});function P(e,t){let n=e.css(T);if(n==`none`)return t==`scale`?1:0;let r=n.match(RegExp(t+`\\s*\\(([\\d\\w\\.]+)`)),i=0;return r?i=A(r[1]):(r=n.match(s)||[0,0,0,0,0],t=t.toLowerCase(),c.test(t)?i=parseFloat(r[3]/r[2]):t==`translatey`?i=parseFloat(r[4]/r[2]):t==`scale`?i=parseFloat(r[2]):t==`rotate`&&(i=parseFloat(Math.atan2(r[2],r[1])))),i}var F=n.Class.extend({init:function(e,t){var n=this;n.element=e,n.effects=[],n.options=t,n.restore=[]},run:function(t){let n=this,i,o,s,c=t.length,l=n.element,u=n.options,d=e.Deferred(),f={},p={},m,h,g;for(n.effects=t,d.done(n.complete.bind(n)),l.data(`animating`,!0),o=0;o<c;o++)for(i=t[o],i.setReverse(u.reverse),i.setOptions(u),n.addRestoreProperties(i.restore),i.prepare(f,p),h=i.children(),s=0,g=h.length;s<g;s++)h[s].duration(u.duration).run();for(var _ in u.effects)a(p,u.effects[_].properties);for(l.is(`:visible`)||a(f,{display:l.data(`olddisplay`)||`block`}),u.reset||(m=l.data(`targetTransform`),m&&(f=a(m,f))),f=N(l,f),l.css(f).css(T),o=0;o<c;o++)t[o].setup();return u.init&&u.init(),l.data(`targetTransform`,p),r.animate(l,p,a({},u,{complete:d.resolve})),d.promise()},stop:function(){e(this.element).kendoStop(!0,!0)},addRestoreProperties:function(e){for(var t=this.element,n,r=0,i=e.length;r<i;r++)n=e[r],this.restore.push(n),t.data(n)||t.data(n,t.css(n))},restoreCallback:function(){for(var e=this.element,t=0,n=this.restore.length;t<n;t++){var r=this.restore[t];e.css(r,e.data(r))}},complete:function(){let e=this,t=0,n=e.element,r=e.options,i=e.effects,a=i.length;for(n.removeData(`animating`).dequeue(),r.hide&&n.data(`olddisplay`,n.data(`olddisplay`)||n.css(`display`)).hide(),this.restoreCallback();t<a;t++)i[t].teardown();r.completeCallback&&r.completeCallback(n)}});r.promise=function(e,t){var i=[],a,o=new F(e,t),s=n.parseEffects(t.effects),c;for(var l in t.effects=s,s)a=r[L(l)],a&&(c=new a(e,s[l].direction),i.push(c));i[0]?o.run(i):(e.is(`:visible`)||e.css({display:e.data(`olddisplay`)||`block`}).css(`display`),t.init&&t.init(),e.dequeue(),o.complete())},a(r,{animate:function(e,t,n){let i=n.transition!==!1;delete n.transition,`transition`in r&&i?r.transition(e,t,n):e.animate(M(t),{queue:!1,show:!1,hide:!1,duration:n.duration,complete:n.complete})}}),r.animatedPromise=r.promise;var I=n.Class.extend({init:function(e,t){var n=this;n.element=e,n._direction=t,n.options={},n._additionalEffects=[],n.restore||=[]},reverse:function(){return this._reverse=!0,this.run()},play:function(){return this._reverse=!1,this.run()},add:function(e){return this._additionalEffects.push(e),this},direction:function(e){return this._direction=e,this},duration:function(e){return this._duration=e,this},compositeRun:function(){var e=this,t=new F(e.element,{reverse:e._reverse,duration:e._duration}),n=e._additionalEffects.concat([e]);return t.run(n)},run:function(){if(this._additionalEffects&&this._additionalEffects[0])return this.compositeRun();let t=this,n=t.element,i=0,o=t.restore,s=o.length,c,l=e.Deferred(),u={},d={},f,p=t.children(),m=p.length;for(l.done(t._complete.bind(t)),n.data(`animating`,!0),i=0;i<s;i++)c=o[i],n.data(c)||n.data(c,n.css(c));for(i=0;i<m;i++)p[i].duration(t._duration).run();return t.prepare(u,d),n.is(`:visible`)||a(u,{display:n.data(`olddisplay`)||`block`}),f=n.data(`targetTransform`),f&&(u=a(f,u)),u=N(n,u),n.css(u).css(T),t.setup(),n.data(`targetTransform`,d),r.animate(n,d,{duration:t._duration,complete:l.resolve}),l.promise()},stop:function(){var t=0,n=this.children(),r=n.length;for(t=0;t<r;t++)n[t].stop();return e(this.element).kendoStop(!0,!0),this},restoreCallback:function(){for(var e=this.element,t=0,n=this.restore.length;t<n;t++){var r=this.restore[t];e.css(r,e.data(r))}},_complete:function(){let e=this,t=e.element;t.removeData(`animating`).dequeue(),e.restoreCallback(),e.shouldHide()&&t.data(`olddisplay`,t.css(`display`)).hide(),e.teardown()},setOptions:function(e){a(!0,this.options,e)},children:function(){return[]},shouldHide:e.noop,setup:e.noop,prepare:e.noop,teardown:e.noop,directions:[],setReverse:function(e){return this._reverse=e,this}});function L(e){return e.charAt(0).toUpperCase()+e.substring(1)}function R(e,t){var n=I.extend(t),a=n.prototype.directions;r[L(e)]=n,r.Element.prototype[e]=function(e,t,r,i){return new n(this.element,e,t,r,i)},i(a,function(t,i){r.Element.prototype[e+L(i)]=function(e,t,r){return new n(this.element,i,e,t,r)}})}var z=[`left`,`right`,`up`,`down`],B=[`in`,`out`];R(`slideIn`,{directions:z,divisor:function(e){return this.options.divisor=e,this},prepare:function(e,t){let r=this,i,a=r.element,o=n._outerWidth,s=n._outerHeight,c=k[r._direction],l=-c.modifier*(c.vertical?s(a):o(a))/(r.options&&r.options.divisor||1)+`px`;r._reverse&&(i=e,e=t,t=i),e[c.transition]=l,t[c.transition]=`0px`}}),R(`tile`,{directions:z,init:function(e,t,n){I.prototype.init.call(this,e,t),this.options={previous:n}},previousDivisor:function(e){return this.options.previousDivisor=e,this},children:function(){var e=this,t=e._reverse,r=e.options.previous,i=e.options.previousDivisor||1,a=e._direction,o=[n.fx(e.element).slideIn(a).setReverse(t)];return r&&o.push(n.fx(r).slideIn(k[a].reverse).divisor(i).setReverse(!t)),o}});function V(e,t,n,r){R(e,{directions:B,startValue:function(e){return this._startValue=e,this},endValue:function(e){return this._endValue=e,this},shouldHide:function(){return this._shouldHide},prepare:function(e,i){var a=this,o,s,c=this._direction===`out`,l=a.element.data(t);o=isNaN(l)||l==n?this._startValue===void 0?c?n:r:this._startValue:l,s=this._endValue===void 0?c?r:n:this._endValue,this._reverse?(e[t]=s,i[t]=o):(e[t]=o,i[t]=s),a._shouldHide=i[t]===r}})}V(`fade`,`opacity`,1,0),V(`zoom`,`scale`,1,.01),R(`slideMargin`,{prepare:function(e,t){var n=this,r=n.element,i=n.options,a=r.data(v),o=i.offset,s,c=n._reverse;!c&&a===null&&r.data(v,parseFloat(r.css(`margin-`+i.axis))),s=r.data(v)||0,t[`margin-`+i.axis]=c?s:s+o}}),R(`slideTo`,{prepare:function(e,t){let n=this,r=n.element,i=n.options.offset.split(`,`),a=n._reverse;t.translatex=a?0:i[0],t.translatey=a?0:i[1],r.css(`left`)}}),R(`expand`,{directions:[`horizontal`,`vertical`],restore:[b],prepare:function(e,n){var r=this,i=r.element,a=r.options,o=r._reverse,s=r._direction===`vertical`?g:h,c=i[0].style[s],l=i.data(s),u=parseFloat(l||c),d=p(i.css(s,m)[s]());e.overflow=_,u=a&&a.reset?d||u:u||d,n[s]=(o?0:u)+`px`,e[s]=(o?u:0)+`px`,l===t&&i.data(s,c)},shouldHide:function(){return this._reverse},teardown:function(){var e=this,t=e.element,n=e._direction===`vertical`?g:h,r=t.data(n);(r==m||r===``)&&setTimeout(function(){t.css(n,m).css(n)},0)}});var H={position:`absolute`,marginLeft:0,marginTop:0,scale:1};R(`transfer`,{init:function(e,t){this.element=e,this.options={target:t},this.restore=[]},setup:function(){this.element.appendTo(document.body)},prepare:function(e,t){var n=this,i=n.element,o=r.box(i),s=r.box(n.options.target),c=P(i,`scale`),l=r.fillScale(s,o),u=r.transformOrigin(s,o);a(e,H),t.scale=1,i.css(T,`scale(1)`).css(T),i.css(T,`scale(`+c+`)`),e.top=o.top,e.left=o.left,e.transformOrigin=u.x+`px `+u.y+`px`,n._reverse?e.scale=l:t.scale=l}});var U={top:`rect(auto auto $size auto)`,bottom:`rect($size auto auto auto)`,left:`rect(auto $size auto auto)`,right:`rect(auto auto auto $size)`},W={top:{start:`rotatex(0deg)`,end:`rotatex(180deg)`},bottom:{start:`rotatex(-180deg)`,end:`rotatex(0deg)`},left:{start:`rotatey(0deg)`,end:`rotatey(-180deg)`},right:{start:`rotatey(180deg)`,end:`rotatey(0deg)`}};function G(e,t){var r=e[n.directions[t].vertical?g:h]()/2+`px`;return U[t].replace(`$size`,r)}R(`turningPage`,{directions:z,init:function(e,t,n){I.prototype.init.call(this,e,t),this._container=n},prepare:function(e,t){var r=this,i=r._reverse,a=i?k[r._direction].reverse:r._direction,o=W[a];e.zIndex=1,r._clipInHalf&&(e.clip=G(r._container,n.directions[a].reverse)),e[`backface-visibility`]=_,t[T]=O+(i?o.start:o.end),e[T]=O+(i?o.end:o.start)},setup:function(){this._container.append(this.element)},face:function(e){return this._face=e,this},shouldHide:function(){var e=this,t=e._reverse,n=e._face;return t&&!n||!t&&n},clipInHalf:function(e){return this._clipInHalf=e,this},temporary:function(){return this.element.addClass(`temp-page`),this}}),R(`staticPage`,{directions:z,init:function(e,t,n){I.prototype.init.call(this,e,t),this._container=n},restore:[`clip`],prepare:function(e,t){var n=this,r=n._reverse?k[n._direction].reverse:n._direction;e.clip=G(n._container,r),e.opacity=.999,t.opacity=1},shouldHide:function(){var e=this,t=e._reverse,n=e._face;return t&&!n||!t&&n},face:function(e){return this._face=e,this}}),R(`pageturn`,{directions:[`horizontal`,`vertical`],init:function(e,t,n,r){I.prototype.init.call(this,e,t),this.options={},this.options.face=n,this.options.back=r},children:function(){var e=this,t=e.options,r=e._direction===`horizontal`?`left`:`top`,i=n.directions[r].reverse,a=e._reverse,o,s=t.face.clone(!0).removeAttr(`id`),c=t.back.clone(!0).removeAttr(`id`),l=e.element;return a&&(o=r,r=i,i=o),[n.fx(t.face).staticPage(r,l).face(!0).setReverse(a),n.fx(t.back).staticPage(i,l).setReverse(a),n.fx(s).turningPage(r,l).face(!0).clipInHalf(!0).temporary().setReverse(a),n.fx(c).turningPage(i,l).clipInHalf(!0).temporary().setReverse(a)]},prepare:function(e,t){e[E]=D,e.transformStyle=`preserve-3d`,e.opacity=.999,t.opacity=1},teardown:function(){this.element.find(`.temp-page`).remove()}}),R(`flip`,{directions:[`horizontal`,`vertical`],init:function(e,t,n,r){I.prototype.init.call(this,e,t),this.options={},this.options.face=n,this.options.back=r},children:function(){var e=this,t=e.options,r=e._direction===`horizontal`?`left`:`top`,i=n.directions[r].reverse,a=e._reverse,o,s=e.element;return a&&(o=r,r=i,i=o),[n.fx(t.face).turningPage(r,s).face(!0).setReverse(a),n.fx(t.back).turningPage(i,s).setReverse(a)]},prepare:function(e){e[E]=D,e.transformStyle=`preserve-3d`}});var K=!o.mobileOS.android,q=`.km-touch-scrollbar, .km-actionsheet-wrapper`;R(`replace`,{_before:e.noop,_after:e.noop,init:function(t,n,r){I.prototype.init.call(this,t),this._previous=e(n),this._transitionClass=r},duration:function(){throw Error(`The replace effect does not support duration setting; the effect duration may be customized through the transition class rule`)},beforeTransition:function(e){return this._before=e,this},afterTransition:function(e){return this._after=e,this},_both:function(){return e().add(this._element).add(this._previous)},_containerClass:function(){var e=this._direction,t=`k-fx k-fx-start k-fx-`+this._transitionClass;return e&&(t+=` k-fx-`+e),this._reverse&&(t+=` k-fx-reverse`),t},complete:function(t){if(!(!this.deferred||t&&e(t.target).is(q))){var n=this.container;n.removeClass(`k-fx-end`).removeClass(this._containerClass()).off(C,this.completeProxy),this._previous.hide().removeClass(`k-fx-current`),this.element.removeClass(`k-fx-next`),K&&n.css(b,``),this.isAbsolute||this._both().css(x,``),this.deferred.resolve(),delete this.deferred}},run:function(){if(this._additionalEffects&&this._additionalEffects[0])return this.compositeRun();let t=this,r=t.element,i=t._previous,a=r.parents().filter(i.parents()).first(),o=t._both(),s=e.Deferred(),c=r.css(x);return a.length||(a=r.parent()),this.container=a,this.deferred=s,this.isAbsolute=c==`absolute`,this.isAbsolute||o.css(x,`absolute`),K&&(a.css(b),a.css(b,`hidden`)),r.addClass(`k-fx-hidden`),a.addClass(this._containerClass()),this.completeProxy=this.complete.bind(this),a.on(C,this.completeProxy),n.animationFrame(function(){r.removeClass(`k-fx-hidden`).addClass(`k-fx-next`),i.css(`display`,``).addClass(`k-fx-current`),t._before(i,r),n.animationFrame(function(){a.removeClass(`k-fx-start`).addClass(`k-fx-end`),t._after(i,r)})}),s.promise()},stop:function(){this.complete()}});var J=n.Class.extend({init:function(){var e=this;e._tickProxy=e._tick.bind(e),e._started=!1},tick:e.noop,done:e.noop,onEnd:e.noop,onCancel:e.noop,start:function(){this.enabled()&&(this.done()?this.onEnd():(this._started=!0,n.animationFrame(this._tickProxy)))},enabled:function(){return!0},cancel:function(){this._started=!1,this.onCancel()},_tick:function(){var e=this;e._started&&(e.tick(),e.done()?(e._started=!1,e.onEnd()):n.animationFrame(e._tickProxy))}}),Y=J.extend({init:function(e){var t=this;a(t,e),J.fn.init.call(t)},done:function(){return this.timePassed()>=this.duration},timePassed:function(){return Math.min(this.duration,new Date-this.startDate)},moveTo:function(e){var t=this;t.initial=t.movable[t.axis],t.delta=e.location-t.initial,t.duration=typeof e.duration==`number`?e.duration:300,t.tick=t._easeProxy(e.ease),t.startDate=new Date,t.start()},_easeProxy:function(e){var t=this;return function(){t.movable.moveAxis(t.axis,e(t.timePassed(),t.initial,t.delta,t.duration))}}});a(Y,{easeOutExpo:function(e,t,n,r){return e==r?t+n:n*(-(2**(-10*e/r))+1)+t},easeOutBack:function(e,t,n,r,i){return i=1.70158,n*((e=e/r-1)*e*((i+1)*e+i)+1)+t}}),r.Animation=J,r.Transition=Y,r.createEffect=R,r.box=function(t){t=e(t);var r=t.offset();return r.width=n._outerWidth(t),r.height=n._outerHeight(t),r},r.transformOrigin=function(e,t){var n=(e.left-t.left)*t.width/(t.width-e.width),r=(e.top-t.top)*t.height/(t.height-e.height);return{x:isNaN(n)?0:n,y:isNaN(r)?0:r}},r.fillScale=function(e,t){return Math.min(e.width/t.width,e.height/t.height)},r.fitScale=function(e,t){return Math.max(e.width/t.width,e.height/t.height)}})(window.kendo.jQuery);var r=kendo;e.__meta__=n,e.default=r});
//# sourceMappingURL=kendo.fx.min.js.map