You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
8.5 KiB
2 lines
8.5 KiB
4 years ago
|
!function(o,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(o="undefined"!=typeof globalThis?globalThis:o||self).Zoom=t()}(this,function(){"use strict";var o=[{key:"zoomTo",name:"zoomTo"}].map(function(o){return{key:o.key,sourceKey:"plugins.zoom."+o.name}}),r="undefined"!=typeof window,e=r&&navigator.userAgent.toLowerCase();e&&/wechatdevtools/.test(e),e&&e.indexOf("android"),function(){if("string"!=typeof e)return;var o=/os (\d\d?_\d(_\d)?)/.exec(e);if(!o)return;var t=o[1].split("_").map(function(o){return parseInt(o,10)});13<=t[0]&&t[1]}();function m(){return window.performance&&window.performance.now&&window.performance.timing?window.performance.now()+window.performance.timing.navigationStart:+new Date}function g(o,t,e){return o<t?t:e<o?e:o}var n=r&&document.createElement("div").style,t=function(){if(!r)return!1;for(var o=0,t=[{key:"standard",value:"transform"},{key:"webkit",value:"webkitTransform"},{key:"Moz",value:"MozTransform"},{key:"O",value:"OTransform"},{key:"ms",value:"msTransform"}];o<t.length;o++){var e=t[o];if(void 0!==n[e.value])return e.key}return!1}();function i(o){return!1===t?o:"standard"===t?"transitionEnd"===o?"transitionend":o:t+o.charAt(0).toUpperCase()+o.substr(1)}t&&"standard"!==t&&t.toLowerCase(),i("transform"),i("transition"),r&&i("perspective")in n,i("transitionTimingFunction"),i("transitionDuration"),i("transitionDelay");var s=i("transformOrigin");i("transitionEnd"),i("transitionProperty");function a(o){if(o instanceof window.SVGElement){var t=o.getBoundingClientRect();return{top:t.top,left:t.left,width:t.width,height:t.height}}return{top:o.offsetTop,left:o.offsetLeft,width:o.offsetWidth,height:o.offsetHeight}}var d={style:"cubic-bezier(0.165, 0.84, 0.44, 1)",fn:function(o){return 1- --o*o*o*o}},l=r&&window;function c(){}var v=r?l.requestAnimationFrame||l.webkitRequestAnimationFrame||l.mozRequestAnimationFrame||l.oRequestAnimationFrame||function(o){return window.setTimeout(o,(o.interval||1e3/60)/2)}:c,y=r?l.cancelAnimationFrame||l.webkitCancelAnimationFrame||l.mozCancelAnimationFrame||l.oCancelAnimationFrame||function(o){window.clearTimeout(o)}:c;function h(o){this.scroll=o,this.scale=1,this.prevScale=1,this.init()}return h.prototype.init=function(){this.handleBScroll(),this.handleOptions(),this.handleHooks(),this.tryInitialZoomTo(this.zoomOpt)},h.prototype.zoomTo=function(o,t,e,r){var n=this.resolveOrigin(t,e),i={x:n.originX,y:n.originY,baseScale:this.scale};this._doZoomTo(o,i,r,!0)},h.prototype.handleBScroll=function(){this.scroll.proxy(o),this.scroll.registerType(["beforeZoomStart","zoomStart","zooming","zoomEnd"])},h.prototype.handleOptions=function(){var o=!0===this.scroll.options.zoom?{}:this.scroll.options.zoom;this.zoomOpt=function(o,t){for(var e in t)o[e]=t[e];return o}({start:1,min:1,max:4,initialOrigin:[0,0],minimalZoomDistance:5,bounceTime:800},o)},h.prototype.handleHooks=function(){var r=this,o=this.scroll,t=this.scroll.scroller;this.wrapper=this.scroll.scroller.wrapper,this.setTransformOrigin(this.scroll.scroller.content);var e=t.scrollBehaviorX,n=t.scrollBehaviorY;this.hooksFn=[],this.registerHooks(o.hooks,o.hooks.eventTypes.contentChanged,function(o){r.setTransformOrigin(o),r.scale=1,r.tryInitialZoomTo(r.zoomOpt)}),this.registerHooks(o.hooks,o.hooks.eventTypes.beforeInitialScrollTo,function(){if(1!==r.zoomOpt.start)return!0}),this.registerHooks(e.hooks,e.hooks.eventTypes.beforeComputeBoundary,function(){var o=a(r.scroll.scroller.content);e.contentSize=Math.floor(o.width*r.scale)}),this.registerHooks(n.hooks,n.hooks.eventTypes.beforeComputeBoundary,function(){var o=a(r.scroll.scroller.content);n.contentSize=Math.floor(o.height*r.scale)}),this.registerHooks(t.actions.hooks,t.actions.hooks.eventTypes.start,function(o){var t=o.touches&&o.touches.length||0;r.fingersOperation(t),2===t&&r.zoomStart(o)}),this.registerHooks(t.actions.hooks,t.actions.hooks.eventTypes.beforeMove,function(o){var t=o.touches&&o.touches.length||0;if(r.fingersOperation(t),2===t)return r.zoom(o),!0}),this.registerHooks(t.actions.hooks
|