kendo-ui-core
Version:
3 lines (2 loc) • 16.8 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("kendo.core.js")):"function"==typeof define&&define.amd?define(["kendo.core.min"],t):((e="undefined"!=typeof globalThis?globalThis:e||self).kendofx=e.kendofx||{},e.kendofx.js=t())}(this,(function(){return function(e,t){let i=window.kendo,n=i.effects,r=e.each,s=e.extend,o=i.support,a=/matrix3?d?\s*\(.*,\s*([\d\.\-]+)\w*?,\s*([\d\.\-]+)\w*?,\s*([\d\.\-]+)\w*?,\s*([\d\.\-]+)\w*?/i,c=/translatex?$/i,l=/(zoom|fade|expand)(\w+)/,d=/(zoom|fade|expand)/,u=["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"],h=Math.round,p="px",v="auto",m="width",_="height",x="hidden",g="origin",y="abortId",k="overflow",b="position",w="completeCallback",C="transitionend",P="transition",z="transform",E="perspective",T="1500px",H="perspective("+T+")",R={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"}};function D(e){return parseInt(e,10)}function O(e,t){var i,n,r,s,a=[],c={};for(n in t)i=n.toLowerCase(),s=-1!=u.indexOf(i),!o.hasHW3D&&s&&-1==f.indexOf(i)?delete t[n]:(r=t[n],s?a.push(n+"("+r+")"):c[n]=r);return a.length&&(c[z]=a.join(" ")),c}i.directions=R,s(e.fn,{kendoStop:function(e,t){return n.stopQueue(this,e||!1,t||!1)}}),i.toggleClass=function(e,t,i,n){return t&&(t=t.split(" "),i=s({exclusive:"all",duration:400,ease:"ease-out"},i),e.css(P,i.exclusive+" "+i.duration+"ms "+i.ease),setTimeout((function(){e.css(P,"").css(_)}),i.duration),r(t,(function(t,i){e.toggleClass(i,n)}))),e},i.parseEffects=function(e,t){var i={};return"string"==typeof e?r(e.split(" "),(function(e,n){var r=!d.test(n),s=n.replace(l,(function(e,t,i){return t+":"+i.toLowerCase()})).split(":"),o=s[1],a={};s.length>1&&(a.direction=t&&r?R[o].reverse:o),i[s[0]]=a})):r(e,(function(e){var n=this.direction;n&&t&&!d.test(e)&&(this.direction=R[n].reverse),i[e]=this})),i},s(n,{transition:function(t,i,n){let r,o,a=0,c=t.data("keys")||[];n=s({duration:200,ease:"ease-out",complete:null,exclusive:"all"},n);let l=!1,d=function(){l||(l=!0,o&&(clearTimeout(o),o=null),t.removeData(y).dequeue().css(P,"").css(P),n.complete.call(t))};n.duration=e.fx&&e.fx.speeds[n.duration]||n.duration,r=O(0,i),e.merge(c,function(e){var t=[];for(var i in e)t.push(i);return t}(r)),e.hasOwnProperty("uniqueSort")?t.data("keys",e.uniqueSort(c)).height():t.data("keys",e.unique(c)).height(),t.css(P,n.exclusive+" "+n.duration+"ms "+n.ease).css(P),t.css(r).css(z),t.one(C,d),0!==n.duration&&(a=500),o=setTimeout(d,n.duration+a),t.data(y,o),t.data(w,d)},stopQueue:function(e,t,n){var r,s=e.data("keys"),o=!n&&s,a=e.data(w);return o&&(r=i.getComputedStyles(e[0],s)),a&&a(),o&&e.css(r),e.removeData("keys").stop(t)}});var S=i.Class.extend({init:function(e,t){var i=this;i.element=e,i.effects=[],i.options=t,i.restore=[]},run:function(t){let i,r,o,a,c,l,d=this,u=t.length,f=d.element,h=d.options,p=e.Deferred(),v={},m={};for(d.effects=t,p.done(d.complete.bind(d)),f.data("animating",!0),r=0;r<u;r++)for(i=t[r],i.setReverse(h.reverse),i.setOptions(h),d.addRestoreProperties(i.restore),i.prepare(v,m),c=i.children(),o=0,l=c.length;o<l;o++)c[o].duration(h.duration).run();for(var _ in h.effects)s(m,h.effects[_].properties);for(f.is(":visible")||s(v,{display:f.data("olddisplay")||"block"}),h.reset||(a=f.data("targetTransform"),a&&(v=s(a,v))),v=O(0,v),f.css(v).css(z),r=0;r<u;r++)t[r].setup();return h.init&&h.init(),f.data("targetTransform",m),n.animate(f,m,s({},h,{complete:p.resolve})),p.promise()},stop:function(){e(this.element).kendoStop(!0,!0)},addRestoreProperties:function(e){for(var t,i=this.element,n=0,r=e.length;n<r;n++)t=e[n],this.restore.push(t),i.data(t)||i.data(t,i.css(t))},restoreCallback:function(){for(var e=this.element,t=0,i=this.restore.length;t<i;t++){var n=this.restore[t];e.css(n,e.data(n))}},complete:function(){let e=this,t=0,i=e.element,n=e.options,r=e.effects,s=r.length;for(i.removeData("animating").dequeue(),n.hide&&i.data("olddisplay",i.css("display")).hide(),this.restoreCallback();t<s;t++)r[t].teardown();n.completeCallback&&n.completeCallback(i)}});n.promise=function(e,t){var r,s,o=[],a=new S(e,t),c=i.parseEffects(t.effects);for(var l in t.effects=c,c)(r=n[F(l)])&&(s=new r(e,c[l].direction),o.push(s));o[0]?a.run(o):(e.is(":visible")||e.css({display:e.data("olddisplay")||"block"}).css("display"),t.init&&t.init(),e.dequeue(),a.complete())},s(n,{animate:function(e,t,i){let r=!1!==i.transition;delete i.transition,"transition"in n&&r?n.transition(e,t,i):e.animate(function(e){for(var t in e)-1!=u.indexOf(t)&&-1==f.indexOf(t)&&delete e[t];return e}(t),{queue:!1,show:!1,hide:!1,duration:i.duration,complete:i.complete})}}),n.animatedPromise=n.promise;var I=i.Class.extend({init:function(e,t){var i=this;i.element=e,i._direction=t,i.options={},i._additionalEffects=[],i.restore||(i.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 S(e.element,{reverse:e._reverse,duration:e._duration}),i=e._additionalEffects.concat([e]);return t.run(i)},run:function(){if(this._additionalEffects&&this._additionalEffects[0])return this.compositeRun();let t,i,r=this,o=r.element,a=0,c=r.restore,l=c.length,d=e.Deferred(),u={},f={},h=r.children(),p=h.length;for(d.done(r._complete.bind(r)),o.data("animating",!0),a=0;a<l;a++)t=c[a],o.data(t)||o.data(t,o.css(t));for(a=0;a<p;a++)h[a].duration(r._duration).run();return r.prepare(u,f),o.is(":visible")||s(u,{display:o.data("olddisplay")||"block"}),i=o.data("targetTransform"),i&&(u=s(i,u)),u=O(0,u),o.css(u).css(z),r.setup(),o.data("targetTransform",f),n.animate(o,f,{duration:r._duration,complete:d.resolve}),d.promise()},stop:function(){var t=0,i=this.children(),n=i.length;for(t=0;t<n;t++)i[t].stop();return e(this.element).kendoStop(!0,!0),this},restoreCallback:function(){for(var e=this.element,t=0,i=this.restore.length;t<i;t++){var n=this.restore[t];e.css(n,e.data(n))}},_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){s(!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 F(e){return e.charAt(0).toUpperCase()+e.substring(1)}function q(e,t){var i=I.extend(t),s=i.prototype.directions;n[F(e)]=i,n.Element.prototype[e]=function(e,t,n,r){return new i(this.element,e,t,n,r)},r(s,(function(t,r){n.Element.prototype[e+F(r)]=function(e,t,n){return new i(this.element,r,e,t,n)}}))}var A=["left","right","up","down"],V=["in","out"];function M(e,t,i,n){q(e,{directions:V,startValue:function(e){return this._startValue=e,this},endValue:function(e){return this._endValue=e,this},shouldHide:function(){return this._shouldHide},prepare:function(e,r){var s,o,a="out"===this._direction,c=this.element.data(t);s=!(isNaN(c)||c==i)?c:void 0!==this._startValue?this._startValue:a?i:n,o=void 0!==this._endValue?this._endValue:a?n:i,this._reverse?(e[t]=o,r[t]=s):(e[t]=s,r[t]=o),this._shouldHide=r[t]===n}})}q("slideIn",{directions:A,divisor:function(e){return this.options.divisor=e,this},prepare:function(e,t){let n,r=this,s=r.element,o=i._outerWidth,a=i._outerHeight,c=R[r._direction],l=-c.modifier*(c.vertical?a(s):o(s))/(r.options&&r.options.divisor||1)+p;r._reverse&&(n=e,e=t,t=n),e[c.transition]=l,t[c.transition]="0px"}}),q("tile",{directions:A,init:function(e,t,i){I.prototype.init.call(this,e,t),this.options={previous:i}},previousDivisor:function(e){return this.options.previousDivisor=e,this},children:function(){var e=this,t=e._reverse,n=e.options.previous,r=e.options.previousDivisor||1,s=e._direction,o=[i.fx(e.element).slideIn(s).setReverse(t)];return n&&o.push(i.fx(n).slideIn(R[s].reverse).divisor(r).setReverse(!t)),o}}),M("fade","opacity",1,0),M("zoom","scale",1,.01),q("slideMargin",{prepare:function(e,t){var i,n=this,r=n.element,s=n.options,o=r.data(g),a=s.offset,c=n._reverse;c||null!==o||r.data(g,parseFloat(r.css("margin-"+s.axis))),i=r.data(g)||0,t["margin-"+s.axis]=c?i:i+a}}),q("slideTo",{prepare:function(e,t){let i=this,n=i.element,r=i.options.offset.split(","),s=i._reverse;t.translatex=s?0:r[0],t.translatey=s?0:r[1],n.css("left")}}),q("expand",{directions:["horizontal","vertical"],restore:[k],prepare:function(e,t){var i=this,n=i.element,r=i.options,s=i._reverse,o="vertical"===i._direction?_:m,a=n[0].style[o],c=n.data(o),l=parseFloat(c||a),d=h(n.css(o,v)[o]());e.overflow=x,l=r&&r.reset?d||l:l||d,t[o]=(s?0:l)+p,e[o]=(s?l:0)+p,undefined===c&&n.data(o,a)},shouldHide:function(){return this._reverse},teardown:function(){var e=this.element,t="vertical"===this._direction?_:m,i=e.data(t);i!=v&&""!==i||setTimeout((function(){e.css(t,v).css(t)}),0)}});var N={position:"absolute",marginLeft:0,marginTop:0,scale:1};q("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 i=this,r=i.element,o=n.box(r),l=n.box(i.options.target),d=function(e,t){let i=e.css(z);if("none"==i)return"scale"==t?1:0;let n=i.match(new RegExp(t+"\\s*\\(([\\d\\w\\.]+)")),r=0;return n?r=D(n[1]):(n=i.match(a)||[0,0,0,0,0],t=t.toLowerCase(),c.test(t)?r=parseFloat(n[3]/n[2]):"translatey"==t?r=parseFloat(n[4]/n[2]):"scale"==t?r=parseFloat(n[2]):"rotate"==t&&(r=parseFloat(Math.atan2(n[2],n[1])))),r}(r,"scale"),u=n.fillScale(l,o),f=n.transformOrigin(l,o);s(e,N),t.scale=1,r.css(z,"scale(1)").css(z),r.css(z,"scale("+d+")"),e.top=o.top,e.left=o.left,e.transformOrigin=f.x+p+" "+f.y+p,i._reverse?e.scale=u:t.scale=u}});var $={top:"rect(auto auto $size auto)",bottom:"rect($size auto auto auto)",left:"rect(auto $size auto auto)",right:"rect(auto auto auto $size)"},j={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 L(e,t){var n=e[i.directions[t].vertical?_:m]()/2+"px";return $[t].replace("$size",n)}q("turningPage",{directions:A,init:function(e,t,i){I.prototype.init.call(this,e,t),this._container=i},prepare:function(e,t){var n=this,r=n._reverse,s=r?R[n._direction].reverse:n._direction,o=j[s];e.zIndex=1,n._clipInHalf&&(e.clip=L(n._container,i.directions[s].reverse)),e["backface-visibility"]=x,t[z]=H+(r?o.start:o.end),e[z]=H+(r?o.end:o.start)},setup:function(){this._container.append(this.element)},face:function(e){return this._face=e,this},shouldHide:function(){var e=this._reverse,t=this._face;return e&&!t||!e&&t},clipInHalf:function(e){return this._clipInHalf=e,this},temporary:function(){return this.element.addClass("temp-page"),this}}),q("staticPage",{directions:A,init:function(e,t,i){I.prototype.init.call(this,e,t),this._container=i},restore:["clip"],prepare:function(e,t){var i=this,n=i._reverse?R[i._direction].reverse:i._direction;e.clip=L(i._container,n),e.opacity=.999,t.opacity=1},shouldHide:function(){var e=this._reverse,t=this._face;return e&&!t||!e&&t},face:function(e){return this._face=e,this}}),q("pageturn",{directions:["horizontal","vertical"],init:function(e,t,i,n){I.prototype.init.call(this,e,t),this.options={},this.options.face=i,this.options.back=n},children:function(){var e,t=this,n=t.options,r="horizontal"===t._direction?"left":"top",s=i.directions[r].reverse,o=t._reverse,a=n.face.clone(!0).removeAttr("id"),c=n.back.clone(!0).removeAttr("id"),l=t.element;return o&&(e=r,r=s,s=e),[i.fx(n.face).staticPage(r,l).face(!0).setReverse(o),i.fx(n.back).staticPage(s,l).setReverse(o),i.fx(a).turningPage(r,l).face(!0).clipInHalf(!0).temporary().setReverse(o),i.fx(c).turningPage(s,l).clipInHalf(!0).temporary().setReverse(o)]},prepare:function(e,t){e[E]=T,e.transformStyle="preserve-3d",e.opacity=.999,t.opacity=1},teardown:function(){this.element.find(".temp-page").remove()}}),q("flip",{directions:["horizontal","vertical"],init:function(e,t,i,n){I.prototype.init.call(this,e,t),this.options={},this.options.face=i,this.options.back=n},children:function(){var e,t=this,n=t.options,r="horizontal"===t._direction?"left":"top",s=i.directions[r].reverse,o=t._reverse,a=t.element;return o&&(e=r,r=s,s=e),[i.fx(n.face).turningPage(r,a).face(!0).setReverse(o),i.fx(n.back).turningPage(s,a).setReverse(o)]},prepare:function(e){e[E]=T,e.transformStyle="preserve-3d"}});var Q=!o.mobileOS.android;q("replace",{_before:e.noop,_after:e.noop,init:function(t,i,n){I.prototype.init.call(this,t),this._previous=e(i),this._transitionClass=n},duration:function(){throw new 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(".km-touch-scrollbar, .km-actionsheet-wrapper"))){var i=this.container;i.removeClass("k-fx-end").removeClass(this._containerClass()).off(C,this.completeProxy),this._previous.hide().removeClass("k-fx-current"),this.element.removeClass("k-fx-next"),Q&&i.css(k,""),this.isAbsolute||this._both().css(b,""),this.deferred.resolve(),delete this.deferred}},run:function(){if(this._additionalEffects&&this._additionalEffects[0])return this.compositeRun();let t,n=this,r=n.element,s=n._previous,o=r.parents().filter(s.parents()).first(),a=n._both(),c=e.Deferred(),l=r.css(b);return o.length||(o=r.parent()),this.container=o,this.deferred=c,this.isAbsolute="absolute"==l,this.isAbsolute||a.css(b,"absolute"),Q&&(t=o.css(k),o.css(k,"hidden")),r.addClass("k-fx-hidden"),o.addClass(this._containerClass()),this.completeProxy=this.complete.bind(this),o.on(C,this.completeProxy),i.animationFrame((function(){r.removeClass("k-fx-hidden").addClass("k-fx-next"),s.css("display","").addClass("k-fx-current"),n._before(s,r),i.animationFrame((function(){o.removeClass("k-fx-start").addClass("k-fx-end"),n._after(s,r)}))})),c.promise()},stop:function(){this.complete()}});var W=i.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,i.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()):i.animationFrame(e._tickProxy))}}),B=W.extend({init:function(e){s(this,e),W.fn.init.call(this)},done:function(){return this.timePassed()>=this.duration},timePassed:function(){return Math.min(this.duration,new Date-this.startDate)},moveTo:function(e){var t=this,i=t.movable;t.initial=i[t.axis],t.delta=e.location-t.initial,t.duration="number"==typeof e.duration?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))}}});s(B,{easeOutExpo:function(e,t,i,n){return e==n?t+i:i*(1-Math.pow(2,-10*e/n))+t},easeOutBack:function(e,t,i,n,r){return i*((e=e/n-1)*e*(((r=1.70158)+1)*e+r)+1)+t}}),n.Animation=W,n.Transition=B,n.createEffect=q,n.box=function(t){var n=(t=e(t)).offset();return n.width=i._outerWidth(t),n.height=i._outerHeight(t),n},n.transformOrigin=function(e,t){var i=(e.left-t.left)*t.width/(t.width-e.width),n=(e.top-t.top)*t.height/(t.height-e.height);return{x:isNaN(i)?0:i,y:isNaN(n)?0:n}},n.fillScale=function(e,t){return Math.min(e.width/t.width,e.height/t.height)},n.fitScale=function(e,t){return Math.max(e.width/t.width,e.height/t.height)}}(window.kendo.jQuery),kendo}));
//# sourceMappingURL=kendo.fx.min.js.map