@tindtechnologies/universalviewer
Version:
The Universal Viewer is a community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎
10 lines (8 loc) • 11.9 kB
JavaScript
import{a as f,b as A}from"./chunk-JUZN4GG2.js";import{a as d}from"./chunk-RQUDVHEA.js";import{a as k}from"./chunk-V63MGAWK.js";import"./chunk-47FI7OS3.js";import{e as x,f as c,i as S}from"./chunk-4DAZ7WDM.js";import{a as O,e as m,f as C,i as p,l as P,n as y,o as I}from"./chunk-VNJCZCB4.js";import"./chunk-L67DAW3A.js";var b=function(s,t,e,i){return new(e||(e=Promise))(function(o,n){function u(r){try{h(i.next(r))}catch(l){n(l)}}function a(r){try{h(i.throw(r))}catch(l){n(l)}}function h(r){r.done?o(r.value):new e(function(l){l(r.value)}).then(u,a)}h((i=i.apply(s,t||[])).next())})},v=function(s,t){var e={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},i,o,n,u;return u={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(r){return function(l){return h([r,l])}}function h(r){if(i)throw new TypeError("Generator is already executing.");for(;e;)try{if(i=1,o&&(n=r[0]&2?o.return:r[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,r[1])).done)return n;switch(o=0,n&&(r=[r[0]&2,n.value]),r[0]){case 0:case 1:n=r;break;case 4:return e.label++,{value:r[1],done:!1};case 5:e.label++,o=r[1],r=[0];continue;case 7:r=e.ops.pop(),e.trys.pop();continue;default:if(n=e.trys,!(n=n.length>0&&n[n.length-1])&&(r[0]===6||r[0]===2)){e=0;continue}if(r[0]===3&&(!n||r[1]>n[0]&&r[1]<n[3])){e.label=r[1];break}if(r[0]===6&&e.label<n[1]){e.label=n[1],n=r;break}if(n&&e.label<n[2]){e.label=n[2],e.ops.push(r);break}n[2]&&e.ops.pop(),e.trys.pop();continue}r=t.call(s,e)}catch(l){r=[6,l],o=0}finally{i=n=0}if(r[0]&5)throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}},H=function(){function s(t){O(this,t),this.lastOnEnd=0,this.blocker=k.createBlocker({disableScroll:!0}),this.mode=I(this),this.isAnimating=!1,this._isOpen=!1,this.isPaneVisible=!1,this.isEndSide=!1,this.disabled=!1,this.side="start",this.swipeGesture=!0,this.maxEdgeStart=50,this.ionWillOpen=p(this,"ionWillOpen",7),this.ionWillClose=p(this,"ionWillClose",7),this.ionDidOpen=p(this,"ionDidOpen",7),this.ionDidClose=p(this,"ionDidClose",7),this.ionMenuChange=p(this,"ionMenuChange",7)}return s.prototype.typeChanged=function(t,e){var i=this.contentEl;i&&(e!==void 0&&i.classList.remove("menu-content-"+e),i.classList.add("menu-content-"+t),i.removeAttribute("style")),this.menuInnerEl&&this.menuInnerEl.removeAttribute("style"),this.animation=void 0},s.prototype.disabledChanged=function(){this.updateState(),this.ionMenuChange.emit({disabled:this.disabled,open:this._isOpen})},s.prototype.sideChanged=function(){this.isEndSide=S(this.side)},s.prototype.swipeGestureChanged=function(){this.updateState()},s.prototype.connectedCallback=function(){return b(this,void 0,void 0,function(){var t,e,i,o,n=this;return v(this,function(u){switch(u.label){case 0:return this.type===void 0&&(this.type=y.get("menuType",this.mode==="ios"?"reveal":"overlay")),t=this.el,e=t.parentNode,this.contentId===void 0&&console.warn(`[DEPRECATED][ion-menu] Using the [main] attribute is deprecated, please use the "contentId" property instead:
BEFORE:
<ion-menu>...</ion-menu>
<div main>...</div>
AFTER:
<ion-menu contentId="my-content"></ion-menu>
<div id="my-content">...</div>
`),i=this.contentId!==void 0?document.getElementById(this.contentId):e&&e.querySelector&&e.querySelector("[main]"),!i||!i.tagName?(console.error('Menu: must have a "content" element to listen for drag events on.'),[2]):(this.contentEl=i,i.classList.add("menu-content"),this.typeChanged(this.type,void 0),this.sideChanged(),d._register(this),o=this,[4,import("./index-14bae62d-RHNU7WUM.js")]);case 1:return o.gesture=u.sent().createGesture({el:document,gestureName:"menu-swipe",gesturePriority:30,threshold:10,canStart:function(a){return n.canStart(a)},onWillStart:function(){return n.onWillStart()},onStart:function(){return n.onStart()},onMove:function(a){return n.onMove(a)},onEnd:function(a){return n.onEnd(a)}}),this.updateState(),[2]}})})},s.prototype.componentDidLoad=function(){return b(this,void 0,void 0,function(){return v(this,function(t){return this.ionMenuChange.emit({disabled:this.disabled,open:this._isOpen}),this.updateState(),[2]})})},s.prototype.disconnectedCallback=function(){this.blocker.destroy(),d._unregister(this),this.animation&&this.animation.destroy(),this.gesture&&(this.gesture.destroy(),this.gesture=void 0),this.animation=void 0,this.contentEl=this.backdropEl=this.menuInnerEl=void 0},s.prototype.onSplitPaneChanged=function(t){this.isPaneVisible=t.detail.isPane(this.el),this.updateState()},s.prototype.onBackdropClick=function(t){if(this._isOpen&&this.lastOnEnd<t.timeStamp-100){var e=t.composedPath?!t.composedPath().includes(this.menuInnerEl):!1;e&&(t.preventDefault(),t.stopPropagation(),this.close())}},s.prototype.isOpen=function(){return Promise.resolve(this._isOpen)},s.prototype.isActive=function(){return Promise.resolve(this._isActive())},s.prototype.open=function(t){return t===void 0&&(t=!0),this.setOpen(!0,t)},s.prototype.close=function(t){return t===void 0&&(t=!0),this.setOpen(!1,t)},s.prototype.toggle=function(t){return t===void 0&&(t=!0),this.setOpen(!this._isOpen,t)},s.prototype.setOpen=function(t,e){return e===void 0&&(e=!0),d._setOpen(this,t,e)},s.prototype._setOpen=function(t,e){return e===void 0&&(e=!0),b(this,void 0,void 0,function(){return v(this,function(i){switch(i.label){case 0:return!this._isActive()||this.isAnimating||t===this._isOpen?[2,!1]:(this.beforeAnimation(t),[4,this.loadAnimation()]);case 1:return i.sent(),[4,this.startAnimation(t,e)];case 2:return i.sent(),this.afterAnimation(t),[2,!0]}})})},s.prototype.loadAnimation=function(){return b(this,void 0,void 0,function(){var t,e;return v(this,function(i){switch(i.label){case 0:return t=this.menuInnerEl.offsetWidth,t===this.width&&this.animation!==void 0?[2]:(this.width=t,this.animation&&(this.animation.destroy(),this.animation=void 0),e=this,[4,d._createAnimation(this.type,this)]);case 1:return e.animation=i.sent(),y.getBoolean("animated",!0)||this.animation.duration(0),this.animation.fill("both"),[2]}})})},s.prototype.startAnimation=function(t,e){return b(this,void 0,void 0,function(){var i,o;return v(this,function(n){switch(n.label){case 0:return i=!t,o=this.animation.direction(i?"reverse":"normal").easing(i?"cubic-bezier(0.4, 0.0, 0.6, 1)":"cubic-bezier(0.0, 0.0, 0.2, 1)"),e?[4,o.playAsync()]:[3,2];case 1:return n.sent(),[3,3];case 2:o.playSync(),n.label=3;case 3:return[2]}})})},s.prototype._isActive=function(){return!this.disabled&&!this.isPaneVisible},s.prototype.canSwipe=function(){return this.swipeGesture&&!this.isAnimating&&this._isActive()},s.prototype.canStart=function(t){return this.canSwipe()?this._isOpen?!0:d._getOpenSync()?!1:N(window,t.currentX,this.isEndSide,this.maxEdgeStart):!1},s.prototype.onWillStart=function(){return this.beforeAnimation(!this._isOpen),this.loadAnimation()},s.prototype.onStart=function(){if(!this.isAnimating||!this.animation){c(!1,"isAnimating has to be true");return}this.animation.direction(this._isOpen?"reverse":"normal").progressStart(!0)},s.prototype.onMove=function(t){if(!this.isAnimating||!this.animation){c(!1,"isAnimating has to be true");return}var e=M(t.deltaX,this._isOpen,this.isEndSide),i=e/this.width;this.animation.progressStep(i)},s.prototype.onEnd=function(t){var e=this;if(!this.isAnimating||!this.animation){c(!1,"isAnimating has to be true");return}var i=this._isOpen,o=this.isEndSide,n=M(t.deltaX,i,o),u=this.width,a=n/u,h=t.velocityX,r=u/2,l=h>=0&&(h>.2||t.deltaX>r),w=h<=0&&(h<-.2||t.deltaX<-r),g=i?o?l:w:o?w:l,E=!i&&g;i&&!g&&(E=!0),this.lastOnEnd=t.timeStamp;var _=g?.001:-.001,G=a<=0?.01:a;_+=A(new f(0,0),new f(.4,0),new f(.6,1),new f(1,1),x(0,G,1)),this.animation.easing("cubic-bezier(0.4, 0.0, 0.6, 1)").onFinish(function(){return e.afterAnimation(E)},{oneTimeCallback:!0}).progressEnd(g?1:0,_,300)},s.prototype.beforeAnimation=function(t){c(!this.isAnimating,"_before() should not be called while animating"),this.el.classList.add(D),this.backdropEl&&this.backdropEl.classList.add(L),this.blocker.block(),this.isAnimating=!0,t?this.ionWillOpen.emit():this.ionWillClose.emit()},s.prototype.afterAnimation=function(t){c(this.isAnimating,"_before() should be called while animating"),this._isOpen=t,this.isAnimating=!1,this._isOpen||this.blocker.unblock(),t?(this.contentEl&&this.contentEl.classList.add(W),this.ionDidOpen.emit()):(this.el.classList.remove(D),this.contentEl&&this.contentEl.classList.remove(W),this.backdropEl&&this.backdropEl.classList.remove(L),this.animation&&this.animation.stop(),this.ionDidClose.emit())},s.prototype.updateState=function(){var t=this._isActive();this.gesture&&this.gesture.setDisabled(!t||!this.swipeGesture),!t&&this._isOpen&&this.forceClosing(),this.disabled||d._setActiveMenu(this),c(!this.isAnimating,"can not be animating")},s.prototype.forceClosing=function(){c(this._isOpen,"menu cannot be closed"),this.isAnimating=!0;var t=this.animation.direction("reverse");t.playSync(),this.afterAnimation(!1)},s.prototype.render=function(){var t,e=this,i=this,o=i.isEndSide,n=i.type,u=i.disabled,a=i.mode,h=i.isPaneVisible;return m(C,{role:"navigation",class:(t={},t[a]=!0,t["menu-type-"+n]=!0,t["menu-enabled"]=!u,t["menu-side-end"]=o,t["menu-side-start"]=!o,t["menu-pane-visible"]=h,t)},m("div",{class:"menu-inner",ref:function(r){return e.menuInnerEl=r}},m("slot",null)),m("ion-backdrop",{ref:function(r){return e.backdropEl=r},class:"menu-backdrop",tappable:!1,stopPropagation:!1}))},Object.defineProperty(s.prototype,"el",{get:function(){return P(this)},enumerable:!0,configurable:!0}),Object.defineProperty(s,"watchers",{get:function(){return{type:["typeChanged"],disabled:["disabledChanged"],side:["sideChanged"],swipeGesture:["swipeGestureChanged"]}},enumerable:!0,configurable:!0}),Object.defineProperty(s,"style",{get:function(){return":host{--width:304px;--min-width:auto;--max-width:auto;--height:100%;--min-height:auto;--max-height:auto;--background:var(--ion-background-color,#fff);left:0;right:0;top:0;bottom:0;display:none;position:absolute;contain:strict}:host(.show-menu){display:block}.menu-inner{left:0;right:auto;top:0;bottom:0;-webkit-transform:translate3d(-9999px,0,0);transform:translate3d(-9999px,0,0);display:-ms-flexbox;display:flex;position:absolute;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:justify;justify-content:space-between;width:var(--width);min-width:var(--min-width);max-width:var(--max-width);height:var(--height);min-height:var(--min-height);max-height:var(--max-height);background:var(--background);contain:strict}:host-context([dir=rtl]) .menu-inner,[dir=rtl] .menu-inner{left:unset;right:unset;left:auto;right:0;-webkit-transform:translate3d(calc(-1 * -9999px),0,0);transform:translate3d(calc(-1 * -9999px),0,0)}:host(.menu-side-start) .menu-inner{--ion-safe-area-right:0px;right:auto;left:0}:host(.menu-side-end) .menu-inner{--ion-safe-area-left:0px;right:0;left:auto}ion-backdrop{display:none;opacity:.01;z-index:-1}@media (max-width:340px){.menu-inner{--width:264px}}:host(.menu-type-reveal){z-index:0}:host(.menu-type-reveal.show-menu) .menu-inner{-webkit-transform:translateZ(0);transform:translateZ(0)}:host(.menu-type-overlay){z-index:1000}:host(.menu-type-overlay) .show-backdrop{display:block;cursor:pointer}:host(.menu-pane-visible) .menu-inner{left:0;right:0;width:auto;-webkit-transform:none!important;transform:none!important;-webkit-box-shadow:none!important;box-shadow:none!important}:host(.menu-pane-visible) ion-backdrop{display:hidden!important}:host(.menu-type-overlay) .menu-inner{-webkit-box-shadow:0 2px 22px 0 rgba(0,0,0,.09),4px 0 16px 0 rgba(0,0,0,.18);box-shadow:0 2px 22px 0 rgba(0,0,0,.09),4px 0 16px 0 rgba(0,0,0,.18)}"},enumerable:!0,configurable:!0}),s}(),M=function(s,t,e){return Math.max(0,t!==e?-s:s)},N=function(s,t,e,i){return e?t>=s.innerWidth-i:t<=i},D="show-menu",L="show-backdrop",W="menu-content-open";export{H as ion_menu};