UNPKG

@ionic/core

Version:
4 lines 8.62 kB
var __awaiter=this&&this.__awaiter||function(t,r,e,i){function n(t){return t instanceof e?t:new e((function(r){r(t)}))}return new(e||(e=Promise))((function(e,s){function o(t){try{c(i.next(t))}catch(t){s(t)}}function a(t){try{c(i["throw"](t))}catch(t){s(t)}}function c(t){t.done?e(t.value):n(t.value).then(o,a)}c((i=i.apply(t,r||[])).next())}))};var __generator=this&&this.__generator||function(t,r){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(t){return function(r){return c([t,r])}}function c(a){if(i)throw new TypeError("Generator is already executing.");while(o&&(o=0,a[0]&&(e=0)),e)try{if(i=1,n&&(s=a[0]&2?n["return"]:a[0]?n["throw"]||((s=n["return"])&&s.call(n),0):n.next)&&!(s=s.call(n,a[1])).done)return s;if(n=0,s)a=[a[0]&2,s.value];switch(a[0]){case 0:case 1:s=a;break;case 4:e.label++;return{value:a[1],done:false};case 5:e.label++;n=a[1];a=[0];continue;case 7:a=e.ops.pop();e.trys.pop();continue;default:if(!(s=e.trys,s=s.length>0&&s[s.length-1])&&(a[0]===6||a[0]===2)){e=0;continue}if(a[0]===3&&(!s||a[1]>s[0]&&a[1]<s[3])){e.label=a[1];break}if(a[0]===6&&e.label<s[1]){e.label=s[1];s=a;break}if(s&&e.label<s[2]){e.label=s[2];e.ops.push(a);break}if(s[2])e.ops.pop();e.trys.pop();continue}a=r.call(t,e)}catch(t){a=[6,t];n=0}finally{i=s=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}}; /*! * (C) Ionic http://ionicframework.com - MIT License */System.register(["./p-f11a9436.system.js","./p-1e955a45.system.js","./p-f201b53a.system.js","./p-4b07c60a.system.js","./p-455cd7cc.system.js","./p-a93873de.system.js","./p-0ec5b7cf.system.js","./p-8985cdb6.system.js","./p-792919fd.system.js"],(function(t,r){"use strict";var e,i,n,s,o,a,c,u,f,h,d,l,v,b;return{setters:[function(t){e=t.r;i=t.h;n=t.e;s=t.f;o=t.c},function(t){a=t.j;c=t.k},function(t){u=t.b},function(t){f=t.f;h=t.g},function(t){d=t.r},function(t){l=t.a;v=t.b;b=t.h},function(){},function(){},function(){}],execute:function(){var m=":host([slot]){display:none;line-height:0;z-index:100}.reorder-icon{display:block}::slotted(ion-icon){font-size:dynamic-font(16px)}.reorder-icon{font-size:2.125rem;opacity:0.4}";var y=m;var p=":host([slot]){display:none;line-height:0;z-index:100}.reorder-icon{display:block}::slotted(ion-icon){font-size:dynamic-font(16px)}.reorder-icon{font-size:1.9375rem;opacity:0.3}";var w=p;var g=t("ion_reorder",function(){function t(t){e(this,t)}t.prototype.onClick=function(t){var r=this.el.closest("ion-reorder-group");t.preventDefault();if(!r||!r.disabled){t.stopImmediatePropagation()}};t.prototype.render=function(){var t=u(this);var r=t==="ios"?a:c;return i(n,{key:"17adf3165f4e09283d5d6434d7cd47bd23519048",class:t},i("slot",{key:"d00d1cd97c689fc5c7b7175a2051cf697fe22871"},i("ion-icon",{key:"eec219aebde6083de98358be3e75965c5a5dc3d0",icon:r,lazy:false,class:"reorder-icon",part:"icon","aria-hidden":"true"})))};Object.defineProperty(t.prototype,"el",{get:function(){return s(this)},enumerable:false,configurable:true});return t}());g.style={ios:y,md:w};var k=".reorder-list-active>*{display:block;-webkit-transition:-webkit-transform 300ms;transition:-webkit-transform 300ms;transition:transform 300ms;transition:transform 300ms, -webkit-transform 300ms;will-change:transform}.reorder-enabled{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.reorder-enabled ion-reorder{display:block;cursor:-webkit-grab;cursor:grab;pointer-events:all;-ms-touch-action:none;touch-action:none}.reorder-selected,.reorder-selected ion-reorder{cursor:-webkit-grabbing;cursor:grabbing}.reorder-selected{position:relative;-webkit-transition:none !important;transition:none !important;-webkit-box-shadow:0 0 10px rgba(0, 0, 0, 0.4);box-shadow:0 0 10px rgba(0, 0, 0, 0.4);opacity:0.8;z-index:100}.reorder-visible ion-reorder .reorder-icon{-webkit-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0)}";var x=k;var j=t("ion_reorder_group",function(){function t(t){e(this,t);this.ionItemReorder=o(this,"ionItemReorder",7);this.lastToIndex=-1;this.cachedHeights=[];this.scrollElTop=0;this.scrollElBottom=0;this.scrollElInitial=0;this.containerTop=0;this.containerBottom=0;this.state=0;this.disabled=true}t.prototype.disabledChanged=function(){if(this.gesture){this.gesture.enable(!this.disabled)}};t.prototype.connectedCallback=function(){return __awaiter(this,void 0,void 0,(function(){var t,e,i;var n=this;return __generator(this,(function(s){switch(s.label){case 0:t=f(this.el);if(!t)return[3,2];e=this;return[4,h(t)];case 1:e.scrollEl=s.sent();s.label=2;case 2:i=this;return[4,r.import("./p-3e1e14d9.system.js")];case 3:i.gesture=s.sent().createGesture({el:this.el,gestureName:"reorder",gesturePriority:110,threshold:0,direction:"y",passive:false,canStart:function(t){return n.canStart(t)},onStart:function(t){return n.onStart(t)},onMove:function(t){return n.onMove(t)},onEnd:function(){return n.onEnd()}});this.disabledChanged();return[2]}}))}))};t.prototype.disconnectedCallback=function(){this.onEnd();if(this.gesture){this.gesture.destroy();this.gesture=undefined}};t.prototype.complete=function(t){return Promise.resolve(this.completeReorder(t))};t.prototype.canStart=function(t){if(this.selectedItemEl||this.state!==0){return false}var r=t.event.target;var e=r.closest("ion-reorder");if(!e){return false}var i=z(e,this.el);if(!i){return false}t.data=i;return true};t.prototype.onStart=function(t){t.event.preventDefault();var r=this.selectedItemEl=t.data;var e=this.cachedHeights;e.length=0;var i=this.el;var n=i.children;if(!n||n.length===0){return}var s=0;for(var o=0;o<n.length;o++){var a=n[o];s+=a.offsetHeight;e.push(s);a.$ionIndex=o}var c=i.getBoundingClientRect();this.containerTop=c.top;this.containerBottom=c.bottom;if(this.scrollEl){var u=this.scrollEl.getBoundingClientRect();this.scrollElInitial=this.scrollEl.scrollTop;this.scrollElTop=u.top+S;this.scrollElBottom=u.bottom-S}else{this.scrollElInitial=0;this.scrollElTop=0;this.scrollElBottom=0}this.lastToIndex=_(r);this.selectedItemHeight=r.offsetHeight;this.state=1;r.classList.add(O);l()};t.prototype.onMove=function(t){var r=this.selectedItemEl;if(!r){return}var e=this.autoscroll(t.currentY);var i=this.containerTop-e;var n=this.containerBottom-e;var s=Math.max(i,Math.min(t.currentY,n));var o=e+s-t.startY;var a=s-i;var c=this.itemIndexForTop(a);if(c!==this.lastToIndex){var u=_(r);this.lastToIndex=c;v();this.reorderMove(u,c)}r.style.transform="translateY(".concat(o,"px)")};t.prototype.onEnd=function(){var t=this.selectedItemEl;this.state=2;if(!t){this.state=0;return}var r=this.lastToIndex;var e=_(t);if(r===e){this.completeReorder()}else{this.ionItemReorder.emit({from:e,to:r,complete:this.completeReorder.bind(this)})}b()};t.prototype.completeReorder=function(t){var r=this;var e=this.selectedItemEl;if(e&&this.state===2){var i=this.el.children;var n=i.length;var s=this.lastToIndex;var o=_(e);d((function(){if(s!==o&&(t===undefined||t===true)){var a=o<s?i[s+1]:i[s];r.el.insertBefore(e,a)}for(var c=0;c<n;c++){i[c].style["transform"]=""}}));if(Array.isArray(t)){t=P(t,o,s)}e.style.transition="";e.classList.remove(O);this.selectedItemEl=undefined;this.state=0}return t};t.prototype.itemIndexForTop=function(t){var r=this.cachedHeights;for(var e=0;e<r.length;e++){if(r[e]>t){return e}}return r.length-1};t.prototype.reorderMove=function(t,r){var e=this.selectedItemHeight;var i=this.el.children;for(var n=0;n<i.length;n++){var s=i[n].style;var o="";if(n>t&&n<=r){o="translateY(".concat(-e,"px)")}else if(n<t&&n>=r){o="translateY(".concat(e,"px)")}s["transform"]=o}};t.prototype.autoscroll=function(t){if(!this.scrollEl){return 0}var r=0;if(t<this.scrollElTop){r=-M}else if(t>this.scrollElBottom){r=M}if(r!==0){this.scrollEl.scrollBy(0,r)}return this.scrollEl.scrollTop-this.scrollElInitial};t.prototype.render=function(){var t;var r=u(this);return i(n,{key:"6ca009dd65302a914d459aec638e62977440db20",class:(t={},t[r]=true,t["reorder-enabled"]=!this.disabled,t["reorder-list-active"]=this.state!==0,t)})};Object.defineProperty(t.prototype,"el",{get:function(){return s(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{disabled:["disabledChanged"]}},enumerable:false,configurable:true});return t}());var _=function(t){return t["$ionIndex"]};var z=function(t,r){var e;while(t){e=t.parentElement;if(e===r){return t}t=e}return undefined};var S=60;var M=10;var O="reorder-selected";var P=function(t,r,e){var i=t[r];t.splice(r,1);t.splice(e,0,i);return t.slice()};j.style=x}}}));