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) 9.67 kB
import{a as y,b as w}from"./chunk-Y2TXPXZV.js";import{a as S,b as m,e as h,f as A,i as d,l as k,m as T,n as x,o as b}from"./chunk-VNJCZCB4.js";import"./chunk-L67DAW3A.js";var E=function(t,e,o,l){return new(o||(o=Promise))(function(n,i){function f(r){try{a(l.next(r))}catch(c){i(c)}}function s(r){try{a(l.throw(r))}catch(c){i(c)}}function a(r){r.done?n(r.value):new o(function(c){c(r.value)}).then(f,s)}a((l=l.apply(t,e||[])).next())})},M=function(t,e){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},l,n,i,f;return f={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(f[Symbol.iterator]=function(){return this}),f;function s(r){return function(c){return a([r,c])}}function a(r){if(l)throw new TypeError("Generator is already executing.");for(;o;)try{if(l=1,n&&(i=r[0]&2?n.return:r[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,r[1])).done)return i;switch(n=0,i&&(r=[r[0]&2,i.value]),r[0]){case 0:case 1:i=r;break;case 4:return o.label++,{value:r[1],done:!1};case 5:o.label++,n=r[1],r=[0];continue;case 7:r=o.ops.pop(),o.trys.pop();continue;default:if(i=o.trys,!(i=i.length>0&&i[i.length-1])&&(r[0]===6||r[0]===2)){o=0;continue}if(r[0]===3&&(!i||r[1]>i[0]&&r[1]<i[3])){o.label=r[1];break}if(r[0]===6&&o.label<i[1]){o.label=i[1],i=r;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(r);break}i[2]&&o.ops.pop(),o.trys.pop();continue}r=e.call(t,o)}catch(c){r=[6,c],n=0}finally{l=i=0}if(r[0]&5)throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}},X=function(){function t(e){S(this,e),this.isScrolling=!1,this.lastScroll=0,this.queued=!1,this.cTop=-1,this.cBottom=-1,this.mode=b(this),this.detail={scrollTop:0,scrollLeft:0,type:"scroll",event:void 0,startX:0,startY:0,startTimeStamp:0,currentX:0,currentY:0,velocityX:0,velocityY:0,deltaX:0,deltaY:0,timeStamp:0,data:void 0,isScrolling:!0},this.fullscreen=!1,this.scrollX=!1,this.scrollY=!0,this.scrollEvents=!1,this.ionScrollStart=d(this,"ionScrollStart",7),this.ionScroll=d(this,"ionScroll",7),this.ionScrollEnd=d(this,"ionScrollEnd",7)}return t.prototype.disconnectedCallback=function(){this.onScrollEnd()},t.prototype.componentDidLoad=function(){this.resize()},t.prototype.onClick=function(e){this.isScrolling&&(e.preventDefault(),e.stopPropagation())},t.prototype.shouldForceOverscroll=function(){var e=this,o=e.forceOverscroll,l=e.mode;return o===void 0?l==="ios"&&T("ios"):o},t.prototype.resize=function(){this.fullscreen?m(this.readDimensions.bind(this)):(this.cTop!==0||this.cBottom!==0)&&(this.cTop=this.cBottom=0,this.el.forceUpdate())},t.prototype.readDimensions=function(){var e=G(this.el),o=Math.max(this.el.offsetTop,0),l=Math.max(e.offsetHeight-o-this.el.offsetHeight,0),n=o!==this.cTop||l!==this.cBottom;n&&(this.cTop=o,this.cBottom=l,this.el.forceUpdate())},t.prototype.onScroll=function(e){var o=this,l=Date.now(),n=!this.isScrolling;this.lastScroll=l,n&&this.onScrollStart(),!this.queued&&this.scrollEvents&&(this.queued=!0,m(function(i){o.queued=!1,o.detail.event=e,I(o.detail,o.scrollEl,i,n),o.ionScroll.emit(o.detail)}))},t.prototype.getScrollElement=function(){return Promise.resolve(this.scrollEl)},t.prototype.scrollToTop=function(e){return e===void 0&&(e=0),this.scrollToPoint(void 0,0,e)},t.prototype.scrollToBottom=function(e){e===void 0&&(e=0);var o=this.scrollEl.scrollHeight-this.scrollEl.clientHeight;return this.scrollToPoint(void 0,o,e)},t.prototype.scrollByPoint=function(e,o,l){return this.scrollToPoint(e+this.scrollEl.scrollLeft,o+this.scrollEl.scrollTop,l)},t.prototype.scrollToPoint=function(e,o,l){return l===void 0&&(l=0),E(this,void 0,void 0,function(){var n,i,f,s,a,r,c,p,v;return M(this,function(j){return n=this.scrollEl,l<32?(o!=null&&(n.scrollTop=o),e!=null&&(n.scrollLeft=e),[2]):(f=0,s=new Promise(function(u){return i=u}),a=n.scrollTop,r=n.scrollLeft,c=o!=null?o-a:0,p=e!=null?e-r:0,v=function(u){var Y=Math.min(1,(u-f)/l)-1,g=Math.pow(Y,3)+1;c!==0&&(n.scrollTop=Math.floor(g*c+a)),p!==0&&(n.scrollLeft=Math.floor(g*p+r)),g<1?requestAnimationFrame(v):i()},requestAnimationFrame(function(u){f=u,v(u)}),[2,s])})})},t.prototype.onScrollStart=function(){var e=this;this.isScrolling=!0,this.ionScrollStart.emit({isScrolling:!0}),this.watchDog&&clearInterval(this.watchDog),this.watchDog=setInterval(function(){e.lastScroll<Date.now()-120&&e.onScrollEnd()},100)},t.prototype.onScrollEnd=function(){clearInterval(this.watchDog),this.watchDog=null,this.isScrolling&&(this.isScrolling=!1,this.ionScrollEnd.emit({isScrolling:!1}))},t.prototype.render=function(){var e,o=this,l=this,n=l.scrollX,i=l.scrollY,f=b(this),s=this.shouldForceOverscroll(),a=f==="ios"&&x.getBoolean("experimentalTransitionShadow",!0);return this.resize(),h(A,{class:Object.assign(Object.assign({},w(this.color)),(e={},e[f]=!0,e["content-sizing"]=y("ion-popover",this.el),e.overscroll=s,e)),style:{"--offset-top":this.cTop+"px","--offset-bottom":this.cBottom+"px"}},h("main",{class:{"inner-scroll":!0,"scroll-x":n,"scroll-y":i,overscroll:(n||i)&&s},ref:function(r){return o.scrollEl=r},onScroll:function(r){return o.onScroll(r)}},h("slot",null)),a?h("div",{class:"transition-effect"},h("div",{class:"transition-cover"}),h("div",{class:"transition-shadow"})):null,h("slot",{name:"fixed"}))},Object.defineProperty(t.prototype,"el",{get:function(){return k(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t,"style",{get:function(){return':host{--background:var(--ion-background-color,#fff);--color:var(--ion-text-color,#000);--padding-top:0px;--padding-bottom:0px;--padding-start:0px;--padding-end:0px;--keyboard-offset:0px;--offset-top:0px;--offset-bottom:0px;--overflow:auto;display:block;position:relative;-ms-flex:1;flex:1;width:100%;height:100%;margin:0!important;padding:0!important;font-family:var(--ion-font-family,inherit);contain:size style}:host(.ion-color) .inner-scroll{background:var(--ion-color-base);color:var(--ion-color-contrast)}:host(.outer-content){--background:var(--ion-color-step-50,#f2f2f2)}.inner-scroll{left:0;right:0;top:calc(var(--offset-top) * -1);bottom:calc(var(--offset-bottom) * -1);padding-left:var(--padding-start);padding-right:var(--padding-end);padding-top:calc(var(--padding-top) + var(--offset-top));padding-bottom:calc(var(--padding-bottom) + var(--keyboard-offset) + var(--offset-bottom));position:absolute;background:var(--background);color:var(--color);-webkit-box-sizing:border-box;box-sizing:border-box;overflow:hidden}@supports ((-webkit-margin-start:0) or (margin-inline-start:0)) or (-webkit-margin-start:0){.inner-scroll{padding-left:unset;padding-right:unset;-webkit-padding-start:var(--padding-start);padding-inline-start:var(--padding-start);-webkit-padding-end:var(--padding-end);padding-inline-end:var(--padding-end)}}.scroll-x,.scroll-y{-webkit-overflow-scrolling:touch;will-change:scroll-position;-ms-scroll-chaining:none;overscroll-behavior:contain}.scroll-y{-ms-touch-action:pan-y;touch-action:pan-y;overflow-y:var(--overflow)}.scroll-x{-ms-touch-action:pan-x;touch-action:pan-x;overflow-x:var(--overflow)}.scroll-x.scroll-y{-ms-touch-action:auto;touch-action:auto}.overscroll:after,.overscroll:before{position:absolute;width:1px;height:1px;content:""}.overscroll:before{bottom:-1px}.overscroll:after{top:-1px}:host(.content-sizing){contain:none}:host(.content-sizing) .inner-scroll{position:relative}.transition-effect{left:-100%;opacity:0;pointer-events:none}.transition-cover,.transition-effect{position:absolute;width:100%;height:100%}.transition-cover{right:0;background:#000;opacity:.1}.transition-shadow{display:block;position:absolute;right:0;width:10px;height:100%;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAA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kyQkVEQTU1RjYyNCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PmePEuQAAABNSURBVHjaYvz//z8DIxAwMDAwATGMhmFmPDQuOSZks0AMmoJBaQHjkPfB0Lfg/2gQjVow+HPy/yHvg9GiYjQfjMbBqAWjFgy/4hogwADYqwdzxy5BuwAAAABJRU5ErkJggg==);background-repeat:repeat-y;background-size:10px 16px}'},enumerable:!0,configurable:!0}),t}(),D=function(t){return t.parentElement?t.parentElement:t.parentNode&&t.parentNode.host?t.parentNode.host:null},G=function(t){var e=t.closest("ion-tabs");if(e)return e;var o=t.closest("ion-app,ion-page,.ion-page,page-inner");return o||D(t)},I=function(t,e,o,l){var n=t.currentX,i=t.currentY,f=t.timeStamp,s=e.scrollLeft,a=e.scrollTop,r=o-f;if(l&&(t.startTimeStamp=o,t.startX=s,t.startY=a,t.velocityX=t.velocityY=0),t.timeStamp=o,t.currentX=t.scrollLeft=s,t.currentY=t.scrollTop=a,t.deltaX=s-t.startX,t.deltaY=a-t.startY,r>0&&r<100){var c=(s-n)/r,p=(a-i)/r;t.velocityX=c*.7+t.velocityX*.3,t.velocityY=p*.7+t.velocityY*.3}};export{X as ion_content};