-
-
Save IllyaMoskvin/76f40ed7057e23b1952633d8ff7c5668 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(e, t, n) { | |
"use strict"; | |
function i(e) { | |
return e && e.__esModule ? e : { | |
"default": e | |
} | |
} | |
Object.defineProperty(t, "__esModule", { | |
value: !0 | |
}); | |
var r = n(1), | |
o = i(r), | |
a = n(7); | |
i(a); | |
n(136), n(135); | |
var s = window.OpenSeadragon; | |
t["default"] = o["default"].module("hj.customSeadragon", []).directive("hjCustomSeadragon", ["$window", "$document", function(e, t) { | |
return { | |
restrict: "AE", | |
scope: { | |
dzi: "=", | |
focusPoint: "=?", | |
zoomLevel: "=?", | |
disabled: "=?" | |
}, | |
controllerAs: "vm", | |
bindToController: !0, | |
template: '<hj-open-seadragon\n tile-sources="vm.dzi"\n options="vm.openSeadragonOptions"\n ></hj-open-seadragon>', | |
controller: ["$rootScope", "$scope", "$element", "$window", "$timeout", function(e, n, i, r, a) { | |
"ngInject"; | |
var l = this, | |
c = "ontouchstart" in r, | |
u = 80, | |
d = 1e3, | |
p = c ? 0 : 5, | |
h = c ? 0 : 1, | |
f = 1, | |
m = 0, | |
g = !1, | |
v = !1, | |
y = void 0, | |
w = void 0, | |
b = void 0, | |
S = void 0, | |
T = void 0, | |
E = void 0, | |
O = void 0, | |
x = void 0, | |
I = void 0, | |
_ = i.children(); | |
l.zoomLevel = l.zoomLevel || 2; | |
var C = new Lethargy; | |
l.openSeadragonOptions = { | |
constrainDuringPan: !0, | |
visibilityRatio: 1, | |
minZoomLevel: 1, | |
defaultZoomLevel: 1, | |
maxZoomPixelRatio: .5, | |
homeFillsViewer: !0, | |
showZoomControl: !1, | |
showHomeControl: !1, | |
showFullPageControl: !1, | |
animationTime: p, | |
panHorizontal: c, | |
panVertical: c, | |
mouseNavEnabled: !!c, | |
gestureSettingsTouch: { | |
flickEnabled: !1 | |
} | |
}; | |
var $ = function(e, t) { | |
var n = e.viewport.containerSize, | |
i = e.viewport.contentSize, | |
r = e.viewport.viewportToImageZoom(e.viewport.getZoom()), | |
o = e.viewport.getBounds(), | |
a = { | |
x: (i.x - n.x * (1 / r)) / i.x, | |
y: (i.y - n.y * (1 / r)) / i.x | |
}, | |
l = new s.Point; | |
l.x = t.x * a.x, l.y = t.y * a.y, l.x = l.x + .5 * o.width, l.y = l.y + .5 * o.height, e.viewport.panTo(l) | |
}; | |
b = function(e, t) { | |
var n = e.viewport.containerSize, | |
i = e.viewport.contentSize, | |
r = e.viewport.viewportToImageZoom(e.viewport.getZoom()); | |
if (!(i.x * r < n.x - 1 || i.y * r < n.y - 1 || 0 === l.zoomLevel)) { | |
var o = t.clientX / n.x, | |
a = t.clientY / n.y; | |
$(e, { | |
x: o, | |
y: a | |
}) | |
} | |
}; | |
var R = [120, 120, 120], | |
P = function(e, t) { | |
return Math.floor(e / t) === e / t | |
}, | |
A = function(e) { | |
if (e) { | |
e = Math.abs(e), R.push(e), R.shift(); | |
var t = P(R[0], 120) && P(R[1], 120) && P(R[2], 120); | |
return !t | |
} | |
}; | |
S = function(e, t) { | |
if (!l.disabled && !g && (t = t.originalEvent || t, t.preventDefault(), t.deltaY !== -0)) { | |
var n = A(t.wheelDeltaY || t.wheelDelta || t.detail || 0), | |
i = void 0; | |
n ? (t.originalEvent || (t.originalEvent = t), i = C.check(t)) : i = Hamster.normalise.delta(t)[2] > 0 ? 1 : -1, i !== !1 && (g = !0, a.cancel(I), I = a(function() { | |
g = !1 | |
}, n ? d : 0), w(e, Math.max(0, l.zoomLevel + i))) | |
} | |
}, w = function(e, t) { | |
var n = arguments.length <= 2 || void 0 === arguments[2] ? !1 : arguments[2], | |
i = e.viewport.containerSize, | |
o = e.viewport.contentSize, | |
s = Math.min(o.x / i.x, o.y / i.y) / ((r.devicePixelRatio || 1) * f), | |
c = Math.round(s); | |
t > c && (t = n ? 0 : c), a(function() { | |
if (l.zoomLevel = Math.max(m, t), l.zoomLevel === c ? _.addClass("max-zoom") : _.removeClass("max-zoom"), 0 === l.zoomLevel) e.viewport.centerSpringX.animationTime = e.viewport.centerSpringY.animationTime = h, y(e); | |
else if (1 === l.zoomLevel) { | |
e.viewport.centerSpringX.animationTime = e.viewport.centerSpringY.animationTime = h, a(function() { | |
e.viewport.centerSpringX.animationTime = e.viewport.centerSpringY.animationTime = p | |
}); | |
var n = i.x / i.x, | |
r = o.x / o.y / (i.x / i.y), | |
u = Math.max(n, r); | |
e.viewport.zoomTo(u) | |
} else l.zoomLevel === c ? (e.viewport.centerSpringX.animationTime = e.viewport.centerSpringY.animationTime = p, e.viewport.zoomTo(s)) : (e.viewport.centerSpringX.animationTime = e.viewport.centerSpringY.animationTime = p, e.viewport.zoomTo(l.zoomLevel)) | |
}) | |
}, y = function(e, t) { | |
var n = new s.Point; | |
n.x = .5, n.y = e.viewport.contentAspectY / 2; | |
var i = e.viewport.containerSize, | |
r = e.viewport.contentSize, | |
o = (i.x - 2 * u) / i.x, | |
a = r.x / r.y / (i.x / (i.y - 2 * u)), | |
l = Math.min(o, a); | |
e.viewport.panTo(n).zoomTo(l) | |
}; | |
var k = function(e) { | |
c || (T = b.bind(null, e), E = S.bind(null, e), O = y.bind(null, e), t.on("mousemove", T), t.on("mousewheel", E), t.on("DOMMouseScroll", E), o["default"].element(e.container).on("click", function() { | |
w(e, l.zoomLevel + 1, !0) | |
})) | |
}, | |
N = function(e, t) { | |
v || (v = !0, _.addClass("ready"), n.$emit("hjCustomSeadragon:ready"), e.viewport.centerSpringX.animationTime = e.viewport.centerSpringY.animationTime = 0, l.zoomLevel > 0 && $(e, l.focusPoint || { | |
x: .5, | |
y: .5 | |
}), a(function() { | |
e.viewport.centerSpringX.animationTime = e.viewport.centerSpringY.animationTime = p | |
}), k(e)) | |
}, | |
D = function L(e) { | |
var t = e.eventSource.viewer; | |
t.world.getItemAt(0).removeHandler("fully-loaded", L), N(t, "fully-loaded") | |
}, | |
M = function(e) { | |
r.vp = e.viewport, e.world.getItemAt(0).addHandler("fully-loaded", D), e.viewport.zoomSpring.animationTime = 0, w(e, l.zoomLevel), e.viewport.zoomSpring.animationTime = h | |
}; | |
n.$on("hjOpenSeadragon:tile-loaded", function(e, t) { | |
var n = t.eventSource; | |
a.cancel(x), x = a(function() { | |
var e = !0, | |
i = t.tile.level; | |
o["default"].forEach(t.tiledImage.tilesMatrix[i], function(t) { | |
o["default"].forEach(t, function(t) { | |
t.loaded || (e = !1) | |
}) | |
}), e && N(n, "tile-loaded") | |
}) | |
}), n.$on("hjOpenSeadragon:open", function(e, t) { | |
M(t.eventSource) | |
}), n.$on("$destroy", function() { | |
t.off("mousemove", T), t.off("mousewheel", E), t.off("DOMMouseScroll", E) | |
}) | |
}] | |
} | |
}]) | |
}, | |
function(e, t, n) { | |
"use strict"; | |
function i(e) { | |
return e && e.__esModule ? e : { | |
"default": e | |
} | |
} | |
Object.defineProperty(t, "__esModule", { | |
value: !0 | |
}); | |
var r = n(1), | |
o = i(r), | |
a = n(7), | |
s = (i(a), window.OpenSeadragon); | |
t["default"] = o["default"].module("hj.openSeadragon", []).directive("hjOpenSeadragon", ["$window", "$document", function(e, t) { | |
return { | |
restrict: "AE", | |
scope: { | |
tileSources: "=", | |
options: "=?" | |
}, | |
link: function(e, t, n) { | |
var i = { | |
element: t[0], | |
tileSources: e.tileSources, | |
prefixUrl: "" | |
}, | |
r = o["default"].extend(i, e.options), | |
a = function() { | |
var t = s(r), | |
n = ["open", "tile-loaded", "tile-drawn"]; | |
n.forEach(function(n) { | |
t.addHandler(n, function(t) { | |
e.$emit("hjOpenSeadragon:" + n, t) | |
}) | |
}) | |
}; | |
e.$watch("tileSources", function(e) { | |
e && (r.tileSources = e, a()) | |
}) | |
} | |
} | |
}]) | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment