trilium/libraries/wheel-zoom.min.js

2 lines
14 KiB
JavaScript
Raw Normal View History

2021-11-16 05:28:56 +08:00
(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):(a="undefined"==typeof globalThis?a||self:globalThis,a.WZoom=b())})(this,function(){'use strict';var x=Math.min,y=Math.abs;function a(a,e){return b(a)||c(a,e)||d(a,e)||f()}function b(a){if(Array.isArray(a))return a}function c(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f=[],g=!0,h=!1;try{for(c=c.call(a);!(g=(d=c.next()).done)&&(f.push(d.value),!(b&&f.length===b));g=!0);}catch(a){h=!0,e=a}finally{try{g||null==c["return"]||c["return"]()}finally{if(h)throw e}}return f}}function d(a,b){if(a){if("string"==typeof a)return e(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?e(a,b):void 0}}function e(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function f(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function g(a){var b=a.getBoundingClientRect(),c=document,d=c.body,e=c.documentElement,f=window.pageYOffset||e.scrollTop||d.scrollTop,g=window.pageXOffset||e.scrollLeft||d.scrollLeft,h=e.clientTop||d.clientTop||0,i=e.clientLeft||d.clientLeft||0,j=b.top+f-h,k=b.left+g-i;return{top:j,left:k}}function h(a,b){if(a&&b)for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}function i(a,b,c){var d=!!(3<arguments.length&&void 0!==arguments[3])&&arguments[3];a.addEventListener(b,c,d)}function j(a,b,c){var d=!!(3<arguments.length&&void 0!==arguments[3])&&arguments[3];a.removeEventListener(b,c,d)}function k(){return"ontouchstart"in window||0<navigator.MaxTouchPoints||0<navigator.msMaxTouchPoints}function l(a){return"wheel"===a.type||"pointerup"===a.type||"pointerdown"===a.type||"pointermove"===a.type||"mousedown"===a.type||"mousemove"===a.type||"mouseup"===a.type?a.clientX:a.changedTouches[0].clientX}function m(a){return"wheel"===a.type||"pointerup"===a.type||"pointerdown"===a.type||"pointermove"===a.type||"mousedown"===a.type||"mousemove"===a.type||"mouseup"===a.type?a.clientY:a.changedTouches[0].clientY}function n(a,b){var c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};this._dropHandler=this._dropHandler.bind(this),this._grabHandler=this._grabHandler.bind(this),this._moveHandler=this._moveHandler.bind(this),c.smoothExtinction=+c.smoothExtinction,isNaN(c.smoothExtinction)&&(c.smoothExtinction=.25),this.options=h({smoothExtinction:.25,onGrab:null,onMove:null,onDrop:null},c),this.isTouch=k(),this.events=this.isTouch?{grab:"touchstart",move:"touchmove",drop:"touchend"}:{grab:"mousedown",move:"mousemove",drop:"mouseup"},this.events.options=!!this.isTouch&&{passive:!1},this.window=a,this.content=b,i(this.content.$element,this.events.grab,this._grabHandler,this.events.options)}function o(a,b,c){var d=b.left,e=b.top,f=b.scale;c.smoothExtinction?a.style.transition="transform ".concat(c.smoothExtinction,"s"):a.style.removeProperty("transition"),a.style.transform="translate3d(".concat(d,"px, ").concat(e,"px, 0px) scale(").concat(f,")")}function p(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};this._init=this._init.bind(this),this._prepare=this._prepare.bind(this),this._computeNewScale=this._computeNewScale.bind(this),this._computeNewPosition=this._computeNewPosition.bind(this),this._transform=this._transform.bind(this),this._wheelHandler=q.bind(this),this._downHandler=r.bind(this),this._upHandler=s.bind(this),this._zoomTwoFingers_TouchmoveHandler=t.bind(this),this._zoomTwoFingers_TouchendHandler=u.bind(this),this.content={},this.window={},this.isTouch=!1,this.events=null,this.direction=1,this.options=null,this.dragScrollable=null,this.coordsOnMouseDown=null;var c={type:"image",width:null,height:null,dragScrollable:!0,dragScrollableOptions:{},minScale:null,maxScale:1,speed:50,zoomOnClick:!0,watchIma