trilium/libraries/wheel-zoom.min.js

1 line
14 KiB
JavaScript
Raw Normal View History

(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 C=Math.min,D=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=i(),g=h(),j=e.clientTop||d.clientTop||0,k=e.clientLeft||d.clientLeft||0,l=b.top+f-j,m=b.left+g-k;return{top:l,left:m}}function h(){var a=void 0!==window.pageXOffset,b="CSS1Compat"===(document.compatMode||"");return a?window.pageXOffset:b?document.documentElement.scrollLeft:document.body.scrollLeft}function i(){var a=void 0!==window.pageYOffset,b="CSS1Compat"===(document.compatMode||"");return a?window.pageYOffset:b?document.documentElement.scrollTop:document.body.scrollTop}function j(a,b){if(a&&b)for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}function k(a,b,c){var d=!!(3<arguments.length&&void 0!==arguments[3])&&arguments[3];a.addEventListener(b,c,d)}function l(a,b,c){var d=!!(3<arguments.length&&void 0!==arguments[3])&&arguments[3];a.removeEventListener(b,c,d)}function m(){return"ontouchstart"in window||0<navigator.MaxTouchPoints||0<navigator.msMaxTouchPoints}function n(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 o(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 p(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=j({smoothExtinction:.25,onGrab:null,onMove:null,onDrop:null},c),this.isTouch=m(),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,k(this.content.$element,this.events.grab,this._grabHandler,this.events.options)}function q(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 r(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=s.bind(this),this._downHandler=t.bind(this),this._upHandler=u.bind(this),this._zoomTwoFingers_TouchmoveHandler=v.bind(this),this._zoomTwoFingers_TouchendHandler=w.bind(this),this.content={},thi