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.89 kB
import{e as g}from"./chunk-4DAZ7WDM.js";import{a as y,b as h,c as d,e as m,f as w,l as k,o as A}from"./chunk-VNJCZCB4.js";import"./chunk-L67DAW3A.js";var p=function(i,t,e,l){return new(e||(e=Promise))(function(o,r){function u(n){try{s(l.next(n))}catch(a){r(a)}}function c(n){try{s(l.throw(n))}catch(a){r(a)}}function s(n){n.done?o(n.value):new e(function(a){a(n.value)}).then(u,c)}s((l=l.apply(i,t||[])).next())})},b=function(i,t){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},l,o,r,u;return u={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function c(n){return function(a){return s([n,a])}}function s(n){if(l)throw new TypeError("Generator is already executing.");for(;e;)try{if(l=1,o&&(r=n[0]&2?o.return:n[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,n[1])).done)return r;switch(o=0,r&&(n=[n[0]&2,r.value]),n[0]){case 0:case 1:r=n;break;case 4:return e.label++,{value:n[1],done:!1};case 5:e.label++,o=n[1],n=[0];continue;case 7:n=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(n[0]===6||n[0]===2)){e=0;continue}if(n[0]===3&&(!r||n[1]>r[0]&&n[1]<r[3])){e.label=n[1];break}if(n[0]===6&&e.label<r[1]){e.label=r[1],r=n;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(n);break}r[2]&&e.ops.pop(),e.trys.pop();continue}n=t.call(i,e)}catch(a){n=[6,a],o=0}finally{l=r=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}},x="all 0.2s ease-in-out",E=function(i){var t=document.querySelector(i+".ion-cloned-element");if(t!==null)return t;var e=document.createElement(i);return e.classList.add("ion-cloned-element"),e.style.setProperty("display","none"),document.body.appendChild(e),e},C=function(i){if(i){var t=i.querySelectorAll("ion-toolbar");return{el:i,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"))||[]}})||[[]]}}},T=function(i,t){h(function(){var e=i.scrollTop,l=g(1,1+-e/500,1.1);d(function(){O(t.toolbars,l)})})},S=function(i,t){t===void 0?i.background.style.removeProperty("--opacity"):i.background.style.setProperty("--opacity",t.toString())},B=function(i,t){if(i[0].isIntersecting){var e=(1-i[0].intersectionRatio)*100/75;S(t.toolbars[0],e===1?void 0:e)}},I=function(i,t,e){d(function(){B(i,t);var l=i[0],o=l.intersectionRect,r=o.width*o.height,u=l.rootBounds.width*l.rootBounds.height,c=r===0&&u===0,s=Math.abs(o.left-l.boundingClientRect.left),n=Math.abs(o.right-l.boundingClientRect.right),a=r>0&&(s>=5||n>=5);if(!(c||a))if(l.isIntersecting)f(t,!1),f(e);else{var v=o.x===0&&o.y===0||o.width!==0&&o.height!==0;v&&(f(t),f(e,!1),S(t.toolbars[0],1))}})},f=function(i,t){t===void 0&&(t=!0),d(function(){t?i.el.classList.remove("header-collapse-condense-inactive"):i.el.classList.add("header-collapse-condense-inactive")})},O=function(i,t,e){i===void 0&&(i=[]),t===void 0&&(t=1),e===void 0&&(e=!1),i.forEach(function(l){var o=l.ionTitleEl,r=l.innerTitleEl;!o||o.size!=="large"||(r.style.transformOrigin="left center",r.style.transition=e?x:"",r.style.transform="scale3d("+t+", "+t+", 1)")})},q=function(){function i(t){y(this,t),this.collapsibleHeaderInitialized=!1,this.translucent=!1}return i.prototype.componentDidLoad=function(){return p(this,void 0,void 0,function(){return b(this,function(t){switch(t.label){case 0:return[4,this.checkCollapsibleHeader()];case 1:return t.sent(),[2]}})})},i.prototype.componentDidUpdate=function(){return p(this,void 0,void 0,function(){return b(this,function(t){switch(t.label){case 0:return[4,this.checkCollapsibleHeader()];case 1:return t.sent(),[2]}})})},i.prototype.componentDidUnload=function(){this.destroyCollapsibleHeader()},i.prototype.checkCollapsibleHeader=function(){return p(this,void 0,void 0,function(){var t,e,l,o;return b(this,function(r){switch(r.label){case 0:return t=this.collapse==="condense",e=t&&A(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"),o=l?l.querySelector("ion-content"):null,[4,this.setupCollapsibleHeader(o,l)]):[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}})})},i.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)},i.prototype.setupCollapsibleHeader=function(t,e){return p(this,void 0,void 0,function(){var l,o=this;return b(this,function(r){switch(r.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=r.sent(),h(function(){var u=e.querySelectorAll("ion-header"),c=Array.from(u).find(function(a){return a.collapse!=="condense"});if(!(!c||!o.scrollEl)){var s=C(c),n=C(o.el);!s||!n||(f(s,!1),h(function(){var a=s.el.clientHeight,v=function(H){I(H,s,n)};o.intersectionObserver=new IntersectionObserver(v,{threshold:[.25,.3,.4,.5,.6,.7,.8,.9,1],rootMargin:"-"+a+"px 0px 0px 0px"}),o.intersectionObserver.observe(n.toolbars[0].el)}),o.contentScrollCallback=function(){T(o.scrollEl,n)},o.scrollEl.addEventListener("scroll",o.contentScrollCallback))}}),d(function(){E("ion-title"),E("ion-back-button")}),this.collapsibleHeaderInitialized=!0,[2]}})})},i.prototype.render=function(){var t,e=A(this),l=this.collapse||"none";return m(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(i.prototype,"el",{get:function(){return k(this)},enumerable:!0,configurable:!0}),Object.defineProperty(i,"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-md:after{left:0;bottom:-5px;background-position:left 0 top -2px;position:absolute;width:100%;height:5px;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAHBAMAAADzDtBxAAAAD1BMVEUAAAAAAAAAAAAAAAAAAABPDueNAAAABXRSTlMUCS0gBIh/TXEAAAAaSURBVAjXYxCEAgY4UIICBmMogMsgFLtAAQCNSwXZKOdPxgAAAABJRU5ErkJggg==);background-repeat:repeat-x;content:""}:host-context([dir=rtl]) .header-md:after,[dir=rtl] .header-md:after{left:unset;right:unset;right:0;background-position:right 0 top -2px}.header-collapse-condense,.header-md[no-border]:after{display:none}'},enumerable:!0,configurable:!0}),i}();export{q as ion_header};