UNPKG

@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 10.6 kB
"use strict";(self.webpackChunkUV=self.webpackChunkUV||[]).push([[3590],{8265:(t,e,i)=>{i.d(e,{a:()=>o,b:()=>r,c:()=>s,h:()=>n});var n=function(){var t=window.TapticEngine;t&&t.selection()},o=function(){var t=window.TapticEngine;t&&t.gestureSelectionStart()},r=function(){var t=window.TapticEngine;t&&t.gestureSelectionChanged()},s=function(){var t=window.TapticEngine;t&&t.gestureSelectionEnd()}},884:(t,e,i)=>{i.d(e,{a:()=>n,b:()=>c,c:()=>a,d:()=>u,e:()=>d,f:()=>r,h:()=>o,i:()=>p,n:()=>l,p:()=>h,r:()=>s});var n=function(t){return"function"==typeof __zone_symbol__requestAnimationFrame?__zone_symbol__requestAnimationFrame(t):"function"==typeof requestAnimationFrame?requestAnimationFrame(t):setTimeout(t)},o=function(t){return!!t.shadowRoot&&!!t.attachShadow},r=function(t){var e=t.closest("ion-item");return e?e.querySelector("ion-label"):null},s=function(t,e,i,n,r){if(t||o(e)){var s=e.querySelector("input.aux-input");s||((s=e.ownerDocument.createElement("input")).type="hidden",s.classList.add("aux-input"),e.appendChild(s)),s.disabled=r,s.name=i,s.value=n||""}},a=function(t,e,i){return Math.max(t,Math.min(e,i))},c=function(t,e){if(!t){var i="ASSERT: "+e;throw console.error(i),new Error(i)}},l=function(t){return t.timeStamp||Date.now()},h=function(t){if(t){var e=t.changedTouches;if(e&&e.length>0){var i=e[0];return{x:i.clientX,y:i.clientY}}if(void 0!==t.pageX)return{x:t.pageX,y:t.pageY}}return{x:0,y:0}},p=function(t){var e="rtl"===document.dir;switch(t){case"start":return e;case"end":return!e;default:throw new Error('"'+t+'" is not a valid value for [side]. Use "start" or "end" instead.')}},u=function(t,e){var i=t._original||t;return{_original:t,emit:d(i.emit.bind(i),e)}},d=function(t,e){var i;return void 0===e&&(e=0),function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];clearTimeout(i),i=setTimeout.apply(void 0,[t,e].concat(n))}}},3590:(t,e,i)=>{i.r(e),i.d(e,{ion_picker_column:()=>s});var n=i(5873),o=i(884),r=i(8265),s=function(){function t(t){(0,n.r)(this,t),this.optHeight=0,this.rotateFactor=0,this.scaleFactor=1,this.velocity=0,this.y=0,this.noAnimate=!0,this.ionPickerColChange=(0,n.c)(this,"ionPickerColChange",7)}return t.prototype.colChanged=function(){this.refresh()},t.prototype.connectedCallback=function(){return t=this,e=void 0,r=function(){var t,e,o,r=this;return function(t,e){var i,n,o,r,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(r){return function(a){return function(r){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(o=2&r[0]?n.return:r[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,r[1])).done)return o;switch(n=0,o&&(r=[2&r[0],o.value]),r[0]){case 0:case 1:o=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,n=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!o||r[1]>o[0]&&r[1]<o[3])){s.label=r[1];break}if(6===r[0]&&s.label<o[1]){s.label=o[1],o=r;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(r);break}o[2]&&s.ops.pop(),s.trys.pop();continue}r=e.call(t,s)}catch(t){r=[6,t],n=0}finally{i=o=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,a])}}}(this,(function(s){switch(s.label){case 0:return t=0,e=.81,"ios"===(0,n.f)(this)&&(t=-.46,e=1),this.rotateFactor=t,this.scaleFactor=e,o=this,[4,i.e(3748).then(i.bind(i,3748))];case 1:return o.gesture=s.sent().createGesture({el:this.el,gestureName:"picker-swipe",gesturePriority:100,threshold:0,onStart:function(t){return r.onStart(t)},onMove:function(t){return r.onMove(t)},onEnd:function(t){return r.onEnd(t)}}),this.gesture.setDisabled(!1),this.tmrId=setTimeout((function(){r.noAnimate=!1,r.refresh(!0)}),250),[2]}}))},new((o=void 0)||(o=Promise))((function(i,n){function s(t){try{c(r.next(t))}catch(t){n(t)}}function a(t){try{c(r.throw(t))}catch(t){n(t)}}function c(t){t.done?i(t.value):new o((function(e){e(t.value)})).then(s,a)}c((r=r.apply(t,e||[])).next())}));var t,e,o,r},t.prototype.componentDidLoad=function(){var t=this.optsEl;t&&(this.optHeight=t.firstElementChild?t.firstElementChild.clientHeight:0),this.refresh()},t.prototype.disconnectedCallback=function(){cancelAnimationFrame(this.rafId),clearTimeout(this.tmrId),this.gesture&&(this.gesture.destroy(),this.gesture=void 0)},t.prototype.emitColChange=function(){this.ionPickerColChange.emit(this.col)},t.prototype.setSelected=function(t,e){var i=t>-1?-t*this.optHeight:0;this.velocity=0,cancelAnimationFrame(this.rafId),this.update(i,e,!0),this.emitColChange()},t.prototype.update=function(t,e,i){if(this.optsEl){for(var n=0,o=0,s=this.col,c=this.rotateFactor,l=s.selectedIndex=this.indexForY(-t),h=0===e?"":e+"ms",p="scale("+this.scaleFactor+")",u=this.optsEl.children,d=0;d<u.length;d++){var f=u[d],m=s.options[d],g=d*this.optHeight+t,v="";if(0!==c){var y=g*c;Math.abs(y)<=90?(n=0,o=90,v="rotateX("+y+"deg) "):n=-9999}else o=0,n=g;var x=l===d;v+="translate3d(0px,"+n+"px,"+o+"px) ",1===this.scaleFactor||x||(v+=p),this.noAnimate?(m.duration=0,f.style.transitionDuration=""):e!==m.duration&&(m.duration=e,f.style.transitionDuration=h),v!==m.transform&&(m.transform=v,f.style.transform=v),x!==m.selected&&(m.selected=x,x?f.classList.add(a):f.classList.remove(a))}this.col.prevSelected=l,i&&(this.y=t),this.lastIndex!==l&&((0,r.b)(),this.lastIndex=l)}},t.prototype.decelerate=function(){var t=this;if(0!==this.velocity){this.velocity*=c,this.velocity=this.velocity>0?Math.max(this.velocity,1):Math.min(this.velocity,-1);var e=this.y+this.velocity;e>this.minY?(e=this.minY,this.velocity=0):e<this.maxY&&(e=this.maxY,this.velocity=0),this.update(e,0,!0),Math.round(e)%this.optHeight!=0||Math.abs(this.velocity)>1?this.rafId=requestAnimationFrame((function(){return t.decelerate()})):(this.velocity=0,this.emitColChange())}else if(this.y%this.optHeight!=0){var i=Math.abs(this.y%this.optHeight);this.velocity=i>this.optHeight/2?1:-1,this.decelerate()}},t.prototype.indexForY=function(t){return Math.min(Math.max(Math.abs(Math.round(t/this.optHeight)),0),this.col.options.length-1)},t.prototype.onStart=function(t){t.event.preventDefault(),t.event.stopPropagation(),cancelAnimationFrame(this.rafId);for(var e=this.col.options,i=e.length-1,n=0,o=0;o<e.length;o++)e[o].disabled||(i=Math.min(i,o),n=Math.max(n,o));this.minY=-i*this.optHeight,this.maxY=-n*this.optHeight},t.prototype.onMove=function(t){t.event.preventDefault(),t.event.stopPropagation();var e=this.y+t.deltaY;e>this.minY?(e=Math.pow(e,.8),this.bounceFrom=e):e<this.maxY?(e+=Math.pow(this.maxY-e,.9),this.bounceFrom=e):this.bounceFrom=0,this.update(e,0,!1)},t.prototype.onEnd=function(t){if(this.bounceFrom>0)return this.update(this.minY,100,!0),void this.emitColChange();if(this.bounceFrom<0)return this.update(this.maxY,100,!0),void this.emitColChange();if(this.velocity=(0,o.c)(-l,23*t.velocityY,l),0===this.velocity&&0===t.deltaY){var e=t.event.target.closest(".picker-opt");e&&e.hasAttribute("opt-index")&&this.setSelected(parseInt(e.getAttribute("opt-index"),10),h)}else this.y+=t.deltaY,this.decelerate()},t.prototype.refresh=function(t){for(var e=this.col.options.length-1,i=0,n=this.col.options,r=0;r<n.length;r++)n[r].disabled||(e=Math.min(e,r),i=Math.max(i,r));if(0===this.velocity){var s=(0,o.c)(e,this.col.selectedIndex||0,i);if(this.col.prevSelected!==s||t){var a=s*this.optHeight*-1;this.velocity=0,this.update(a,h,!0)}}},t.prototype.render=function(){var t,e=this,i=this.col,o=(0,n.f)(this);return(0,n.h)(n.H,{class:(t={},t[o]=!0,t["picker-col"]=!0,t["picker-opts-left"]="left"===this.col.align,t["picker-opts-right"]="right"===this.col.align,t),style:{"max-width":this.col.columnWidth}},i.prefix&&(0,n.h)("div",{class:"picker-prefix",style:{width:i.prefixWidth}},i.prefix),(0,n.h)("div",{class:"picker-opts",style:{maxWidth:i.optionsWidth},ref:function(t){return e.optsEl=t}},i.options.map((function(t,e){return(0,n.h)("button",{type:"button",class:{"picker-opt":!0,"picker-opt-disabled":!!t.disabled},"opt-index":e},t.text)}))),i.suffix&&(0,n.h)("div",{class:"picker-suffix",style:{width:i.suffixWidth}},i.suffix))},Object.defineProperty(t.prototype,"el",{get:function(){return(0,n.d)(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t,"watchers",{get:function(){return{col:["colChanged"]}},enumerable:!0,configurable:!0}),Object.defineProperty(t,"style",{get:function(){return".picker-col{display:-ms-flexbox;display:flex;position:relative;-ms-flex:1;flex:1;-ms-flex-pack:center;justify-content:center;height:100%;-webkit-box-sizing:content-box;box-sizing:content-box;contain:content}.picker-opts{position:relative;-ms-flex:1;flex:1;max-width:100%}.picker-opt{left:0;top:0;display:block;position:absolute;width:100%;border:0;text-align:center;text-overflow:ellipsis;white-space:nowrap;contain:strict;overflow:hidden;will-change:transform}:host-context([dir=rtl]) .picker-opt,[dir=rtl] .picker-opt{left:unset;right:unset;right:0}.picker-opt.picker-opt-disabled{pointer-events:none}.picker-opt-disabled{opacity:0}.picker-opts-left{-ms-flex-pack:start;justify-content:flex-start}.picker-opts-right{-ms-flex-pack:end;justify-content:flex-end}.picker-opt:active,.picker-opt:focus{outline:none}.picker-prefix{text-align:end}.picker-prefix,.picker-suffix{position:relative;-ms-flex:1;flex:1;white-space:nowrap}.picker-suffix{text-align:start}.picker-col{padding-left:8px;padding-right:8px;padding-top:0;padding-bottom:0;-webkit-transform-style:preserve-3d;transform-style:preserve-3d}@supports ((-webkit-margin-start:0) or (margin-inline-start:0)) or (-webkit-margin-start:0){.picker-col{padding-left:unset;padding-right:unset;-webkit-padding-start:8px;padding-inline-start:8px;-webkit-padding-end:8px;padding-inline-end:8px}}.picker-opts,.picker-prefix,.picker-suffix{top:77px;-webkit-transform-style:preserve-3d;transform-style:preserve-3d;color:inherit;font-size:22px;line-height:42px;pointer-events:none}.picker-opt{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;height:43px;-webkit-transition-timing-function:ease-out;transition-timing-function:ease-out;background:transparent;color:inherit;font-size:22px;line-height:42px;-webkit-backface-visibility:hidden;backface-visibility:hidden;pointer-events:auto}.picker-opt.picker-opt-selected,.picker-prefix,.picker-suffix{color:var(--ion-color-primary,#3880ff)}"},enumerable:!0,configurable:!0}),t}(),a="picker-opt-selected",c=.97,l=90,h=150}}]);