| 1 | //#region plugin/zoom/plugin.js |
| 2 | var e = { |
| 3 | id: "zoom", |
| 4 | init: function(e) { |
| 5 | e.getRevealElement().addEventListener("mousedown", function(t) { |
| 6 | var r = /Linux/.test(window.navigator.platform) ? "ctrl" : "alt", i = (e.getConfig().zoomKey ? e.getConfig().zoomKey : r) + "Key", a = e.getConfig().zoomLevel ? e.getConfig().zoomLevel : 2; |
| 7 | t[i] && !e.isOverview() && (t.preventDefault(), n.to({ |
| 8 | x: t.clientX, |
| 9 | y: t.clientY, |
| 10 | scale: a, |
| 11 | pan: !1 |
| 12 | })); |
| 13 | }); |
| 14 | }, |
| 15 | destroy: () => { |
| 16 | n.reset(); |
| 17 | } |
| 18 | }, t = () => e, n = (function() { |
| 19 | var e = 1, t = 0, r = 0, i = -1, a = -1, o = "transform" in document.body.style; |
| 20 | o && (document.body.style.transition = "transform 0.8s ease"), document.addEventListener("keyup", function(t) { |
| 21 | e !== 1 && t.keyCode === 27 && n.out(); |
| 22 | }), document.addEventListener("mousemove", function(n) { |
| 23 | e !== 1 && (t = n.clientX, r = n.clientY); |
| 24 | }); |
| 25 | function s(t, n) { |
| 26 | var r = l(); |
| 27 | if (t.width = t.width || 1, t.height = t.height || 1, t.x -= (window.innerWidth - t.width * n) / 2, t.y -= (window.innerHeight - t.height * n) / 2, o) if (n === 1) document.body.style.transform = ""; |
| 28 | else { |
| 29 | var i = r.x + "px " + r.y + "px", a = "translate(" + -t.x + "px," + -t.y + "px) scale(" + n + ")"; |
| 30 | document.body.style.transformOrigin = i, document.body.style.transform = a; |
| 31 | } |
| 32 | else n === 1 ? (document.body.style.position = "", document.body.style.left = "", document.body.style.top = "", document.body.style.width = "", document.body.style.height = "", document.body.style.zoom = "") : (document.body.style.position = "relative", document.body.style.left = -(r.x + t.x) / n + "px", document.body.style.top = -(r.y + t.y) / n + "px", document.body.style.width = n * 100 + "%", document.body.style.height = n * 100 + "%", document.body.style.zoom = n); |
| 33 | e = n, document.documentElement.classList && (e === 1 ? document.documentElement.classList.remove("zoomed") : document.documentElement.classList.add("zoomed")); |
| 34 | } |
| 35 | function c() { |
| 36 | var n = .12, i = window.innerWidth * n, a = window.innerHeight * n, o = l(); |
| 37 | r < a ? window.scroll(o.x, o.y - (1 - r / a) * (14 / e)) : r > window.innerHeight - a && window.scroll(o.x, o.y + (1 - (window.innerHeight - r) / a) * (14 / e)), t < i ? window.scroll(o.x - (1 - t / i) * (14 / e), o.y) : t > window.innerWidth - i && window.scroll(o.x + (1 - (window.innerWidth - t) / i) * (14 / e), o.y); |
| 38 | } |
| 39 | function l() { |
| 40 | return { |
| 41 | x: window.scrollX === void 0 ? window.pageXOffset : window.scrollX, |
| 42 | y: window.scrollY === void 0 ? window.pageYOffset : window.scrollY |
| 43 | }; |
| 44 | } |
| 45 | return { |
| 46 | to: function(t) { |
| 47 | if (e !== 1) n.out(); |
| 48 | else { |
| 49 | if (t.x = t.x || 0, t.y = t.y || 0, t.element) { |
| 50 | var r = 20, o = t.element.getBoundingClientRect(); |
| 51 | t.x = o.left - r, t.y = o.top - r, t.width = o.width + r * 2, t.height = o.height + r * 2; |
| 52 | } |
| 53 | t.width !== void 0 && t.height !== void 0 && (t.scale = Math.max(Math.min(window.innerWidth / t.width, window.innerHeight / t.height), 1)), t.scale > 1 && (t.x *= t.scale, t.y *= t.scale, s(t, t.scale), t.pan !== !1 && (i = setTimeout(function() { |
| 54 | a = setInterval(c, 1e3 / 60); |
| 55 | }, 800))); |
| 56 | } |
| 57 | }, |
| 58 | out: function() { |
| 59 | clearTimeout(i), clearInterval(a), s({ |
| 60 | x: 0, |
| 61 | y: 0 |
| 62 | }, 1), e = 1; |
| 63 | }, |
| 64 | magnify: function(e) { |
| 65 | this.to(e); |
| 66 | }, |
| 67 | reset: function() { |
| 68 | this.out(); |
| 69 | }, |
| 70 | zoomLevel: function() { |
| 71 | return e; |
| 72 | } |
| 73 | }; |
| 74 | })(), r = t; |
| 75 | //#endregion |
| 76 | export { r as default }; |
| 77 |