viewerjs 1.10.2 → 1.10.5
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.
- package/README.md +6 -4
- package/dist/viewer.common.js +73 -45
- package/dist/viewer.css +164 -189
- package/dist/viewer.esm.js +73 -45
- package/dist/viewer.js +73 -45
- package/dist/viewer.min.css +3 -3
- package/dist/viewer.min.js +3 -3
- package/package.json +30 -44
- package/src/css/viewer.css +1 -0
- package/src/css/viewer.scss +1 -0
- package/src/index.css +1 -1
- package/src/index.scss +1 -1
- package/src/js/handlers.js +8 -3
- package/src/js/methods.js +24 -6
- package/src/js/others.js +13 -8
- package/src/js/viewer.js +15 -1
- package/CHANGELOG.md +0 -272
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Viewer.js
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/viewerjs) [](https://www.npmjs.com/package/viewerjs) [](https://unpkg.com/viewerjs/dist/viewer.common.js)
|
|
3
|
+
[](https://www.npmjs.com/package/viewerjs) [](https://www.npmjs.com/package/viewerjs) [](https://unpkg.com/viewerjs/dist/viewer.common.js)
|
|
4
4
|
|
|
5
5
|
> JavaScript image viewer.
|
|
6
6
|
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
- Supports keyboard
|
|
37
37
|
- Cross-browser support
|
|
38
38
|
|
|
39
|
-
## Main
|
|
39
|
+
## Main files
|
|
40
40
|
|
|
41
41
|
```text
|
|
42
42
|
dist/
|
|
@@ -206,8 +206,8 @@ new Viewer(image, {
|
|
|
206
206
|
- `{ key: String }`: customize the size of the button.
|
|
207
207
|
- `{ key: Function }`: customize the click handler of the button.
|
|
208
208
|
- `{ key: { show: Boolean | Number, size: String, click: Function }`: customize each property of the button.
|
|
209
|
-
- Available keys: "zoomIn", "zoomOut", "oneToOne", "reset", "prev", "play", "next", "rotateLeft", "rotateRight", "flipHorizontal"
|
|
210
|
-
- Available sizes: "small", "medium" (default) and "large".
|
|
209
|
+
- Available built-in keys: "zoomIn", "zoomOut", "oneToOne", "reset", "prev", "play", "next", "rotateLeft", "rotateRight", "flipHorizontal", "flipVertical".
|
|
210
|
+
- Available built-in sizes: "small", "medium" (default) and "large".
|
|
211
211
|
|
|
212
212
|
Specify the visibility and layout of the toolbar its buttons.
|
|
213
213
|
|
|
@@ -234,6 +234,8 @@ new Viewer(image, {
|
|
|
234
234
|
});
|
|
235
235
|
```
|
|
236
236
|
|
|
237
|
+
> see more for [custom toolbar](docs/examples/custom-toolbar.html).
|
|
238
|
+
|
|
237
239
|
### className
|
|
238
240
|
|
|
239
241
|
- Type: `String`
|
package/dist/viewer.common.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Viewer.js v1.10.
|
|
2
|
+
* Viewer.js v1.10.5
|
|
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:
|
|
8
|
+
* Date: 2022-04-05T08:21:02.491Z
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
@@ -15,14 +15,9 @@ function ownKeys(object, enumerableOnly) {
|
|
|
15
15
|
|
|
16
16
|
if (Object.getOwnPropertySymbols) {
|
|
17
17
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
keys.push.apply(keys, symbols);
|
|
18
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
19
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
20
|
+
})), keys.push.apply(keys, symbols);
|
|
26
21
|
}
|
|
27
22
|
|
|
28
23
|
return keys;
|
|
@@ -30,19 +25,12 @@ function ownKeys(object, enumerableOnly) {
|
|
|
30
25
|
|
|
31
26
|
function _objectSpread2(target) {
|
|
32
27
|
for (var i = 1; i < arguments.length; i++) {
|
|
33
|
-
var source = arguments[i]
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
40
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
41
|
-
} else {
|
|
42
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
43
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
44
|
-
});
|
|
45
|
-
}
|
|
28
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
29
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
30
|
+
_defineProperty(target, key, source[key]);
|
|
31
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
32
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
33
|
+
});
|
|
46
34
|
}
|
|
47
35
|
|
|
48
36
|
return target;
|
|
@@ -51,17 +39,11 @@ function _objectSpread2(target) {
|
|
|
51
39
|
function _typeof(obj) {
|
|
52
40
|
"@babel/helpers - typeof";
|
|
53
41
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
_typeof = function (obj) {
|
|
60
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return _typeof(obj);
|
|
42
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
43
|
+
return typeof obj;
|
|
44
|
+
} : function (obj) {
|
|
45
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
46
|
+
}, _typeof(obj);
|
|
65
47
|
}
|
|
66
48
|
|
|
67
49
|
function _classCallCheck(instance, Constructor) {
|
|
@@ -83,6 +65,9 @@ function _defineProperties(target, props) {
|
|
|
83
65
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
84
66
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
85
67
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
68
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
69
|
+
writable: false
|
|
70
|
+
});
|
|
86
71
|
return Constructor;
|
|
87
72
|
}
|
|
88
73
|
|
|
@@ -1454,9 +1439,10 @@ var handlers = {
|
|
|
1454
1439
|
// Cancel the emulated double click when the native dblclick event was triggered.
|
|
1455
1440
|
if (IS_TOUCH_DEVICE && event.isTrusted) {
|
|
1456
1441
|
clearTimeout(this.doubleClickImageTimeout);
|
|
1457
|
-
}
|
|
1442
|
+
} // XXX: No pageX/Y properties in custom event, fallback to the original event.
|
|
1443
|
+
|
|
1458
1444
|
|
|
1459
|
-
this.toggle(event);
|
|
1445
|
+
this.toggle(event.isTrusted ? event : event.detail && event.detail.originalEvent);
|
|
1460
1446
|
}
|
|
1461
1447
|
},
|
|
1462
1448
|
load: function load() {
|
|
@@ -1723,7 +1709,9 @@ var handlers = {
|
|
|
1723
1709
|
this.imageClicked = false; // This timeout will be cleared later when a native dblclick event is triggering
|
|
1724
1710
|
|
|
1725
1711
|
this.doubleClickImageTimeout = setTimeout(function () {
|
|
1726
|
-
dispatchEvent(_this2.image, EVENT_DBLCLICK
|
|
1712
|
+
dispatchEvent(_this2.image, EVENT_DBLCLICK, {
|
|
1713
|
+
originalEvent: event
|
|
1714
|
+
});
|
|
1727
1715
|
}, 50);
|
|
1728
1716
|
} else {
|
|
1729
1717
|
this.imageClicked = true; // The default timing of a double click in Windows is 500 ms
|
|
@@ -1738,7 +1726,9 @@ var handlers = {
|
|
|
1738
1726
|
if (options.backdrop && options.backdrop !== 'static' && event.target === this.canvas) {
|
|
1739
1727
|
// This timeout will be cleared later when a native click event is triggering
|
|
1740
1728
|
this.clickCanvasTimeout = setTimeout(function () {
|
|
1741
|
-
dispatchEvent(_this2.canvas, EVENT_CLICK
|
|
1729
|
+
dispatchEvent(_this2.canvas, EVENT_CLICK, {
|
|
1730
|
+
originalEvent: event
|
|
1731
|
+
});
|
|
1742
1732
|
}, 50);
|
|
1743
1733
|
}
|
|
1744
1734
|
}
|
|
@@ -2492,8 +2482,24 @@ var methods = {
|
|
|
2492
2482
|
ratio = Math.min(Math.max(ratio, minZoomRatio), maxZoomRatio);
|
|
2493
2483
|
}
|
|
2494
2484
|
|
|
2495
|
-
if (_originalEvent
|
|
2496
|
-
|
|
2485
|
+
if (_originalEvent) {
|
|
2486
|
+
switch (_originalEvent.type) {
|
|
2487
|
+
case 'wheel':
|
|
2488
|
+
if (options.zoomRatio >= 0.055 && ratio > 0.95 && ratio < 1.05) {
|
|
2489
|
+
ratio = 1;
|
|
2490
|
+
}
|
|
2491
|
+
|
|
2492
|
+
break;
|
|
2493
|
+
|
|
2494
|
+
case 'pointermove':
|
|
2495
|
+
case 'touchmove':
|
|
2496
|
+
case 'mousemove':
|
|
2497
|
+
if (ratio > 0.99 && ratio < 1.01) {
|
|
2498
|
+
ratio = 1;
|
|
2499
|
+
}
|
|
2500
|
+
|
|
2501
|
+
break;
|
|
2502
|
+
}
|
|
2497
2503
|
}
|
|
2498
2504
|
|
|
2499
2505
|
var newWidth = naturalWidth * ratio;
|
|
@@ -2520,7 +2526,7 @@ var methods = {
|
|
|
2520
2526
|
|
|
2521
2527
|
if (_originalEvent) {
|
|
2522
2528
|
var offset = getOffset(this.viewer);
|
|
2523
|
-
var center = pointers && Object.keys(pointers).length ? getPointersCenter(pointers) : {
|
|
2529
|
+
var center = pointers && Object.keys(pointers).length > 0 ? getPointersCenter(pointers) : {
|
|
2524
2530
|
pageX: _originalEvent.pageX,
|
|
2525
2531
|
pageY: _originalEvent.pageY
|
|
2526
2532
|
}; // Zoom from the triggering point of the event
|
|
@@ -3034,10 +3040,20 @@ var others = {
|
|
|
3034
3040
|
var viewer = _this.viewer;
|
|
3035
3041
|
var target = event.target;
|
|
3036
3042
|
|
|
3037
|
-
if (target
|
|
3038
|
-
|
|
3039
|
-
|
|
3043
|
+
if (target === document || target === viewer || viewer.contains(target)) {
|
|
3044
|
+
return;
|
|
3045
|
+
}
|
|
3046
|
+
|
|
3047
|
+
while (target) {
|
|
3048
|
+
// Avoid conflicts with other modals (#474, #540)
|
|
3049
|
+
if (target.getAttribute('tabindex') !== null || target.getAttribute('aria-modal') === 'true') {
|
|
3050
|
+
return;
|
|
3051
|
+
}
|
|
3052
|
+
|
|
3053
|
+
target = target.parentElement;
|
|
3040
3054
|
}
|
|
3055
|
+
|
|
3056
|
+
viewer.focus();
|
|
3041
3057
|
});
|
|
3042
3058
|
},
|
|
3043
3059
|
clearEnforceFocus: function clearEnforceFocus() {
|
|
@@ -3334,6 +3350,7 @@ var Viewer = /*#__PURE__*/function () {
|
|
|
3334
3350
|
forEach(images, function (image) {
|
|
3335
3351
|
if (!image.complete) {
|
|
3336
3352
|
removeListener(image, EVENT_LOAD, progress);
|
|
3353
|
+
removeListener(image, EVENT_ERROR, progress);
|
|
3337
3354
|
}
|
|
3338
3355
|
});
|
|
3339
3356
|
}
|
|
@@ -3342,7 +3359,18 @@ var Viewer = /*#__PURE__*/function () {
|
|
|
3342
3359
|
if (image.complete) {
|
|
3343
3360
|
progress();
|
|
3344
3361
|
} else {
|
|
3345
|
-
|
|
3362
|
+
var onLoad;
|
|
3363
|
+
var onError;
|
|
3364
|
+
addListener(image, EVENT_LOAD, onLoad = function onLoad() {
|
|
3365
|
+
removeListener(image, EVENT_ERROR, onError);
|
|
3366
|
+
progress();
|
|
3367
|
+
}, {
|
|
3368
|
+
once: true
|
|
3369
|
+
});
|
|
3370
|
+
addListener(image, EVENT_ERROR, onError = function onError() {
|
|
3371
|
+
removeListener(image, EVENT_LOAD, onLoad);
|
|
3372
|
+
progress();
|
|
3373
|
+
}, {
|
|
3346
3374
|
once: true
|
|
3347
3375
|
});
|
|
3348
3376
|
}
|