UNPKG

@tindtechnologies/universalviewer

Version:

The Universal Viewer is a community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎

2 lines (1 loc) 6.63 kB
import{b as f,c as d,d as m}from"./chunk-MYFOSXPU.js";import{a as v,e as p,f as b,i as g,l as y,o as E}from"./chunk-VNJCZCB4.js";import"./chunk-L67DAW3A.js";var T=function(s,r,t,i){return new(t||(t=Promise))(function(o,e){function a(n){try{c(i.next(n))}catch(h){e(h)}}function l(n){try{c(i.throw(n))}catch(h){e(h)}}function c(n){n.done?o(n.value):new t(function(h){h(n.value)}).then(a,l)}c((i=i.apply(s,r||[])).next())})},S=function(s,r){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},i,o,e,a;return a={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(n){return function(h){return c([n,h])}}function c(n){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,o&&(e=n[0]&2?o.return:n[0]?o.throw||((e=o.return)&&e.call(o),0):o.next)&&!(e=e.call(o,n[1])).done)return e;switch(o=0,e&&(n=[n[0]&2,e.value]),n[0]){case 0:case 1:e=n;break;case 4:return t.label++,{value:n[1],done:!1};case 5:t.label++,o=n[1],n=[0];continue;case 7:n=t.ops.pop(),t.trys.pop();continue;default:if(e=t.trys,!(e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1],e=n;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(n);break}e[2]&&t.ops.pop(),t.trys.pop();continue}n=r.call(s,t)}catch(h){n=[6,h],o=0}finally{i=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}},B=function(){function s(r){v(this,r),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=!0,this.ionItemReorder=g(this,"ionItemReorder",7)}return s.prototype.disabledChanged=function(){this.gesture&&this.gesture.setDisabled(this.disabled)},s.prototype.connectedCallback=function(){return T(this,void 0,void 0,function(){var r,t,i,o=this;return S(this,function(e){switch(e.label){case 0:return r=this.el.closest("ion-content"),r?(t=this,[4,r.getScrollElement()]):[3,2];case 1:t.scrollEl=e.sent(),e.label=2;case 2:return i=this,[4,import("./index-14bae62d-RHNU7WUM.js")];case 3:return i.gesture=e.sent().createGesture({el:this.el,gestureName:"reorder",gesturePriority:110,threshold:0,direction:"y",passive:!1,canStart:function(a){return o.canStart(a)},onStart:function(a){return o.onStart(a)},onMove:function(a){return o.onMove(a)},onEnd:function(){return o.onEnd()}}),this.disabledChanged(),[2]}})})},s.prototype.disconnectedCallback=function(){this.onEnd(),this.gesture&&(this.gesture.destroy(),this.gesture=void 0)},s.prototype.complete=function(r){return Promise.resolve(this.completeSync(r))},s.prototype.canStart=function(r){if(this.selectedItemEl||this.state!==0)return!1;var t=r.event.target,i=t.closest("ion-reorder");if(!i)return!1;var o=k(i,this.el);return o?(r.data=o,!0):!1},s.prototype.onStart=function(r){r.event.preventDefault();var t=this.selectedItemEl=r.data,i=this.cachedHeights;i.length=0;var o=this.el,e=o.children;if(!(!e||e.length===0)){for(var a=0,l=0;l<e.length;l++){var c=e[l];a+=c.offsetHeight,i.push(a),c.$ionIndex=l}var n=o.getBoundingClientRect();if(this.containerTop=n.top,this.containerBottom=n.bottom,this.scrollEl){var h=this.scrollEl.getBoundingClientRect();this.scrollElInitial=this.scrollEl.scrollTop,this.scrollElTop=h.top+w,this.scrollElBottom=h.bottom-w}else this.scrollElInitial=0,this.scrollElTop=0,this.scrollElBottom=0;this.lastToIndex=u(t),this.selectedItemHeight=t.offsetHeight,this.state=1,t.classList.add(x),f()}},s.prototype.onMove=function(r){var t=this.selectedItemEl;if(t){var i=this.autoscroll(r.currentY),o=this.containerTop-i,e=this.containerBottom-i,a=Math.max(o,Math.min(r.currentY,e)),l=i+a-r.startY,c=a-o,n=this.itemIndexForTop(c);if(n!==this.lastToIndex){var h=u(t);this.lastToIndex=n,d(),this.reorderMove(h,n)}t.style.transform="translateY("+l+"px)"}},s.prototype.onEnd=function(){var r=this.selectedItemEl;if(this.state=2,!r){this.state=0;return}var t=this.lastToIndex,i=u(r);t===i?this.completeSync():this.ionItemReorder.emit({from:i,to:t,complete:this.completeSync.bind(this)}),m()},s.prototype.completeSync=function(r){var t=this.selectedItemEl;if(t&&this.state===2){var i=this.el.children,o=i.length,e=this.lastToIndex,a=u(t);if(e!==a&&(!r||r===!0)){var l=a<e?i[e+1]:i[e];this.el.insertBefore(t,l)}Array.isArray(r)&&(r=_(r,a,e));for(var c=0;c<o;c++)i[c].style.transform="";t.style.transition="",t.classList.remove(x),this.selectedItemEl=void 0,this.state=0}return r},s.prototype.itemIndexForTop=function(r){var t=this.cachedHeights,i=0;for(i=0;i<t.length&&!(t[i]>r);i++);return i},s.prototype.reorderMove=function(r,t){for(var i=this.selectedItemHeight,o=this.el.children,e=0;e<o.length;e++){var a=o[e].style,l="";e>r&&e<=t?l="translateY("+-i+"px)":e<r&&e>=t&&(l="translateY("+i+"px)"),a.transform=l}},s.prototype.autoscroll=function(r){if(!this.scrollEl)return 0;var t=0;return r<this.scrollElTop?t=-I:r>this.scrollElBottom&&(t=I),t!==0&&this.scrollEl.scrollBy(0,t),this.scrollEl.scrollTop-this.scrollElInitial},s.prototype.render=function(){var r,t=E(this);return p(b,{class:(r={},r[t]=!0,r["reorder-enabled"]=!this.disabled,r["reorder-list-active"]=this.state!==0,r)})},Object.defineProperty(s.prototype,"el",{get:function(){return y(this)},enumerable:!0,configurable:!0}),Object.defineProperty(s,"watchers",{get:function(){return{disabled:["disabledChanged"]}},enumerable:!0,configurable:!0}),Object.defineProperty(s,"style",{get:function(){return".reorder-list-active>*{-webkit-transition:-webkit-transform .3s;transition:-webkit-transform .3s;transition:transform .3s;transition:transform .3s,-webkit-transform .3s;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,.4);box-shadow:0 0 10px rgba(0,0,0,.4);opacity:.8;z-index:100}.reorder-visible ion-reorder .reorder-icon{-webkit-transform:translateZ(0);transform:translateZ(0)}"},enumerable:!0,configurable:!0}),s}(),u=function(s){return s.$ionIndex},k=function(s,r){for(var t;s;){if(t=s.parentElement,t===r)return s;s=t}},w=60,I=10,x="reorder-selected",_=function(s,r,t){var i=s[r];return s.splice(r,1),s.splice(t,0,i),s.slice()};export{B as ion_reorder_group};