@tindtechnologies/universalviewer
Version:
The Universal Viewer is a community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎
1 lines • 3.86 kB
JavaScript
;(self.webpackChunkUV=self.webpackChunkUV||[]).push([[6520],{6520:(t,e,n)=>{n.r(e),n.d(e,{startInputShims:()=>v});var o=n(884),r=new WeakMap,a=function(t,e,n,o){void 0===o&&(o=0),r.has(t)!==n&&(n?u(t,e,o):c(t,e))},i=function(t){return t===t.getRootNode().activeElement},u=function(t,e,n){var o=e.parentNode,a=e.cloneNode(!1);a.classList.add("cloned-input"),a.tabIndex=-1,o.appendChild(a),r.set(t,a);var i="rtl"===t.ownerDocument.dir?9999:-9999;t.style.pointerEvents="none",e.style.transform="translate3d("+i+"px,"+n+"px,0) scale(0)"},c=function(t,e){var n=r.get(t);n&&(r.delete(t),n.remove()),t.style.pointerEvents="",e.style.transform=""},l="input, textarea, [no-blur]",s=function(t,e,n,o){var r=function(t,e,n){return function(t,e,n,o){var r=t.top,a=t.bottom,i=e.top,u=i+15,c=.5*Math.min(e.bottom,o-n)-a,l=u-r,s=Math.round(c<0?-c:l>0?-l:0),d=Math.min(s,r-i),f=Math.abs(d)/.3;return{scrollAmount:d,scrollDuration:Math.min(400,Math.max(150,f)),scrollPadding:n,inputSafeY:4-(r-u)}}((t.closest("ion-item,[ion-item]")||t).getBoundingClientRect(),e.getBoundingClientRect(),n,t.ownerDocument.defaultView.innerHeight)}(t,n,o);Math.abs(r.scrollAmount)<4?e.focus():(a(t,e,!0,r.inputSafeY),e.focus(),n.scrollByPoint(0,r.scrollAmount,r.scrollDuration).then((function(){a(t,e,!1,r.inputSafeY),e.focus()})))},d="$ionPaddingTimer",f=function(t,e){if("INPUT"===t.tagName&&!(t.parentElement&&"ION-INPUT"===t.parentElement.tagName||t.parentElement&&t.parentElement.parentElement&&"ION-SEARCHBAR"===t.parentElement.parentElement.tagName)){var n=t.closest("ion-content");if(null!==n){var o=n[d];o&&clearTimeout(o),e>0?n.style.setProperty("--keyboard-offset",e+"px"):n[d]=setTimeout((function(){n.style.setProperty("--keyboard-offset","0px")}),120)}}},v=function(t){var e=document,n=t.getNumber("keyboardHeight",290),r=t.getBoolean("scrollAssist",!0),u=t.getBoolean("hideCaretOnScroll",!0),c=t.getBoolean("inputBlurring",!0),d=t.getBoolean("scrollPadding",!0),v=Array.from(e.querySelectorAll("ion-input, ion-textarea")),m=new WeakMap,p=new WeakMap,E=function(t){var e=(t.shadowRoot||t).querySelector("input")||(t.shadowRoot||t).querySelector("textarea"),c=t.closest("ion-content");if(e){if(c&&u&&!m.has(t)){var l=function(t,e,n){if(!n||!e)return function(){};var o=function(n){i(e)&&a(t,e,n)},r=function(){return a(t,e,!1)},u=function(){return o(!0)},c=function(){return o(!1)};return n.addEventListener("ionScrollStart",u),n.addEventListener("ionScrollEnd",c),e.addEventListener("blur",r),function(){n.removeEventListener("ionScrollStart",u),n.removeEventListener("ionScrollEnd",c),e.addEventListener("ionBlur",r)}}(t,e,c);m.set(t,l)}c&&r&&!p.has(t)&&(l=function(t,e,n,r){var a,u=function(t){a=(0,o.p)(t)},c=function(u){if(a){var c=(0,o.p)(u);(function(t,e,n){if(e&&n){var o=e.x-n.x,r=e.y-n.y;return o*o+r*r>t*t}return!1})(6,a,c)||i(e)||(u.preventDefault(),u.stopPropagation(),s(t,e,n,r))}};return t.addEventListener("touchstart",u,!0),t.addEventListener("touchend",c,!0),function(){t.removeEventListener("touchstart",u,!0),t.removeEventListener("touchend",c,!0)}}(t,e,c,n),p.set(t,l))}};c&&function(){var t=!0,e=!1,n=document;n.addEventListener("ionScrollStart",(function(){e=!0})),n.addEventListener("focusin",(function(){t=!0}),!0),n.addEventListener("touchend",(function(o){if(e)e=!1;else{var r=n.activeElement;if(r&&!r.matches(l)){var a=o.target;a!==r&&(a.matches(l)||a.closest(l)||(t=!1,setTimeout((function(){t||r.blur()}),50)))}}}),!1)}(),d&&function(t){var e=document;e.addEventListener("focusin",(function(e){f(e.target,t)})),e.addEventListener("focusout",(function(t){f(t.target,0)}))}(n);for(var h=0,g=v;h<g.length;h++){var L=g[h];E(L)}e.addEventListener("ionInputDidLoad",(function(t){E(t.detail)})),e.addEventListener("ionInputDidUnload",(function(t){var e,n;e=t.detail,u&&((n=m.get(e))&&n(),m.delete(e)),r&&((n=p.get(e))&&n(),p.delete(e))}))}}}]);