UNPKG

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) 7.53 kB
import{e as g}from"./chunk-4DAZ7WDM.js";import{a as m,b as h,c as d,e as k,f as w,l as x,o as y}from"./chunk-VNJCZCB4.js";import"./chunk-L67DAW3A.js";var b=function(o,t,e,l){return new(e||(e=Promise))(function(i,n){function u(r){try{s(l.next(r))}catch(a){n(a)}}function c(r){try{s(l.throw(r))}catch(a){n(a)}}function s(r){r.done?i(r.value):new e(function(a){a(r.value)}).then(u,c)}s((l=l.apply(o,t||[])).next())})},p=function(o,t){var e={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},l,i,n,u;return u={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function c(r){return function(a){return s([r,a])}}function s(r){if(l)throw new TypeError("Generator is already executing.");for(;e;)try{if(l=1,i&&(n=r[0]&2?i.return:r[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,r[1])).done)return n;switch(i=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++,i=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(o,e)}catch(a){r=[6,a],i=0}finally{l=n=0}if(r[0]&5)throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}},T="all 0.2s ease-in-out",C=function(o){var t=document.querySelector(o+".ion-cloned-element");if(t!==null)return t;var e=document.createElement(o);return e.classList.add("ion-cloned-element"),e.style.setProperty("display","none"),document.body.appendChild(e),e},E=function(o){if(o){var t=o.querySelectorAll("ion-toolbar");return{el:o,toolbars:Array.from(t).map(function(e){var l=e.querySelector("ion-title");return{el:e,background:e.shadowRoot.querySelector(".toolbar-background"),ionTitleEl:l,innerTitleEl:l?l.shadowRoot.querySelector(".toolbar-title"):null,ionButtonsEl:Array.from(e.querySelectorAll("ion-buttons"))||[]}})||[[]]}}},I=function(o,t){h(function(){var e=o.scrollTop,l=g(1,1+-e/500,1.1);d(function(){q(t.toolbars,l)})})},H=function(o,t){t===void 0?o.background.style.removeProperty("--opacity"):o.background.style.setProperty("--opacity",t.toString())},O=function(o,t){if(o[0].isIntersecting){var e=(1-o[0].intersectionRatio)*100/75;H(t.toolbars[0],e===1?void 0:e)}},A=function(o,t,e){d(function(){O(o,t);var l=o[0],i=l.intersectionRect,n=i.width*i.height,u=l.rootBounds.width*l.rootBounds.height,c=n===0&&u===0,s=Math.abs(i.left-l.boundingClientRect.left),r=Math.abs(i.right-l.boundingClientRect.right),a=n>0&&(s>=5||r>=5);if(!(c||a))if(l.isIntersecting)f(t,!1),f(e);else{var v=i.x===0&&i.y===0||i.width!==0&&i.height!==0;v&&(f(t),f(e,!1),H(t.toolbars[0],1))}})},f=function(o,t){t===void 0&&(t=!0),d(function(){t?o.el.classList.remove("header-collapse-condense-inactive"):o.el.classList.add("header-collapse-condense-inactive")})},q=function(o,t,e){o===void 0&&(o=[]),t===void 0&&(t=1),e===void 0&&(e=!1),o.forEach(function(l){var i=l.ionTitleEl,n=l.innerTitleEl;!i||i.size!=="large"||(n.style.transformOrigin="left center",n.style.transition=e?T:"",n.style.transform="scale3d("+t+", "+t+", 1)")})},L=function(){function o(t){m(this,t),this.collapsibleHeaderInitialized=!1,this.translucent=!1}return o.prototype.componentDidLoad=function(){return b(this,void 0,void 0,function(){return p(this,function(t){switch(t.label){case 0:return[4,this.checkCollapsibleHeader()];case 1:return t.sent(),[2]}})})},o.prototype.componentDidUpdate=function(){return b(this,void 0,void 0,function(){return p(this,function(t){switch(t.label){case 0:return[4,this.checkCollapsibleHeader()];case 1:return t.sent(),[2]}})})},o.prototype.componentDidUnload=function(){this.destroyCollapsibleHeader()},o.prototype.checkCollapsibleHeader=function(){return b(this,void 0,void 0,function(){var t,e,l,i;return p(this,function(n){switch(n.label){case 0:return t=this.collapse==="condense",e=t&&y(this)==="ios"?t:!1,!e&&this.collapsibleHeaderInitialized?(this.destroyCollapsibleHeader(),[3,3]):[3,1];case 1:return e&&!this.collapsibleHeaderInitialized?(l=this.el.closest("ion-app,ion-page,.ion-page,page-inner"),i=l?l.querySelector("ion-content"):null,[4,this.setupCollapsibleHeader(i,l)]):[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}})})},o.prototype.destroyCollapsibleHeader=function(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=void 0),this.scrollEl&&this.contentScrollCallback&&(this.scrollEl.removeEventListener("scroll",this.contentScrollCallback),this.contentScrollCallback=void 0)},o.prototype.setupCollapsibleHeader=function(t,e){return b(this,void 0,void 0,function(){var l,i=this;return p(this,function(n){switch(n.label){case 0:return!t||!e?(console.error("ion-header requires a content to collapse, make sure there is an ion-content."),[2]):(l=this,[4,t.getScrollElement()]);case 1:return l.scrollEl=n.sent(),h(function(){var u=e.querySelectorAll("ion-header"),c=Array.from(u).find(function(a){return a.collapse!=="condense"});if(!(!c||!i.scrollEl)){var s=E(c),r=E(i.el);!s||!r||(f(s,!1),h(function(){var a=s.el.clientHeight,v=function(S){A(S,s,r)};i.intersectionObserver=new IntersectionObserver(v,{threshold:[.25,.3,.4,.5,.6,.7,.8,.9,1],rootMargin:"-"+a+"px 0px 0px 0px"}),i.intersectionObserver.observe(r.toolbars[0].el)}),i.contentScrollCallback=function(){I(i.scrollEl,r)},i.scrollEl.addEventListener("scroll",i.contentScrollCallback))}}),d(function(){C("ion-title"),C("ion-back-button")}),this.collapsibleHeaderInitialized=!0,[2]}})})},o.prototype.render=function(){var t,e=y(this),l=this.collapse||"none";return k(w,{role:"banner",class:(t={},t[e]=!0,t["header-"+e]=!0,t["header-translucent"]=this.translucent,t["header-collapse-"+l]=!0,t["header-translucent-"+e]=this.translucent,t)})},Object.defineProperty(o.prototype,"el",{get:function(){return x(this)},enumerable:!0,configurable:!0}),Object.defineProperty(o,"style",{get:function(){return"ion-header{display:block;position:relative;-ms-flex-order:-1;order:-1;width:100%;z-index:10}ion-header ion-toolbar:first-child{padding-top:var(--ion-safe-area-top,0)}.header-ios ion-toolbar:last-child{--border-width:0 0 0.55px}.header-ios[no-border] ion-toolbar:last-child{--border-width:0}@supports ((-webkit-backdrop-filter:blur(0)) or (backdrop-filter:blur(0))){.header-translucent-ios{-webkit-backdrop-filter:saturate(180%) blur(20px);backdrop-filter:saturate(180%) blur(20px)}.header-translucent-ios ion-toolbar{--opacity:.8;--backdrop-filter:saturate(180%) blur(20px)}}.header-collapse-condense{z-index:9}.header-collapse-condense ion-toolbar{position:-webkit-sticky;position:sticky;top:0}.header-collapse-condense ion-toolbar:first-child{padding-top:7px;z-index:1}.header-collapse-condense ion-toolbar{z-index:0}.header-collapse-condense ion-toolbar ion-searchbar{height:48px;padding-top:0;padding-bottom:13px}ion-toolbar.in-toolbar ion-buttons,ion-toolbar.in-toolbar ion-title{-webkit-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.header-collapse-condense ion-toolbar ion-buttons,.header-collapse-condense ion-toolbar ion-title{-webkit-transition:none;transition:none}.header-collapse-condense-inactive ion-toolbar.in-toolbar ion-buttons.buttons-collapse,.header-collapse-condense-inactive ion-toolbar.in-toolbar ion-title{opacity:0;pointer-events:none}"},enumerable:!0,configurable:!0}),o}();export{L as ion_header};