svg-pan-zoom.min.js 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151
  1. // svg-pan-zoom v3.6.1
  2. // https://github.com/ariutta/svg-pan-zoom
  3. !function s(r, a, l) {
  4. function u(e, t) {
  5. if (!a[e]) {
  6. if (!r[e]) {
  7. var o = "function" == typeof require && require;
  8. if (!t && o)
  9. return o(e, !0);
  10. if (h)
  11. return h(e, !0);
  12. var n = new Error("Cannot find module '" + e + "'");
  13. throw n.code = "MODULE_NOT_FOUND",
  14. n
  15. }
  16. var i = a[e] = {
  17. exports: {}
  18. };
  19. r[e][0].call(i.exports, function(t) {
  20. return u(r[e][1][t] || t)
  21. }, i, i.exports, s, r, a, l)
  22. }
  23. return a[e].exports
  24. }
  25. for (var h = "function" == typeof require && require, t = 0; t < l.length; t++)
  26. u(l[t]);
  27. return u
  28. }({
  29. 1: [function(t, e, o) {
  30. var s = t("./svg-utilities");
  31. e.exports = {
  32. enable: function(t) {
  33. var e = t.svg.querySelector("defs");
  34. if (e || (e = document.createElementNS(s.svgNS, "defs"),
  35. t.svg.appendChild(e)),
  36. !e.querySelector("style#svg-pan-zoom-controls-styles")) {
  37. var o = document.createElementNS(s.svgNS, "style");
  38. o.setAttribute("id", "svg-pan-zoom-controls-styles"),
  39. o.setAttribute("type", "text/css"),
  40. o.textContent = ".svg-pan-zoom-control { cursor: pointer; fill: black; fill-opacity: 0.333; } .svg-pan-zoom-control:hover { fill-opacity: 0.8; } .svg-pan-zoom-control-background { fill: white; fill-opacity: 0.5; } .svg-pan-zoom-control-background { fill-opacity: 0.8; }",
  41. e.appendChild(o)
  42. }
  43. var n = document.createElementNS(s.svgNS, "g");
  44. n.setAttribute("id", "svg-pan-zoom-controls"),
  45. n.setAttribute("transform", "translate(" + (t.width - 70) + " " + (t.height - 76) + ") scale(0.75)"),
  46. n.setAttribute("class", "svg-pan-zoom-control"),
  47. n.appendChild(this._createZoomIn(t)),
  48. n.appendChild(this._createZoomReset(t)),
  49. n.appendChild(this._createZoomOut(t)),
  50. t.svg.appendChild(n),
  51. t.controlIcons = n
  52. },
  53. _createZoomIn: function(t) {
  54. var e = document.createElementNS(s.svgNS, "g");
  55. e.setAttribute("id", "svg-pan-zoom-zoom-in"),
  56. e.setAttribute("transform", "translate(30.5 5) scale(0.015)"),
  57. e.setAttribute("class", "svg-pan-zoom-control"),
  58. e.addEventListener("click", function() {
  59. // t.getPublicInstance().zoomIn()
  60. }, !1),
  61. e.addEventListener("touchstart", function() {
  62. // t.getPublicInstance().zoomIn()
  63. }, !1);
  64. var o = document.createElementNS(s.svgNS, "rect");
  65. o.setAttribute("x", "0"),
  66. o.setAttribute("y", "0"),
  67. o.setAttribute("width", "1500"),
  68. o.setAttribute("height", "1400"),
  69. o.setAttribute("class", "svg-pan-zoom-control-background"),
  70. e.appendChild(o);
  71. var n = document.createElementNS(s.svgNS, "path");
  72. return n.setAttribute("d", "M1280 576v128q0 26 -19 45t-45 19h-320v320q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45v-320h-320q-26 0 -45 -19t-19 -45v-128q0 -26 19 -45t45 -19h320v-320q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v320h320q26 0 45 19t19 45zM1536 1120v-960 q0 -119 -84.5 -203.5t-203.5 -84.5h-960q-119 0 -203.5 84.5t-84.5 203.5v960q0 119 84.5 203.5t203.5 84.5h960q119 0 203.5 -84.5t84.5 -203.5z"),
  73. n.setAttribute("class", "svg-pan-zoom-control-element"),
  74. e.appendChild(n),
  75. e
  76. },
  77. _createZoomReset: function(t) {
  78. var e = document.createElementNS(s.svgNS, "g");
  79. e.setAttribute("id", "svg-pan-zoom-reset-pan-zoom"),
  80. e.setAttribute("transform", "translate(5 35) scale(0.4)"),
  81. e.setAttribute("class", "svg-pan-zoom-control"),
  82. e.addEventListener("click", function() {
  83. t.getPublicInstance().reset()
  84. }, !1),
  85. e.addEventListener("touchstart", function() {
  86. t.getPublicInstance().reset()
  87. }, !1);
  88. var o = document.createElementNS(s.svgNS, "rect");
  89. o.setAttribute("x", "2"),
  90. o.setAttribute("y", "2"),
  91. o.setAttribute("width", "182"),
  92. o.setAttribute("height", "58"),
  93. o.setAttribute("class", "svg-pan-zoom-control-background"),
  94. e.appendChild(o);
  95. var n = document.createElementNS(s.svgNS, "path");
  96. n.setAttribute("d", "M33.051,20.632c-0.742-0.406-1.854-0.609-3.338-0.609h-7.969v9.281h7.769c1.543,0,2.701-0.188,3.473-0.562c1.365-0.656,2.048-1.953,2.048-3.891C35.032,22.757,34.372,21.351,33.051,20.632z"),
  97. n.setAttribute("class", "svg-pan-zoom-control-element"),
  98. e.appendChild(n);
  99. var i = document.createElementNS(s.svgNS, "path");
  100. return i.setAttribute("d", "M170.231,0.5H15.847C7.102,0.5,0.5,5.708,0.5,11.84v38.861C0.5,56.833,7.102,61.5,15.847,61.5h154.384c8.745,0,15.269-4.667,15.269-10.798V11.84C185.5,5.708,178.976,0.5,170.231,0.5z M42.837,48.569h-7.969c-0.219-0.766-0.375-1.383-0.469-1.852c-0.188-0.969-0.289-1.961-0.305-2.977l-0.047-3.211c-0.03-2.203-0.41-3.672-1.142-4.406c-0.732-0.734-2.103-1.102-4.113-1.102h-7.05v13.547h-7.055V14.022h16.524c2.361,0.047,4.178,0.344,5.45,0.891c1.272,0.547,2.351,1.352,3.234,2.414c0.731,0.875,1.31,1.844,1.737,2.906s0.64,2.273,0.64,3.633c0,1.641-0.414,3.254-1.242,4.84s-2.195,2.707-4.102,3.363c1.594,0.641,2.723,1.551,3.387,2.73s0.996,2.98,0.996,5.402v2.32c0,1.578,0.063,2.648,0.19,3.211c0.19,0.891,0.635,1.547,1.333,1.969V48.569z M75.579,48.569h-26.18V14.022h25.336v6.117H56.454v7.336h16.781v6H56.454v8.883h19.125V48.569z M104.497,46.331c-2.44,2.086-5.887,3.129-10.34,3.129c-4.548,0-8.125-1.027-10.731-3.082s-3.909-4.879-3.909-8.473h6.891c0.224,1.578,0.662,2.758,1.316,3.539c1.196,1.422,3.246,2.133,6.15,2.133c1.739,0,3.151-0.188,4.236-0.562c2.058-0.719,3.087-2.055,3.087-4.008c0-1.141-0.504-2.023-1.512-2.648c-1.008-0.609-2.607-1.148-4.796-1.617l-3.74-0.82c-3.676-0.812-6.201-1.695-7.576-2.648c-2.328-1.594-3.492-4.086-3.492-7.477c0-3.094,1.139-5.664,3.417-7.711s5.623-3.07,10.036-3.07c3.685,0,6.829,0.965,9.431,2.895c2.602,1.93,3.966,4.73,4.093,8.402h-6.938c-0.128-2.078-1.057-3.555-2.787-4.43c-1.154-0.578-2.587-0.867-4.301-0.867c-1.907,0-3.428,0.375-4.565,1.125c-1.138,0.75-1.706,1.797-1.706,3.141c0,1.234,0.561,2.156,1.682,2.766c0.721,0.406,2.25,0.883,4.589,1.43l6.063,1.43c2.657,0.625,4.648,1.461,5.975,2.508c2.059,1.625,3.089,3.977,3.089,7.055C108.157,41.624,106.937,44.245,104.497,46.331z M139.61,48.569h-26.18V14.022h25.336v6.117h-18.281v7.336h16.781v6h-16.781v8.883h19.125V48.569z M170.337,20.14h-10.336v28.43h-7.266V20.14h-10.383v-6.117h27.984V20.14z"),
  101. i.setAttribute("class", "svg-pan-zoom-control-element"),
  102. e.appendChild(i),
  103. e
  104. },
  105. _createZoomOut: function(t) {
  106. var e = document.createElementNS(s.svgNS, "g");
  107. e.setAttribute("id", "svg-pan-zoom-zoom-out"),
  108. e.setAttribute("transform", "translate(30.5 70) scale(0.015)"),
  109. e.setAttribute("class", "svg-pan-zoom-control"),
  110. e.addEventListener("click", function() {
  111. t.getPublicInstance().zoomOut()
  112. }, !1),
  113. e.addEventListener("touchstart", function() {
  114. t.getPublicInstance().zoomOut()
  115. }, !1);
  116. var o = document.createElementNS(s.svgNS, "rect");
  117. o.setAttribute("x", "0"),
  118. o.setAttribute("y", "0"),
  119. o.setAttribute("width", "1500"),
  120. o.setAttribute("height", "1400"),
  121. o.setAttribute("class", "svg-pan-zoom-control-background"),
  122. e.appendChild(o);
  123. var n = document.createElementNS(s.svgNS, "path");
  124. return n.setAttribute("d", "M1280 576v128q0 26 -19 45t-45 19h-896q-26 0 -45 -19t-19 -45v-128q0 -26 19 -45t45 -19h896q26 0 45 19t19 45zM1536 1120v-960q0 -119 -84.5 -203.5t-203.5 -84.5h-960q-119 0 -203.5 84.5t-84.5 203.5v960q0 119 84.5 203.5t203.5 84.5h960q119 0 203.5 -84.5 t84.5 -203.5z"),
  125. n.setAttribute("class", "svg-pan-zoom-control-element"),
  126. e.appendChild(n),
  127. e
  128. },
  129. disable: function(t) {
  130. t.controlIcons && (t.controlIcons.parentNode.removeChild(t.controlIcons),
  131. t.controlIcons = null)
  132. }
  133. }
  134. }
  135. , {
  136. "./svg-utilities": 5
  137. }],
  138. 2: [function(t, e, o) {
  139. function n(t, e) {
  140. this.init(t, e)
  141. }
  142. var i = t("./svg-utilities")
  143. , r = t("./utilities");
  144. n.prototype.init = function(t, e) {
  145. this.viewport = t,
  146. this.options = e,
  147. this.originalState = {
  148. zoom: 1,
  149. x: 0,
  150. y: 0
  151. },
  152. this.activeState = {
  153. zoom: 1,
  154. x: 0,
  155. y: 0
  156. },
  157. this.updateCTMCached = r.proxy(this.updateCTM, this),
  158. this.requestAnimationFrame = r.createRequestAnimationFrame(this.options.refreshRate),
  159. this.viewBox = {
  160. x: 0,
  161. y: 0,
  162. width: 0,
  163. height: 0
  164. },
  165. this.cacheViewBox();
  166. var o = this.processCTM();
  167. this.setCTM(o),
  168. this.updateCTM()
  169. }
  170. ,
  171. n.prototype.cacheViewBox = function() {
  172. var t = this.options.svg.getAttribute("viewBox");
  173. if (t) {
  174. var e = t.split(/[\s\,]/).filter(function(t) {
  175. return t
  176. }).map(parseFloat);
  177. this.viewBox.x = e[0],
  178. this.viewBox.y = e[1],
  179. this.viewBox.width = e[2],
  180. this.viewBox.height = e[3];
  181. var o = Math.min(this.options.width / this.viewBox.width, this.options.height / this.viewBox.height);
  182. this.activeState.zoom = o,
  183. this.activeState.x = (this.options.width - this.viewBox.width * o) / 2,
  184. this.activeState.y = (this.options.height - this.viewBox.height * o) / 2,
  185. this.updateCTMOnNextFrame(),
  186. this.options.svg.removeAttribute("viewBox")
  187. } else
  188. this.simpleViewBoxCache()
  189. }
  190. ,
  191. n.prototype.simpleViewBoxCache = function() {
  192. var t = this.viewport.getBBox();
  193. this.viewBox.x = t.x,
  194. this.viewBox.y = t.y,
  195. this.viewBox.width = t.width,
  196. this.viewBox.height = t.height
  197. }
  198. ,
  199. n.prototype.getViewBox = function() {
  200. return r.extend({}, this.viewBox)
  201. }
  202. ,
  203. n.prototype.processCTM = function() {
  204. var t, e = this.getCTM();
  205. (this.options.fit || this.options.contain) && (t = this.options.fit ? Math.min(this.options.width / this.viewBox.width, this.options.height / this.viewBox.height) : Math.max(this.options.width / this.viewBox.width, this.options.height / this.viewBox.height),
  206. e.a = t,
  207. e.d = t,
  208. e.e = -this.viewBox.x * t,
  209. e.f = -this.viewBox.y * t);
  210. if (this.options.center) {
  211. var o = .5 * (this.options.width - (this.viewBox.width + 2 * this.viewBox.x) * e.a)
  212. , n = .5 * (this.options.height - (this.viewBox.height + 2 * this.viewBox.y) * e.a);
  213. e.e = o,
  214. e.f = n
  215. }
  216. return this.originalState.zoom = e.a,
  217. this.originalState.x = e.e,
  218. this.originalState.y = e.f,
  219. e
  220. }
  221. ,
  222. n.prototype.getOriginalState = function() {
  223. return r.extend({}, this.originalState)
  224. }
  225. ,
  226. n.prototype.getState = function() {
  227. return r.extend({}, this.activeState)
  228. }
  229. ,
  230. n.prototype.getZoom = function() {
  231. return this.activeState.zoom
  232. }
  233. ,
  234. n.prototype.getRelativeZoom = function() {
  235. return this.activeState.zoom / this.originalState.zoom
  236. }
  237. ,
  238. n.prototype.computeRelativeZoom = function(t) {
  239. return t / this.originalState.zoom
  240. }
  241. ,
  242. n.prototype.getPan = function() {
  243. return {
  244. x: this.activeState.x,
  245. y: this.activeState.y
  246. }
  247. }
  248. ,
  249. n.prototype.getCTM = function() {
  250. var t = this.options.svg.createSVGMatrix();
  251. return t.a = this.activeState.zoom,
  252. t.b = 0,
  253. t.c = 0,
  254. t.d = this.activeState.zoom,
  255. t.e = this.activeState.x,
  256. t.f = this.activeState.y,
  257. t
  258. }
  259. ,
  260. n.prototype.setCTM = function(t) {
  261. var e = this.isZoomDifferent(t)
  262. , o = this.isPanDifferent(t);
  263. if (e || o) {
  264. if (e && (!1 === this.options.beforeZoom(this.getRelativeZoom(), this.computeRelativeZoom(t.a)) ? (t.a = t.d = this.activeState.zoom,
  265. e = !1) : (this.updateCache(t),
  266. this.options.onZoom(this.getRelativeZoom()))),
  267. o) {
  268. var n = this.options.beforePan(this.getPan(), {
  269. x: t.e,
  270. y: t.f
  271. })
  272. , i = !1
  273. , s = !1;
  274. !1 === n ? (t.e = this.getPan().x,
  275. t.f = this.getPan().y,
  276. i = s = !0) : r.isObject(n) && (!1 === n.x ? (t.e = this.getPan().x,
  277. i = !0) : r.isNumber(n.x) && (t.e = n.x),
  278. !1 === n.y ? (t.f = this.getPan().y,
  279. s = !0) : r.isNumber(n.y) && (t.f = n.y)),
  280. i && s || !this.isPanDifferent(t) ? o = !1 : (this.updateCache(t),
  281. this.options.onPan(this.getPan()))
  282. }
  283. (e || o) && this.updateCTMOnNextFrame()
  284. }
  285. }
  286. ,
  287. n.prototype.isZoomDifferent = function(t) {
  288. return this.activeState.zoom !== t.a
  289. }
  290. ,
  291. n.prototype.isPanDifferent = function(t) {
  292. return this.activeState.x !== t.e || this.activeState.y !== t.f
  293. }
  294. ,
  295. n.prototype.updateCache = function(t) {
  296. this.activeState.zoom = t.a,
  297. this.activeState.x = t.e,
  298. this.activeState.y = t.f
  299. }
  300. ,
  301. n.prototype.pendingUpdate = !1,
  302. n.prototype.updateCTMOnNextFrame = function() {
  303. this.pendingUpdate || (this.pendingUpdate = !0,
  304. this.requestAnimationFrame.call(window, this.updateCTMCached))
  305. }
  306. ,
  307. n.prototype.updateCTM = function() {
  308. var t = this.getCTM();
  309. i.setCTM(this.viewport, t, this.defs),
  310. this.pendingUpdate = !1,
  311. this.options.onUpdatedCTM && this.options.onUpdatedCTM(t)
  312. }
  313. ,
  314. e.exports = function(t, e) {
  315. return new n(t,e)
  316. }
  317. }
  318. , {
  319. "./svg-utilities": 5,
  320. "./utilities": 7
  321. }],
  322. 3: [function(t, e, o) {
  323. var n, i = t("./svg-pan-zoom.js");
  324. n = window,
  325. document,
  326. "function" == typeof define && define.amd ? define("svg-pan-zoom", function() {
  327. return i
  328. }) : void 0 !== e && e.exports && (e.exports = i,
  329. n.svgPanZoom = i)
  330. }
  331. , {
  332. "./svg-pan-zoom.js": 4
  333. }],
  334. 4: [function(t, e, o) {
  335. function i(t, e) {
  336. this.init(t, e)
  337. }
  338. var n = t("./uniwheel")
  339. , s = t("./control-icons")
  340. , r = t("./utilities")
  341. , a = t("./svg-utilities")
  342. , l = t("./shadow-viewport")
  343. , u = {
  344. viewportSelector: ".svg-pan-zoom_viewport",
  345. panEnabled: !0,
  346. controlIconsEnabled: !1,
  347. zoomEnabled: !0,
  348. dblClickZoomEnabled: !0,
  349. mouseWheelZoomEnabled: !0,
  350. preventMouseEventsDefault: !0,
  351. zoomScaleSensitivity: .1,
  352. minZoom: .5,
  353. maxZoom: 10,
  354. fit: !0,
  355. contain: !1,
  356. center: !0,
  357. refreshRate: "auto",
  358. beforeZoom: null,
  359. onZoom: null,
  360. beforePan: null,
  361. onPan: null,
  362. customEventsHandler: null,
  363. eventsListenerElement: null,
  364. onUpdatedCTM: null
  365. }
  366. , h = {
  367. passive: !0
  368. };
  369. i.prototype.init = function(t, e) {
  370. var o = this;
  371. this.svg = t,
  372. this.defs = t.querySelector("defs"),
  373. a.setupSvgAttributes(this.svg),
  374. this.options = r.extend(r.extend({}, u), e),
  375. this.state = "none";
  376. var n = a.getBoundingClientRectNormalized(t);
  377. this.width = n.width,
  378. this.height = n.height,
  379. this.viewport = l(a.getOrCreateViewport(this.svg, this.options.viewportSelector), {
  380. svg: this.svg,
  381. width: this.width,
  382. height: this.height,
  383. fit: this.options.fit,
  384. contain: this.options.contain,
  385. center: this.options.center,
  386. refreshRate: this.options.refreshRate,
  387. beforeZoom: function(t, e) {
  388. if (o.viewport && o.options.beforeZoom)
  389. return o.options.beforeZoom(t, e)
  390. },
  391. onZoom: function(t) {
  392. if (o.viewport && o.options.onZoom)
  393. return o.options.onZoom(t)
  394. },
  395. beforePan: function(t, e) {
  396. if (o.viewport && o.options.beforePan)
  397. return o.options.beforePan(t, e)
  398. },
  399. onPan: function(t) {
  400. if (o.viewport && o.options.onPan)
  401. return o.options.onPan(t)
  402. },
  403. onUpdatedCTM: function(t) {
  404. if (o.viewport && o.options.onUpdatedCTM)
  405. return o.options.onUpdatedCTM(t)
  406. }
  407. });
  408. var i = this.getPublicInstance();
  409. i.setBeforeZoom(this.options.beforeZoom),
  410. i.setOnZoom(this.options.onZoom),
  411. i.setBeforePan(this.options.beforePan),
  412. i.setOnPan(this.options.onPan),
  413. i.setOnUpdatedCTM(this.options.onUpdatedCTM),
  414. this.options.controlIconsEnabled && s.enable(this),
  415. this.lastMouseWheelEventTime = Date.now(),
  416. this.setupHandlers()
  417. }
  418. ,
  419. i.prototype.setupHandlers = function() {
  420. var o = this
  421. , n = null;
  422. if (this.eventListeners = {
  423. mousedown: function(t) {
  424. var e = o.handleMouseDown(t, n);
  425. return n = t,
  426. e
  427. },
  428. touchstart: function(t) {
  429. var e = o.handleMouseDown(t, n);
  430. return n = t,
  431. e
  432. },
  433. mouseup: function(t) {
  434. return o.handleMouseUp(t)
  435. },
  436. touchend: function(t) {
  437. return o.handleMouseUp(t)
  438. },
  439. mousemove: function(t) {
  440. return o.handleMouseMove(t)
  441. },
  442. touchmove: function(t) {
  443. return o.handleMouseMove(t)
  444. },
  445. mouseleave: function(t) {
  446. return o.handleMouseUp(t)
  447. },
  448. touchleave: function(t) {
  449. return o.handleMouseUp(t)
  450. },
  451. touchcancel: function(t) {
  452. return o.handleMouseUp(t)
  453. }
  454. },
  455. null != this.options.customEventsHandler) {
  456. this.options.customEventsHandler.init({
  457. svgElement: this.svg,
  458. eventsListenerElement: this.options.eventsListenerElement,
  459. instance: this.getPublicInstance()
  460. });
  461. var t = this.options.customEventsHandler.haltEventListeners;
  462. if (t && t.length)
  463. for (var e = t.length - 1; 0 <= e; e--)
  464. this.eventListeners.hasOwnProperty(t[e]) && delete this.eventListeners[t[e]]
  465. }
  466. for (var i in this.eventListeners)
  467. (this.options.eventsListenerElement || this.svg).addEventListener(i, this.eventListeners[i], !this.options.preventMouseEventsDefault && h);
  468. this.options.mouseWheelZoomEnabled && (this.options.mouseWheelZoomEnabled = !1,
  469. this.enableMouseWheelZoom())
  470. }
  471. ,
  472. i.prototype.enableMouseWheelZoom = function() {
  473. if (!this.options.mouseWheelZoomEnabled) {
  474. var e = this;
  475. this.wheelListener = function(t) {
  476. return e.handleMouseWheel(t)
  477. }
  478. ;
  479. var t = !this.options.preventMouseEventsDefault;
  480. n.on(this.options.eventsListenerElement || this.svg, this.wheelListener, t),
  481. this.options.mouseWheelZoomEnabled = !0
  482. }
  483. }
  484. ,
  485. i.prototype.disableMouseWheelZoom = function() {
  486. if (this.options.mouseWheelZoomEnabled) {
  487. var t = !this.options.preventMouseEventsDefault;
  488. n.off(this.options.eventsListenerElement || this.svg, this.wheelListener, t),
  489. this.options.mouseWheelZoomEnabled = !1
  490. }
  491. }
  492. ,
  493. i.prototype.handleMouseWheel = function(t) {
  494. if (this.options.zoomEnabled && "none" === this.state) {
  495. this.options.preventMouseEventsDefault && (t.preventDefault ? t.preventDefault() : t.returnValue = !1);
  496. var e = t.deltaY || 1
  497. , o = Date.now() - this.lastMouseWheelEventTime
  498. , n = 3 + Math.max(0, 30 - o);
  499. this.lastMouseWheelEventTime = Date.now(),
  500. "deltaMode"in t && 0 === t.deltaMode && t.wheelDelta && (e = 0 === t.deltaY ? 0 : Math.abs(t.wheelDelta) / t.deltaY),
  501. e = -.3 < e && e < .3 ? e : (0 < e ? 1 : -1) * Math.log(Math.abs(e) + 10) / n;
  502. var i = this.svg.getScreenCTM().inverse()
  503. , s = a.getEventPoint(t, this.svg).matrixTransform(i)
  504. , r = Math.pow(1 + this.options.zoomScaleSensitivity, -1 * e);
  505. this.zoomAtPoint(r, s)
  506. }
  507. }
  508. ,
  509. i.prototype.zoomAtPoint = function(t, e, o) {
  510. var n = this.viewport.getOriginalState();
  511. o ? (t = Math.max(this.options.minZoom * n.zoom, Math.min(this.options.maxZoom * n.zoom, t)),
  512. t /= this.getZoom()) : this.getZoom() * t < this.options.minZoom * n.zoom ? t = this.options.minZoom * n.zoom / this.getZoom() : this.getZoom() * t > this.options.maxZoom * n.zoom && (t = this.options.maxZoom * n.zoom / this.getZoom());
  513. var i = this.viewport.getCTM()
  514. , s = e.matrixTransform(i.inverse())
  515. , r = this.svg.createSVGMatrix().translate(s.x, s.y).scale(t).translate(-s.x, -s.y)
  516. , a = i.multiply(r);
  517. a.a !== i.a && this.viewport.setCTM(a)
  518. }
  519. ,
  520. i.prototype.zoom = function(t, e) {
  521. this.zoomAtPoint(t, a.getSvgCenterPoint(this.svg, this.width, this.height), e)
  522. }
  523. ,
  524. i.prototype.publicZoom = function(t, e) {
  525. e && (t = this.computeFromRelativeZoom(t)),
  526. this.zoom(t, e)
  527. }
  528. ,
  529. i.prototype.publicZoomAtPoint = function(t, e, o) {
  530. if (o && (t = this.computeFromRelativeZoom(t)),
  531. "SVGPoint" !== r.getType(e)) {
  532. if (!("x"in e && "y"in e))
  533. throw new Error("Given point is invalid");
  534. e = a.createSVGPoint(this.svg, e.x, e.y)
  535. }
  536. this.zoomAtPoint(t, e, o)
  537. }
  538. ,
  539. i.prototype.getZoom = function() {
  540. return this.viewport.getZoom()
  541. }
  542. ,
  543. i.prototype.getRelativeZoom = function() {
  544. return this.viewport.getRelativeZoom()
  545. }
  546. ,
  547. i.prototype.computeFromRelativeZoom = function(t) {
  548. return t * this.viewport.getOriginalState().zoom
  549. }
  550. ,
  551. i.prototype.resetZoom = function() {
  552. var t = this.viewport.getOriginalState();
  553. this.zoom(t.zoom, !0)
  554. }
  555. ,
  556. i.prototype.resetPan = function() {
  557. this.pan(this.viewport.getOriginalState())
  558. }
  559. ,
  560. i.prototype.reset = function() {
  561. this.resetZoom(),
  562. this.resetPan()
  563. }
  564. ,
  565. i.prototype.handleDblClick = function(t) {
  566. var e;
  567. if ((this.options.preventMouseEventsDefault && (t.preventDefault ? t.preventDefault() : t.returnValue = !1),
  568. this.options.controlIconsEnabled) && -1 < (t.target.getAttribute("class") || "").indexOf("svg-pan-zoom-control"))
  569. return !1;
  570. e = t.shiftKey ? 1 / (2 * (1 + this.options.zoomScaleSensitivity)) : 2 * (1 + this.options.zoomScaleSensitivity);
  571. var o = a.getEventPoint(t, this.svg).matrixTransform(this.svg.getScreenCTM().inverse());
  572. this.zoomAtPoint(e, o)
  573. }
  574. ,
  575. i.prototype.handleMouseDown = function(t, e) {
  576. this.options.preventMouseEventsDefault && (t.preventDefault ? t.preventDefault() : t.returnValue = !1),
  577. r.mouseAndTouchNormalize(t, this.svg),
  578. this.options.dblClickZoomEnabled && r.isDblClick(t, e) ? this.handleDblClick(t) : (this.state = "pan",
  579. this.firstEventCTM = this.viewport.getCTM(),
  580. this.stateOrigin = a.getEventPoint(t, this.svg).matrixTransform(this.firstEventCTM.inverse()))
  581. }
  582. ,
  583. i.prototype.handleMouseMove = function(t) {
  584. if (this.options.preventMouseEventsDefault && (t.preventDefault ? t.preventDefault() : t.returnValue = !1),
  585. "pan" === this.state && this.options.panEnabled) {
  586. var e = a.getEventPoint(t, this.svg).matrixTransform(this.firstEventCTM.inverse())
  587. , o = this.firstEventCTM.translate(e.x - this.stateOrigin.x, e.y - this.stateOrigin.y);
  588. this.viewport.setCTM(o)
  589. }
  590. }
  591. ,
  592. i.prototype.handleMouseUp = function(t) {
  593. this.options.preventMouseEventsDefault && (t.preventDefault ? t.preventDefault() : t.returnValue = !1),
  594. "pan" === this.state && (this.state = "none")
  595. }
  596. ,
  597. i.prototype.fit = function() {
  598. var t = this.viewport.getViewBox()
  599. , e = Math.min(this.width / t.width, this.height / t.height);
  600. this.zoom(e, !0)
  601. }
  602. ,
  603. i.prototype.contain = function() {
  604. var t = this.viewport.getViewBox()
  605. , e = Math.max(this.width / t.width, this.height / t.height);
  606. this.zoom(e, !0)
  607. }
  608. ,
  609. i.prototype.center = function() {
  610. var t = this.viewport.getViewBox()
  611. , e = .5 * (this.width - (t.width + 2 * t.x) * this.getZoom())
  612. , o = .5 * (this.height - (t.height + 2 * t.y) * this.getZoom());
  613. this.getPublicInstance().pan({
  614. x: e,
  615. y: o
  616. })
  617. }
  618. ,
  619. i.prototype.updateBBox = function() {
  620. this.viewport.simpleViewBoxCache()
  621. }
  622. ,
  623. i.prototype.pan = function(t) {
  624. var e = this.viewport.getCTM();
  625. e.e = t.x,
  626. e.f = t.y,
  627. this.viewport.setCTM(e)
  628. }
  629. ,
  630. i.prototype.panBy = function(t) {
  631. var e = this.viewport.getCTM();
  632. e.e += t.x,
  633. e.f += t.y,
  634. this.viewport.setCTM(e)
  635. }
  636. ,
  637. i.prototype.getPan = function() {
  638. var t = this.viewport.getState();
  639. return {
  640. x: t.x,
  641. y: t.y
  642. }
  643. }
  644. ,
  645. i.prototype.resize = function() {
  646. var t = a.getBoundingClientRectNormalized(this.svg);
  647. this.width = t.width,
  648. this.height = t.height;
  649. var e = this.viewport;
  650. e.options.width = this.width,
  651. e.options.height = this.height,
  652. e.processCTM(),
  653. this.options.controlIconsEnabled && (this.getPublicInstance().disableControlIcons(),
  654. this.getPublicInstance().enableControlIcons())
  655. }
  656. ,
  657. i.prototype.destroy = function() {
  658. var e = this;
  659. for (var t in this.beforeZoom = null,
  660. this.onZoom = null,
  661. this.beforePan = null,
  662. this.onPan = null,
  663. (this.onUpdatedCTM = null) != this.options.customEventsHandler && this.options.customEventsHandler.destroy({
  664. svgElement: this.svg,
  665. eventsListenerElement: this.options.eventsListenerElement,
  666. instance: this.getPublicInstance()
  667. }),
  668. this.eventListeners)
  669. (this.options.eventsListenerElement || this.svg).removeEventListener(t, this.eventListeners[t], !this.options.preventMouseEventsDefault && h);
  670. this.disableMouseWheelZoom(),
  671. this.getPublicInstance().disableControlIcons(),
  672. this.reset(),
  673. c = c.filter(function(t) {
  674. return t.svg !== e.svg
  675. }),
  676. delete this.options,
  677. delete this.viewport,
  678. delete this.publicInstance,
  679. delete this.pi,
  680. this.getPublicInstance = function() {
  681. return null
  682. }
  683. }
  684. ,
  685. i.prototype.getPublicInstance = function() {
  686. var o = this;
  687. return this.publicInstance || (this.publicInstance = this.pi = {
  688. enablePan: function() {
  689. return o.options.panEnabled = !0,
  690. o.pi
  691. },
  692. disablePan: function() {
  693. return o.options.panEnabled = !1,
  694. o.pi
  695. },
  696. isPanEnabled: function() {
  697. return !!o.options.panEnabled
  698. },
  699. pan: function(t) {
  700. return o.pan(t),
  701. o.pi
  702. },
  703. panBy: function(t) {
  704. return o.panBy(t),
  705. o.pi
  706. },
  707. getPan: function() {
  708. return o.getPan()
  709. },
  710. setBeforePan: function(t) {
  711. return o.options.beforePan = null === t ? null : r.proxy(t, o.publicInstance),
  712. o.pi
  713. },
  714. setOnPan: function(t) {
  715. return o.options.onPan = null === t ? null : r.proxy(t, o.publicInstance),
  716. o.pi
  717. },
  718. enableZoom: function() {
  719. return o.options.zoomEnabled = !0,
  720. o.pi
  721. },
  722. disableZoom: function() {
  723. return o.options.zoomEnabled = !1,
  724. o.pi
  725. },
  726. isZoomEnabled: function() {
  727. return !!o.options.zoomEnabled
  728. },
  729. enableControlIcons: function() {
  730. return o.options.controlIconsEnabled || (o.options.controlIconsEnabled = !0,
  731. s.enable(o)),
  732. o.pi
  733. },
  734. disableControlIcons: function() {
  735. return o.options.controlIconsEnabled && (o.options.controlIconsEnabled = !1,
  736. s.disable(o)),
  737. o.pi
  738. },
  739. isControlIconsEnabled: function() {
  740. return !!o.options.controlIconsEnabled
  741. },
  742. enableDblClickZoom: function() {
  743. return o.options.dblClickZoomEnabled = !0,
  744. o.pi
  745. },
  746. disableDblClickZoom: function() {
  747. return o.options.dblClickZoomEnabled = !1,
  748. o.pi
  749. },
  750. isDblClickZoomEnabled: function() {
  751. return !!o.options.dblClickZoomEnabled
  752. },
  753. enableMouseWheelZoom: function() {
  754. return o.enableMouseWheelZoom(),
  755. o.pi
  756. },
  757. disableMouseWheelZoom: function() {
  758. return o.disableMouseWheelZoom(),
  759. o.pi
  760. },
  761. isMouseWheelZoomEnabled: function() {
  762. return !!o.options.mouseWheelZoomEnabled
  763. },
  764. setZoomScaleSensitivity: function(t) {
  765. return o.options.zoomScaleSensitivity = t,
  766. o.pi
  767. },
  768. setMinZoom: function(t) {
  769. return o.options.minZoom = t,
  770. o.pi
  771. },
  772. setMaxZoom: function(t) {
  773. return o.options.maxZoom = t,
  774. o.pi
  775. },
  776. setBeforeZoom: function(t) {
  777. return o.options.beforeZoom = null === t ? null : r.proxy(t, o.publicInstance),
  778. o.pi
  779. },
  780. setOnZoom: function(t) {
  781. return o.options.onZoom = null === t ? null : r.proxy(t, o.publicInstance),
  782. o.pi
  783. },
  784. zoom: function(t) {
  785. return o.publicZoom(t, !0),
  786. o.pi
  787. },
  788. zoomBy: function(t) {
  789. return o.publicZoom(t, !1),
  790. o.pi
  791. },
  792. zoomAtPoint: function(t, e) {
  793. return o.publicZoomAtPoint(t, e, !0),
  794. o.pi
  795. },
  796. zoomAtPointBy: function(t, e) {
  797. return o.publicZoomAtPoint(t, e, !1),
  798. o.pi
  799. },
  800. zoomIn: function() {
  801. return this.zoomBy(1 + o.options.zoomScaleSensitivity),
  802. o.pi
  803. },
  804. zoomOut: function() {
  805. return this.zoomBy(1 / (1 + o.options.zoomScaleSensitivity)),
  806. o.pi
  807. },
  808. getZoom: function() {
  809. return o.getRelativeZoom()
  810. },
  811. setOnUpdatedCTM: function(t) {
  812. return o.options.onUpdatedCTM = null === t ? null : r.proxy(t, o.publicInstance),
  813. o.pi
  814. },
  815. resetZoom: function() {
  816. return o.resetZoom(),
  817. o.pi
  818. },
  819. resetPan: function() {
  820. return o.resetPan(),
  821. o.pi
  822. },
  823. reset: function() {
  824. return o.reset(),
  825. o.pi
  826. },
  827. fit: function() {
  828. return o.fit(),
  829. o.pi
  830. },
  831. contain: function() {
  832. return o.contain(),
  833. o.pi
  834. },
  835. center: function() {
  836. return o.center(),
  837. o.pi
  838. },
  839. updateBBox: function() {
  840. return o.updateBBox(),
  841. o.pi
  842. },
  843. resize: function() {
  844. return o.resize(),
  845. o.pi
  846. },
  847. getSizes: function() {
  848. return {
  849. width: o.width,
  850. height: o.height,
  851. realZoom: o.getZoom(),
  852. viewBox: o.viewport.getViewBox()
  853. }
  854. },
  855. destroy: function() {
  856. return o.destroy(),
  857. o.pi
  858. }
  859. }),
  860. this.publicInstance
  861. }
  862. ;
  863. var c = [];
  864. e.exports = function(t, e) {
  865. var o = r.getSvg(t);
  866. if (null === o)
  867. return null;
  868. for (var n = c.length - 1; 0 <= n; n--)
  869. if (c[n].svg === o)
  870. return c[n].instance.getPublicInstance();
  871. return c.push({
  872. svg: o,
  873. instance: new i(o,e)
  874. }),
  875. c[c.length - 1].instance.getPublicInstance()
  876. }
  877. }
  878. , {
  879. "./control-icons": 1,
  880. "./shadow-viewport": 2,
  881. "./svg-utilities": 5,
  882. "./uniwheel": 6,
  883. "./utilities": 7
  884. }],
  885. 5: [function(t, e, o) {
  886. var l = t("./utilities")
  887. , s = "unknown";
  888. document.documentMode && (s = "ie"),
  889. e.exports = {
  890. svgNS: "http://www.w3.org/2000/svg",
  891. xmlNS: "http://www.w3.org/XML/1998/namespace",
  892. xmlnsNS: "http://www.w3.org/2000/xmlns/",
  893. xlinkNS: "http://www.w3.org/1999/xlink",
  894. evNS: "http://www.w3.org/2001/xml-events",
  895. getBoundingClientRectNormalized: function(t) {
  896. if (t.clientWidth && t.clientHeight)
  897. return {
  898. width: t.clientWidth,
  899. height: t.clientHeight
  900. };
  901. if (t.getBoundingClientRect())
  902. return t.getBoundingClientRect();
  903. throw new Error("Cannot get BoundingClientRect for SVG.")
  904. },
  905. getOrCreateViewport: function(t, e) {
  906. var o = null;
  907. if (!(o = l.isElement(e) ? e : t.querySelector(e))) {
  908. var n = Array.prototype.slice.call(t.childNodes || t.children).filter(function(t) {
  909. return "defs" !== t.nodeName && "#text" !== t.nodeName
  910. });
  911. 1 === n.length && "g" === n[0].nodeName && null === n[0].getAttribute("transform") && (o = n[0])
  912. }
  913. if (!o) {
  914. var i = "viewport-" + (new Date).toISOString().replace(/\D/g, "");
  915. (o = document.createElementNS(this.svgNS, "g")).setAttribute("id", i);
  916. var s = t.childNodes || t.children;
  917. if (s && 0 < s.length)
  918. for (var r = s.length; 0 < r; r--)
  919. "defs" !== s[s.length - r].nodeName && o.appendChild(s[s.length - r]);
  920. t.appendChild(o)
  921. }
  922. var a = [];
  923. return o.getAttribute("class") && (a = o.getAttribute("class").split(" ")),
  924. ~a.indexOf("svg-pan-zoom_viewport") || (a.push("svg-pan-zoom_viewport"),
  925. o.setAttribute("class", a.join(" "))),
  926. o
  927. },
  928. setupSvgAttributes: function(t) {
  929. if (t.setAttribute("xmlns", this.svgNS),
  930. t.setAttributeNS(this.xmlnsNS, "xmlns:xlink", this.xlinkNS),
  931. t.setAttributeNS(this.xmlnsNS, "xmlns:ev", this.evNS),
  932. null !== t.parentNode) {
  933. var e = t.getAttribute("style") || "";
  934. -1 === e.toLowerCase().indexOf("overflow") && t.setAttribute("style", "overflow: hidden; " + e)
  935. }
  936. },
  937. internetExplorerRedisplayInterval: 300,
  938. refreshDefsGlobal: l.throttle(function() {
  939. for (var t = document.querySelectorAll("defs"), e = t.length, o = 0; o < e; o++) {
  940. var n = t[o];
  941. n.parentNode.insertBefore(n, n)
  942. }
  943. }, this ? this.internetExplorerRedisplayInterval : null),
  944. setCTM: function(t, e, o) {
  945. var n = this
  946. , i = "matrix(" + e.a + "," + e.b + "," + e.c + "," + e.d + "," + e.e + "," + e.f + ")";
  947. t.setAttributeNS(null, "transform", i),
  948. "transform"in t.style ? t.style.transform = i : "-ms-transform"in t.style ? t.style["-ms-transform"] = i : "-webkit-transform"in t.style && (t.style["-webkit-transform"] = i),
  949. "ie" === s && o && (o.parentNode.insertBefore(o, o),
  950. window.setTimeout(function() {
  951. n.refreshDefsGlobal()
  952. }, n.internetExplorerRedisplayInterval))
  953. },
  954. getEventPoint: function(t, e) {
  955. var o = e.createSVGPoint();
  956. return l.mouseAndTouchNormalize(t, e),
  957. o.x = t.clientX,
  958. o.y = t.clientY,
  959. o
  960. },
  961. getSvgCenterPoint: function(t, e, o) {
  962. return this.createSVGPoint(t, e / 2, o / 2)
  963. },
  964. createSVGPoint: function(t, e, o) {
  965. var n = t.createSVGPoint();
  966. return n.x = e,
  967. n.y = o,
  968. n
  969. }
  970. }
  971. }
  972. , {
  973. "./utilities": 7
  974. }],
  975. 6: [function(t, e, o) {
  976. function n(t, e, o, n) {
  977. var i;
  978. i = "wheel" === a ? o : function(t, o) {
  979. function e(t) {
  980. var e = {
  981. originalEvent: t = t || window.event,
  982. target: t.target || t.srcElement,
  983. type: "wheel",
  984. deltaMode: "MozMousePixelScroll" == t.type ? 0 : 1,
  985. deltaX: 0,
  986. delatZ: 0,
  987. preventDefault: function() {
  988. t.preventDefault ? t.preventDefault() : t.returnValue = !1
  989. }
  990. };
  991. return "mousewheel" == a ? (e.deltaY = -.025 * t.wheelDelta,
  992. t.wheelDeltaX && (e.deltaX = -.025 * t.wheelDeltaX)) : e.deltaY = t.detail,
  993. o(e)
  994. }
  995. return u.push({
  996. element: t,
  997. fn: e
  998. }),
  999. e
  1000. }(t, o),
  1001. t[s](l + e, i, !!n && h)
  1002. }
  1003. function i(t, e, o, n) {
  1004. var i;
  1005. i = "wheel" === a ? o : function(t) {
  1006. for (var e = 0; e < u.length; e++)
  1007. if (u[e].element === t)
  1008. return u[e].fn;
  1009. return function() {}
  1010. }(t),
  1011. t[r](l + e, i, !!n && h),
  1012. function(t) {
  1013. for (var e = 0; e < u.length; e++)
  1014. if (u[e].element === t)
  1015. return u.splice(e, 1)
  1016. }(t)
  1017. }
  1018. var s, r, a, l, u, h;
  1019. e.exports = (u = [],
  1020. h = {
  1021. passive: !(l = "")
  1022. },
  1023. window.addEventListener ? (s = "addEventListener",
  1024. r = "removeEventListener") : (s = "attachEvent",
  1025. r = "detachEvent",
  1026. l = "on"),
  1027. a = "onwheel"in document.createElement("div") ? "wheel" : void 0 !== document.onmousewheel ? "mousewheel" : "DOMMouseScroll",
  1028. {
  1029. on: function(t, e, o) {
  1030. n(t, a, e, o),
  1031. "DOMMouseScroll" == a && n(t, "MozMousePixelScroll", e, o)
  1032. },
  1033. off: function(t, e, o) {
  1034. i(t, a, e, o),
  1035. "DOMMouseScroll" == a && i(t, "MozMousePixelScroll", e, o)
  1036. }
  1037. })
  1038. }
  1039. , {}],
  1040. 7: [function(t, e, o) {
  1041. function n(e) {
  1042. return function(t) {
  1043. window.setTimeout(t, e)
  1044. }
  1045. }
  1046. e.exports = {
  1047. extend: function(t, e) {
  1048. for (var o in t = t || {},
  1049. e)
  1050. this.isObject(e[o]) ? t[o] = this.extend(t[o], e[o]) : t[o] = e[o];
  1051. return t
  1052. },
  1053. isElement: function(t) {
  1054. return t instanceof HTMLElement || t instanceof SVGElement || t instanceof SVGSVGElement || t && "object" == typeof t && null !== t && 1 === t.nodeType && "string" == typeof t.nodeName
  1055. },
  1056. isObject: function(t) {
  1057. return "[object Object]" === Object.prototype.toString.call(t)
  1058. },
  1059. isNumber: function(t) {
  1060. return !isNaN(parseFloat(t)) && isFinite(t)
  1061. },
  1062. getSvg: function(t) {
  1063. var e, o;
  1064. if (this.isElement(t))
  1065. e = t;
  1066. else {
  1067. if (!("string" == typeof t || t instanceof String))
  1068. throw new Error("Provided selector is not an HTML object nor String");
  1069. if (!(e = document.querySelector(t)))
  1070. throw new Error("Provided selector did not find any elements. Selector: " + t)
  1071. }
  1072. if ("svg" === e.tagName.toLowerCase())
  1073. o = e;
  1074. else if ("object" === e.tagName.toLowerCase())
  1075. o = e.contentDocument.documentElement;
  1076. else {
  1077. if ("embed" !== e.tagName.toLowerCase())
  1078. throw "img" === e.tagName.toLowerCase() ? new Error('Cannot script an SVG in an "img" element. Please use an "object" element or an in-line SVG.') : new Error("Cannot get SVG.");
  1079. o = e.getSVGDocument().documentElement
  1080. }
  1081. return o
  1082. },
  1083. proxy: function(t, e) {
  1084. return function() {
  1085. return t.apply(e, arguments)
  1086. }
  1087. },
  1088. getType: function(t) {
  1089. return Object.prototype.toString.apply(t).replace(/^\[object\s/, "").replace(/\]$/, "")
  1090. },
  1091. mouseAndTouchNormalize: function(t, e) {
  1092. if (void 0 === t.clientX || null === t.clientX)
  1093. if (t.clientX = 0,
  1094. void (t.clientY = 0) !== t.touches && t.touches.length) {
  1095. if (void 0 !== t.touches[0].clientX)
  1096. t.clientX = t.touches[0].clientX,
  1097. t.clientY = t.touches[0].clientY;
  1098. else if (void 0 !== t.touches[0].pageX) {
  1099. var o = e.getBoundingClientRect();
  1100. t.clientX = t.touches[0].pageX - o.left,
  1101. t.clientY = t.touches[0].pageY - o.top
  1102. }
  1103. } else
  1104. void 0 !== t.originalEvent && void 0 !== t.originalEvent.clientX && (t.clientX = t.originalEvent.clientX,
  1105. t.clientY = t.originalEvent.clientY)
  1106. },
  1107. isDblClick: function(t, e) {
  1108. if (2 === t.detail)
  1109. return !0;
  1110. if (null == e)
  1111. return !1;
  1112. var o = t.timeStamp - e.timeStamp
  1113. , n = Math.sqrt(Math.pow(t.clientX - e.clientX, 2) + Math.pow(t.clientY - e.clientY, 2));
  1114. return o < 250 && n < 10
  1115. },
  1116. now: Date.now || function() {
  1117. return (new Date).getTime()
  1118. }
  1119. ,
  1120. throttle: function(o, n, i) {
  1121. var s, r, a, l = this, u = null, h = 0;
  1122. i = i || {};
  1123. function c() {
  1124. h = !1 === i.leading ? 0 : l.now(),
  1125. u = null,
  1126. a = o.apply(s, r),
  1127. u || (s = r = null)
  1128. }
  1129. return function() {
  1130. var t = l.now();
  1131. h || !1 !== i.leading || (h = t);
  1132. var e = n - (t - h);
  1133. return s = this,
  1134. r = arguments,
  1135. e <= 0 || n < e ? (clearTimeout(u),
  1136. u = null,
  1137. h = t,
  1138. a = o.apply(s, r),
  1139. u || (s = r = null)) : u || !1 === i.trailing || (u = setTimeout(c, e)),
  1140. a
  1141. }
  1142. },
  1143. createRequestAnimationFrame: function(t) {
  1144. var e = null;
  1145. return "auto" !== t && t < 60 && 1 < t && (e = Math.floor(1e3 / t)),
  1146. null === e ? window.requestAnimationFrame || n(33) : n(e)
  1147. }
  1148. }
  1149. }
  1150. , {}]
  1151. }, {}, [3]);