viewerjs 1.10.0 → 1.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * Viewer.js v1.10.0
2
+ * Viewer.js v1.10.4
3
3
  * https://fengyuanchen.github.io/viewerjs
4
4
  *
5
5
  * Copyright 2015-present Chen Fengyuan
6
6
  * Released under the MIT license
7
7
  *
8
- * Date: 2021-06-12T07:57:10.970Z
8
+ * Date: 2022-02-13T08:40:00.127Z
9
9
  */
10
10
 
11
11
  function ownKeys(object, enumerableOnly) {
@@ -13,14 +13,9 @@ function ownKeys(object, enumerableOnly) {
13
13
 
14
14
  if (Object.getOwnPropertySymbols) {
15
15
  var symbols = Object.getOwnPropertySymbols(object);
16
-
17
- if (enumerableOnly) {
18
- symbols = symbols.filter(function (sym) {
19
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
20
- });
21
- }
22
-
23
- keys.push.apply(keys, symbols);
16
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
17
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
18
+ })), keys.push.apply(keys, symbols);
24
19
  }
25
20
 
26
21
  return keys;
@@ -28,19 +23,12 @@ function ownKeys(object, enumerableOnly) {
28
23
 
29
24
  function _objectSpread2(target) {
30
25
  for (var i = 1; i < arguments.length; i++) {
31
- var source = arguments[i] != null ? arguments[i] : {};
32
-
33
- if (i % 2) {
34
- ownKeys(Object(source), true).forEach(function (key) {
35
- _defineProperty(target, key, source[key]);
36
- });
37
- } else if (Object.getOwnPropertyDescriptors) {
38
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
39
- } else {
40
- ownKeys(Object(source)).forEach(function (key) {
41
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
42
- });
43
- }
26
+ var source = null != arguments[i] ? arguments[i] : {};
27
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
28
+ _defineProperty(target, key, source[key]);
29
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
30
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
31
+ });
44
32
  }
45
33
 
46
34
  return target;
@@ -49,17 +37,11 @@ function _objectSpread2(target) {
49
37
  function _typeof(obj) {
50
38
  "@babel/helpers - typeof";
51
39
 
52
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
53
- _typeof = function (obj) {
54
- return typeof obj;
55
- };
56
- } else {
57
- _typeof = function (obj) {
58
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
59
- };
60
- }
61
-
62
- return _typeof(obj);
40
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
41
+ return typeof obj;
42
+ } : function (obj) {
43
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
44
+ }, _typeof(obj);
63
45
  }
64
46
 
65
47
  function _classCallCheck(instance, Constructor) {
@@ -81,6 +63,9 @@ function _defineProperties(target, props) {
81
63
  function _createClass(Constructor, protoProps, staticProps) {
82
64
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
83
65
  if (staticProps) _defineProperties(Constructor, staticProps);
66
+ Object.defineProperty(Constructor, "prototype", {
67
+ writable: false
68
+ });
84
69
  return Constructor;
85
70
  }
86
71
 
@@ -372,6 +357,7 @@ var EVENT_DRAG_START = 'dragstart';
372
357
  var EVENT_FOCUSIN = 'focusin';
373
358
  var EVENT_KEY_DOWN = 'keydown';
374
359
  var EVENT_LOAD = 'load';
360
+ var EVENT_ERROR = 'error';
375
361
  var EVENT_TOUCH_END = IS_TOUCH_DEVICE ? 'touchend touchcancel' : 'mouseup';
376
362
  var EVENT_TOUCH_MOVE = IS_TOUCH_DEVICE ? 'touchmove' : 'mousemove';
377
363
  var EVENT_TOUCH_START = IS_TOUCH_DEVICE ? 'touchstart' : 'mousedown';
@@ -488,15 +474,15 @@ function forEach(data, callback) {
488
474
  if (Array.isArray(data) || isNumber(data.length)
489
475
  /* array-like */
490
476
  ) {
491
- var length = data.length;
492
- var i;
477
+ var length = data.length;
478
+ var i;
493
479
 
494
- for (i = 0; i < length; i += 1) {
495
- if (callback.call(data, data[i], i, data) === false) {
496
- break;
497
- }
480
+ for (i = 0; i < length; i += 1) {
481
+ if (callback.call(data, data[i], i, data) === false) {
482
+ break;
498
483
  }
499
- } else if (isObject(data)) {
484
+ }
485
+ } else if (isObject(data)) {
500
486
  Object.keys(data).forEach(function (key) {
501
487
  callback.call(data, data[key], key, data);
502
488
  });
@@ -1121,13 +1107,17 @@ var render = {
1121
1107
  this.items = items;
1122
1108
  forEach(items, function (item) {
1123
1109
  var image = item.firstElementChild;
1110
+ var onLoad;
1111
+ var onError;
1124
1112
  setData(image, 'filled', true);
1125
1113
 
1126
1114
  if (options.loading) {
1127
1115
  addClass(item, CLASS_LOADING);
1128
1116
  }
1129
1117
 
1130
- addListener(image, EVENT_LOAD, function (event) {
1118
+ addListener(image, EVENT_LOAD, onLoad = function onLoad(event) {
1119
+ removeListener(image, EVENT_ERROR, onError);
1120
+
1131
1121
  if (options.loading) {
1132
1122
  removeClass(item, CLASS_LOADING);
1133
1123
  }
@@ -1136,6 +1126,15 @@ var render = {
1136
1126
  }, {
1137
1127
  once: true
1138
1128
  });
1129
+ addListener(image, EVENT_ERROR, onError = function onError() {
1130
+ removeListener(image, EVENT_LOAD, onLoad);
1131
+
1132
+ if (options.loading) {
1133
+ removeClass(item, CLASS_LOADING);
1134
+ }
1135
+ }, {
1136
+ once: true
1137
+ });
1139
1138
  });
1140
1139
 
1141
1140
  if (options.transition) {
@@ -1146,16 +1145,23 @@ var render = {
1146
1145
  });
1147
1146
  }
1148
1147
  },
1149
- renderList: function renderList(index) {
1150
- var i = index || this.index;
1151
- var width = this.items[i].offsetWidth || 30;
1152
- var outerWidth = width + 1; // 1 pixel of `margin-left` width
1153
- // Place the active item in the center of the screen
1148
+ renderList: function renderList() {
1149
+ var index = this.index;
1150
+ var item = this.items[index];
1151
+
1152
+ if (!item) {
1153
+ return;
1154
+ }
1155
+
1156
+ var next = item.nextElementSibling;
1157
+ var gutter = parseInt(window.getComputedStyle(next || item).marginLeft, 10);
1158
+ var offsetWidth = item.offsetWidth;
1159
+ var outerWidth = offsetWidth + gutter; // Place the active item in the center of the screen
1154
1160
 
1155
1161
  setStyle(this.list, assign({
1156
- width: outerWidth * this.length
1162
+ width: outerWidth * this.length - gutter
1157
1163
  }, getTransforms({
1158
- translateX: (this.viewerData.width - width) / 2 - outerWidth * i
1164
+ translateX: (this.viewerData.width - offsetWidth) / 2 - outerWidth * index
1159
1165
  })));
1160
1166
  },
1161
1167
  resetList: function resetList() {
@@ -1431,9 +1437,10 @@ var handlers = {
1431
1437
  // Cancel the emulated double click when the native dblclick event was triggered.
1432
1438
  if (IS_TOUCH_DEVICE && event.isTrusted) {
1433
1439
  clearTimeout(this.doubleClickImageTimeout);
1434
- }
1440
+ } // XXX: No pageX/Y properties in custom event, fallback to the original event.
1441
+
1435
1442
 
1436
- this.toggle(event);
1443
+ this.toggle(event.isTrusted ? event : event.detail && event.detail.originalEvent);
1437
1444
  }
1438
1445
  },
1439
1446
  load: function load() {
@@ -1455,7 +1462,7 @@ var handlers = {
1455
1462
  removeClass(this.canvas, CLASS_LOADING);
1456
1463
  }
1457
1464
 
1458
- image.style.cssText = 'height:0;' + "margin-left:".concat(viewerData.width / 2, "px;") + "margin-top:".concat(viewerData.height / 2, "px;") + 'max-width:none!important;' + 'position:absolute;' + 'width:0;';
1465
+ image.style.cssText = 'height:0;' + "margin-left:".concat(viewerData.width / 2, "px;") + "margin-top:".concat(viewerData.height / 2, "px;") + 'max-width:none!important;' + 'position:relative;' + 'width:0;';
1459
1466
  this.initImage(function () {
1460
1467
  toggleClass(image, CLASS_MOVE, options.movable);
1461
1468
  toggleClass(image, CLASS_TRANSITION, options.transition);
@@ -1700,7 +1707,9 @@ var handlers = {
1700
1707
  this.imageClicked = false; // This timeout will be cleared later when a native dblclick event is triggering
1701
1708
 
1702
1709
  this.doubleClickImageTimeout = setTimeout(function () {
1703
- dispatchEvent(_this2.image, EVENT_DBLCLICK);
1710
+ dispatchEvent(_this2.image, EVENT_DBLCLICK, {
1711
+ originalEvent: event
1712
+ });
1704
1713
  }, 50);
1705
1714
  } else {
1706
1715
  this.imageClicked = true; // The default timing of a double click in Windows is 500 ms
@@ -1715,7 +1724,9 @@ var handlers = {
1715
1724
  if (options.backdrop && options.backdrop !== 'static' && event.target === this.canvas) {
1716
1725
  // This timeout will be cleared later when a native click event is triggering
1717
1726
  this.clickCanvasTimeout = setTimeout(function () {
1718
- dispatchEvent(_this2.canvas, EVENT_CLICK);
1727
+ dispatchEvent(_this2.canvas, EVENT_CLICK, {
1728
+ originalEvent: event
1729
+ });
1719
1730
  }, 50);
1720
1731
  }
1721
1732
  }
@@ -2012,8 +2023,12 @@ var methods = {
2012
2023
  }
2013
2024
 
2014
2025
  var activeItem = this.items[this.index];
2015
- removeClass(activeItem, CLASS_ACTIVE);
2016
- activeItem.removeAttribute('aria-selected');
2026
+
2027
+ if (activeItem) {
2028
+ removeClass(activeItem, CLASS_ACTIVE);
2029
+ activeItem.removeAttribute('aria-selected');
2030
+ }
2031
+
2017
2032
  addClass(item, CLASS_ACTIVE);
2018
2033
  item.setAttribute('aria-selected', true);
2019
2034
 
@@ -2045,6 +2060,7 @@ var methods = {
2045
2060
  };
2046
2061
 
2047
2062
  var onLoad;
2063
+ var onError;
2048
2064
  addListener(element, EVENT_VIEWED, onViewed, {
2049
2065
  once: true
2050
2066
  });
@@ -2073,7 +2089,27 @@ var methods = {
2073
2089
  if (image.complete) {
2074
2090
  this.load();
2075
2091
  } else {
2076
- addListener(image, EVENT_LOAD, onLoad = this.load.bind(this), {
2092
+ addListener(image, EVENT_LOAD, onLoad = function onLoad() {
2093
+ removeListener(image, EVENT_ERROR, onError);
2094
+
2095
+ _this2.load();
2096
+ }, {
2097
+ once: true
2098
+ });
2099
+ addListener(image, EVENT_ERROR, onError = function onError() {
2100
+ removeListener(image, EVENT_LOAD, onLoad);
2101
+
2102
+ if (_this2.timeout) {
2103
+ clearTimeout(_this2.timeout);
2104
+ _this2.timeout = false;
2105
+ }
2106
+
2107
+ removeClass(image, CLASS_INVISIBLE);
2108
+
2109
+ if (options.loading) {
2110
+ removeClass(_this2.canvas, CLASS_LOADING);
2111
+ }
2112
+ }, {
2077
2113
  once: true
2078
2114
  });
2079
2115
 
@@ -2444,8 +2480,24 @@ var methods = {
2444
2480
  ratio = Math.min(Math.max(ratio, minZoomRatio), maxZoomRatio);
2445
2481
  }
2446
2482
 
2447
- if (_originalEvent && options.zoomRatio >= 0.055 && ratio > 0.95 && ratio < 1.05) {
2448
- ratio = 1;
2483
+ if (_originalEvent) {
2484
+ switch (_originalEvent.type) {
2485
+ case 'wheel':
2486
+ if (options.zoomRatio >= 0.055 && ratio > 0.95 && ratio < 1.05) {
2487
+ ratio = 1;
2488
+ }
2489
+
2490
+ break;
2491
+
2492
+ case 'pointermove':
2493
+ case 'touchmove':
2494
+ case 'mousemove':
2495
+ if (ratio > 0.99 && ratio < 1.01) {
2496
+ ratio = 1;
2497
+ }
2498
+
2499
+ break;
2500
+ }
2449
2501
  }
2450
2502
 
2451
2503
  var newWidth = naturalWidth * ratio;
@@ -2472,7 +2524,7 @@ var methods = {
2472
2524
 
2473
2525
  if (_originalEvent) {
2474
2526
  var offset = getOffset(this.viewer);
2475
- var center = pointers && Object.keys(pointers).length ? getPointersCenter(pointers) : {
2527
+ var center = pointers && Object.keys(pointers).length > 0 ? getPointersCenter(pointers) : {
2476
2528
  pageX: _originalEvent.pageX,
2477
2529
  pageY: _originalEvent.pageY
2478
2530
  }; // Zoom from the triggering point of the event
@@ -3512,4 +3564,4 @@ var Viewer = /*#__PURE__*/function () {
3512
3564
 
3513
3565
  assign(Viewer.prototype, render, events, handlers, methods, others);
3514
3566
 
3515
- export default Viewer;
3567
+ export { Viewer as default };
package/dist/viewer.js CHANGED
@@ -1,32 +1,27 @@
1
1
  /*!
2
- * Viewer.js v1.10.0
2
+ * Viewer.js v1.10.4
3
3
  * https://fengyuanchen.github.io/viewerjs
4
4
  *
5
5
  * Copyright 2015-present Chen Fengyuan
6
6
  * Released under the MIT license
7
7
  *
8
- * Date: 2021-06-12T07:57:10.970Z
8
+ * Date: 2022-02-13T08:40:00.127Z
9
9
  */
10
10
 
11
11
  (function (global, factory) {
12
12
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
13
13
  typeof define === 'function' && define.amd ? define(factory) :
14
14
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Viewer = factory());
15
- }(this, (function () { 'use strict';
15
+ })(this, (function () { 'use strict';
16
16
 
17
17
  function ownKeys(object, enumerableOnly) {
18
18
  var keys = Object.keys(object);
19
19
 
20
20
  if (Object.getOwnPropertySymbols) {
21
21
  var symbols = Object.getOwnPropertySymbols(object);
22
-
23
- if (enumerableOnly) {
24
- symbols = symbols.filter(function (sym) {
25
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
26
- });
27
- }
28
-
29
- keys.push.apply(keys, symbols);
22
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
23
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
24
+ })), keys.push.apply(keys, symbols);
30
25
  }
31
26
 
32
27
  return keys;
@@ -34,19 +29,12 @@
34
29
 
35
30
  function _objectSpread2(target) {
36
31
  for (var i = 1; i < arguments.length; i++) {
37
- var source = arguments[i] != null ? arguments[i] : {};
38
-
39
- if (i % 2) {
40
- ownKeys(Object(source), true).forEach(function (key) {
41
- _defineProperty(target, key, source[key]);
42
- });
43
- } else if (Object.getOwnPropertyDescriptors) {
44
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
45
- } else {
46
- ownKeys(Object(source)).forEach(function (key) {
47
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
48
- });
49
- }
32
+ var source = null != arguments[i] ? arguments[i] : {};
33
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
34
+ _defineProperty(target, key, source[key]);
35
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
36
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
37
+ });
50
38
  }
51
39
 
52
40
  return target;
@@ -55,17 +43,11 @@
55
43
  function _typeof(obj) {
56
44
  "@babel/helpers - typeof";
57
45
 
58
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
59
- _typeof = function (obj) {
60
- return typeof obj;
61
- };
62
- } else {
63
- _typeof = function (obj) {
64
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
65
- };
66
- }
67
-
68
- return _typeof(obj);
46
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
47
+ return typeof obj;
48
+ } : function (obj) {
49
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
50
+ }, _typeof(obj);
69
51
  }
70
52
 
71
53
  function _classCallCheck(instance, Constructor) {
@@ -87,6 +69,9 @@
87
69
  function _createClass(Constructor, protoProps, staticProps) {
88
70
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
89
71
  if (staticProps) _defineProperties(Constructor, staticProps);
72
+ Object.defineProperty(Constructor, "prototype", {
73
+ writable: false
74
+ });
90
75
  return Constructor;
91
76
  }
92
77
 
@@ -378,6 +363,7 @@
378
363
  var EVENT_FOCUSIN = 'focusin';
379
364
  var EVENT_KEY_DOWN = 'keydown';
380
365
  var EVENT_LOAD = 'load';
366
+ var EVENT_ERROR = 'error';
381
367
  var EVENT_TOUCH_END = IS_TOUCH_DEVICE ? 'touchend touchcancel' : 'mouseup';
382
368
  var EVENT_TOUCH_MOVE = IS_TOUCH_DEVICE ? 'touchmove' : 'mousemove';
383
369
  var EVENT_TOUCH_START = IS_TOUCH_DEVICE ? 'touchstart' : 'mousedown';
@@ -494,15 +480,15 @@
494
480
  if (Array.isArray(data) || isNumber(data.length)
495
481
  /* array-like */
496
482
  ) {
497
- var length = data.length;
498
- var i;
483
+ var length = data.length;
484
+ var i;
499
485
 
500
- for (i = 0; i < length; i += 1) {
501
- if (callback.call(data, data[i], i, data) === false) {
502
- break;
503
- }
486
+ for (i = 0; i < length; i += 1) {
487
+ if (callback.call(data, data[i], i, data) === false) {
488
+ break;
504
489
  }
505
- } else if (isObject(data)) {
490
+ }
491
+ } else if (isObject(data)) {
506
492
  Object.keys(data).forEach(function (key) {
507
493
  callback.call(data, data[key], key, data);
508
494
  });
@@ -1127,13 +1113,17 @@
1127
1113
  this.items = items;
1128
1114
  forEach(items, function (item) {
1129
1115
  var image = item.firstElementChild;
1116
+ var onLoad;
1117
+ var onError;
1130
1118
  setData(image, 'filled', true);
1131
1119
 
1132
1120
  if (options.loading) {
1133
1121
  addClass(item, CLASS_LOADING);
1134
1122
  }
1135
1123
 
1136
- addListener(image, EVENT_LOAD, function (event) {
1124
+ addListener(image, EVENT_LOAD, onLoad = function onLoad(event) {
1125
+ removeListener(image, EVENT_ERROR, onError);
1126
+
1137
1127
  if (options.loading) {
1138
1128
  removeClass(item, CLASS_LOADING);
1139
1129
  }
@@ -1142,6 +1132,15 @@
1142
1132
  }, {
1143
1133
  once: true
1144
1134
  });
1135
+ addListener(image, EVENT_ERROR, onError = function onError() {
1136
+ removeListener(image, EVENT_LOAD, onLoad);
1137
+
1138
+ if (options.loading) {
1139
+ removeClass(item, CLASS_LOADING);
1140
+ }
1141
+ }, {
1142
+ once: true
1143
+ });
1145
1144
  });
1146
1145
 
1147
1146
  if (options.transition) {
@@ -1152,16 +1151,23 @@
1152
1151
  });
1153
1152
  }
1154
1153
  },
1155
- renderList: function renderList(index) {
1156
- var i = index || this.index;
1157
- var width = this.items[i].offsetWidth || 30;
1158
- var outerWidth = width + 1; // 1 pixel of `margin-left` width
1159
- // Place the active item in the center of the screen
1154
+ renderList: function renderList() {
1155
+ var index = this.index;
1156
+ var item = this.items[index];
1157
+
1158
+ if (!item) {
1159
+ return;
1160
+ }
1161
+
1162
+ var next = item.nextElementSibling;
1163
+ var gutter = parseInt(window.getComputedStyle(next || item).marginLeft, 10);
1164
+ var offsetWidth = item.offsetWidth;
1165
+ var outerWidth = offsetWidth + gutter; // Place the active item in the center of the screen
1160
1166
 
1161
1167
  setStyle(this.list, assign({
1162
- width: outerWidth * this.length
1168
+ width: outerWidth * this.length - gutter
1163
1169
  }, getTransforms({
1164
- translateX: (this.viewerData.width - width) / 2 - outerWidth * i
1170
+ translateX: (this.viewerData.width - offsetWidth) / 2 - outerWidth * index
1165
1171
  })));
1166
1172
  },
1167
1173
  resetList: function resetList() {
@@ -1437,9 +1443,10 @@
1437
1443
  // Cancel the emulated double click when the native dblclick event was triggered.
1438
1444
  if (IS_TOUCH_DEVICE && event.isTrusted) {
1439
1445
  clearTimeout(this.doubleClickImageTimeout);
1440
- }
1446
+ } // XXX: No pageX/Y properties in custom event, fallback to the original event.
1447
+
1441
1448
 
1442
- this.toggle(event);
1449
+ this.toggle(event.isTrusted ? event : event.detail && event.detail.originalEvent);
1443
1450
  }
1444
1451
  },
1445
1452
  load: function load() {
@@ -1461,7 +1468,7 @@
1461
1468
  removeClass(this.canvas, CLASS_LOADING);
1462
1469
  }
1463
1470
 
1464
- image.style.cssText = 'height:0;' + "margin-left:".concat(viewerData.width / 2, "px;") + "margin-top:".concat(viewerData.height / 2, "px;") + 'max-width:none!important;' + 'position:absolute;' + 'width:0;';
1471
+ image.style.cssText = 'height:0;' + "margin-left:".concat(viewerData.width / 2, "px;") + "margin-top:".concat(viewerData.height / 2, "px;") + 'max-width:none!important;' + 'position:relative;' + 'width:0;';
1465
1472
  this.initImage(function () {
1466
1473
  toggleClass(image, CLASS_MOVE, options.movable);
1467
1474
  toggleClass(image, CLASS_TRANSITION, options.transition);
@@ -1706,7 +1713,9 @@
1706
1713
  this.imageClicked = false; // This timeout will be cleared later when a native dblclick event is triggering
1707
1714
 
1708
1715
  this.doubleClickImageTimeout = setTimeout(function () {
1709
- dispatchEvent(_this2.image, EVENT_DBLCLICK);
1716
+ dispatchEvent(_this2.image, EVENT_DBLCLICK, {
1717
+ originalEvent: event
1718
+ });
1710
1719
  }, 50);
1711
1720
  } else {
1712
1721
  this.imageClicked = true; // The default timing of a double click in Windows is 500 ms
@@ -1721,7 +1730,9 @@
1721
1730
  if (options.backdrop && options.backdrop !== 'static' && event.target === this.canvas) {
1722
1731
  // This timeout will be cleared later when a native click event is triggering
1723
1732
  this.clickCanvasTimeout = setTimeout(function () {
1724
- dispatchEvent(_this2.canvas, EVENT_CLICK);
1733
+ dispatchEvent(_this2.canvas, EVENT_CLICK, {
1734
+ originalEvent: event
1735
+ });
1725
1736
  }, 50);
1726
1737
  }
1727
1738
  }
@@ -2018,8 +2029,12 @@
2018
2029
  }
2019
2030
 
2020
2031
  var activeItem = this.items[this.index];
2021
- removeClass(activeItem, CLASS_ACTIVE);
2022
- activeItem.removeAttribute('aria-selected');
2032
+
2033
+ if (activeItem) {
2034
+ removeClass(activeItem, CLASS_ACTIVE);
2035
+ activeItem.removeAttribute('aria-selected');
2036
+ }
2037
+
2023
2038
  addClass(item, CLASS_ACTIVE);
2024
2039
  item.setAttribute('aria-selected', true);
2025
2040
 
@@ -2051,6 +2066,7 @@
2051
2066
  };
2052
2067
 
2053
2068
  var onLoad;
2069
+ var onError;
2054
2070
  addListener(element, EVENT_VIEWED, onViewed, {
2055
2071
  once: true
2056
2072
  });
@@ -2079,7 +2095,27 @@
2079
2095
  if (image.complete) {
2080
2096
  this.load();
2081
2097
  } else {
2082
- addListener(image, EVENT_LOAD, onLoad = this.load.bind(this), {
2098
+ addListener(image, EVENT_LOAD, onLoad = function onLoad() {
2099
+ removeListener(image, EVENT_ERROR, onError);
2100
+
2101
+ _this2.load();
2102
+ }, {
2103
+ once: true
2104
+ });
2105
+ addListener(image, EVENT_ERROR, onError = function onError() {
2106
+ removeListener(image, EVENT_LOAD, onLoad);
2107
+
2108
+ if (_this2.timeout) {
2109
+ clearTimeout(_this2.timeout);
2110
+ _this2.timeout = false;
2111
+ }
2112
+
2113
+ removeClass(image, CLASS_INVISIBLE);
2114
+
2115
+ if (options.loading) {
2116
+ removeClass(_this2.canvas, CLASS_LOADING);
2117
+ }
2118
+ }, {
2083
2119
  once: true
2084
2120
  });
2085
2121
 
@@ -2450,8 +2486,24 @@
2450
2486
  ratio = Math.min(Math.max(ratio, minZoomRatio), maxZoomRatio);
2451
2487
  }
2452
2488
 
2453
- if (_originalEvent && options.zoomRatio >= 0.055 && ratio > 0.95 && ratio < 1.05) {
2454
- ratio = 1;
2489
+ if (_originalEvent) {
2490
+ switch (_originalEvent.type) {
2491
+ case 'wheel':
2492
+ if (options.zoomRatio >= 0.055 && ratio > 0.95 && ratio < 1.05) {
2493
+ ratio = 1;
2494
+ }
2495
+
2496
+ break;
2497
+
2498
+ case 'pointermove':
2499
+ case 'touchmove':
2500
+ case 'mousemove':
2501
+ if (ratio > 0.99 && ratio < 1.01) {
2502
+ ratio = 1;
2503
+ }
2504
+
2505
+ break;
2506
+ }
2455
2507
  }
2456
2508
 
2457
2509
  var newWidth = naturalWidth * ratio;
@@ -2478,7 +2530,7 @@
2478
2530
 
2479
2531
  if (_originalEvent) {
2480
2532
  var offset = getOffset(this.viewer);
2481
- var center = pointers && Object.keys(pointers).length ? getPointersCenter(pointers) : {
2533
+ var center = pointers && Object.keys(pointers).length > 0 ? getPointersCenter(pointers) : {
2482
2534
  pageX: _originalEvent.pageX,
2483
2535
  pageY: _originalEvent.pageY
2484
2536
  }; // Zoom from the triggering point of the event
@@ -3520,4 +3572,4 @@
3520
3572
 
3521
3573
  return Viewer;
3522
3574
 
3523
- })));
3575
+ }));