viewerjs 1.10.5 → 1.11.1
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 +32 -7
- package/dist/viewer.common.js +271 -647
- package/dist/viewer.css +17 -28
- package/dist/viewer.esm.js +271 -647
- package/dist/viewer.js +271 -647
- package/dist/viewer.min.css +3 -3
- package/dist/viewer.min.js +3 -3
- package/package.json +23 -23
- package/src/css/viewer.css +2 -1
- package/src/css/viewer.scss +2 -1
- package/src/js/defaults.js +7 -1
- package/src/js/handlers.js +11 -3
- package/src/js/methods.js +42 -19
- package/src/js/others.js +8 -3
- package/src/js/render.js +9 -3
- package/types/index.d.ts +8 -2
package/dist/viewer.common.js
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Viewer.js v1.
|
|
2
|
+
* Viewer.js v1.11.1
|
|
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: 2022-
|
|
8
|
+
* Date: 2022-11-06T05:18:19.939Z
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
13
|
function ownKeys(object, enumerableOnly) {
|
|
14
14
|
var keys = Object.keys(object);
|
|
15
|
-
|
|
16
15
|
if (Object.getOwnPropertySymbols) {
|
|
17
16
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
18
17
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
19
18
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
20
19
|
})), keys.push.apply(keys, symbols);
|
|
21
20
|
}
|
|
22
|
-
|
|
23
21
|
return keys;
|
|
24
22
|
}
|
|
25
|
-
|
|
26
23
|
function _objectSpread2(target) {
|
|
27
24
|
for (var i = 1; i < arguments.length; i++) {
|
|
28
25
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -32,10 +29,8 @@ function _objectSpread2(target) {
|
|
|
32
29
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
33
30
|
});
|
|
34
31
|
}
|
|
35
|
-
|
|
36
32
|
return target;
|
|
37
33
|
}
|
|
38
|
-
|
|
39
34
|
function _typeof(obj) {
|
|
40
35
|
"@babel/helpers - typeof";
|
|
41
36
|
|
|
@@ -45,13 +40,11 @@ function _typeof(obj) {
|
|
|
45
40
|
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
46
41
|
}, _typeof(obj);
|
|
47
42
|
}
|
|
48
|
-
|
|
49
43
|
function _classCallCheck(instance, Constructor) {
|
|
50
44
|
if (!(instance instanceof Constructor)) {
|
|
51
45
|
throw new TypeError("Cannot call a class as a function");
|
|
52
46
|
}
|
|
53
47
|
}
|
|
54
|
-
|
|
55
48
|
function _defineProperties(target, props) {
|
|
56
49
|
for (var i = 0; i < props.length; i++) {
|
|
57
50
|
var descriptor = props[i];
|
|
@@ -61,7 +54,6 @@ function _defineProperties(target, props) {
|
|
|
61
54
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
62
55
|
}
|
|
63
56
|
}
|
|
64
|
-
|
|
65
57
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
66
58
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
67
59
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
@@ -70,7 +62,6 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
|
70
62
|
});
|
|
71
63
|
return Constructor;
|
|
72
64
|
}
|
|
73
|
-
|
|
74
65
|
function _defineProperty(obj, key, value) {
|
|
75
66
|
if (key in obj) {
|
|
76
67
|
Object.defineProperty(obj, key, {
|
|
@@ -82,7 +73,6 @@ function _defineProperty(obj, key, value) {
|
|
|
82
73
|
} else {
|
|
83
74
|
obj[key] = value;
|
|
84
75
|
}
|
|
85
|
-
|
|
86
76
|
return obj;
|
|
87
77
|
}
|
|
88
78
|
|
|
@@ -93,213 +83,183 @@ var DEFAULTS = {
|
|
|
93
83
|
* @type {boolean}
|
|
94
84
|
*/
|
|
95
85
|
backdrop: true,
|
|
96
|
-
|
|
97
86
|
/**
|
|
98
87
|
* Show the button on the top-right of the viewer.
|
|
99
88
|
* @type {boolean}
|
|
100
89
|
*/
|
|
101
90
|
button: true,
|
|
102
|
-
|
|
103
91
|
/**
|
|
104
92
|
* Show the navbar.
|
|
105
93
|
* @type {boolean | number}
|
|
106
94
|
*/
|
|
107
95
|
navbar: true,
|
|
108
|
-
|
|
109
96
|
/**
|
|
110
97
|
* Specify the visibility and the content of the title.
|
|
111
98
|
* @type {boolean | number | Function | Array}
|
|
112
99
|
*/
|
|
113
100
|
title: true,
|
|
114
|
-
|
|
115
101
|
/**
|
|
116
102
|
* Show the toolbar.
|
|
117
103
|
* @type {boolean | number | Object}
|
|
118
104
|
*/
|
|
119
105
|
toolbar: true,
|
|
120
|
-
|
|
121
106
|
/**
|
|
122
107
|
* Custom class name(s) to add to the viewer's root element.
|
|
123
108
|
* @type {string}
|
|
124
109
|
*/
|
|
125
110
|
className: '',
|
|
126
|
-
|
|
127
111
|
/**
|
|
128
112
|
* Define where to put the viewer in modal mode.
|
|
129
113
|
* @type {string | Element}
|
|
130
114
|
*/
|
|
131
115
|
container: 'body',
|
|
132
|
-
|
|
133
116
|
/**
|
|
134
117
|
* Filter the images for viewing. Return true if the image is viewable.
|
|
135
118
|
* @type {Function}
|
|
136
119
|
*/
|
|
137
120
|
filter: null,
|
|
138
|
-
|
|
139
121
|
/**
|
|
140
122
|
* Enable to request fullscreen when play.
|
|
141
123
|
* {@link https://developer.mozilla.org/en-US/docs/Web/API/FullscreenOptions}
|
|
142
124
|
* @type {boolean|FullscreenOptions}
|
|
143
125
|
*/
|
|
144
126
|
fullscreen: true,
|
|
145
|
-
|
|
146
127
|
/**
|
|
147
128
|
* Define the extra attributes to inherit from the original image.
|
|
148
129
|
* @type {Array}
|
|
149
130
|
*/
|
|
150
131
|
inheritedAttributes: ['crossOrigin', 'decoding', 'isMap', 'loading', 'referrerPolicy', 'sizes', 'srcset', 'useMap'],
|
|
151
|
-
|
|
152
132
|
/**
|
|
153
|
-
* Define the initial
|
|
133
|
+
* Define the initial coverage of the viewing image.
|
|
134
|
+
* @type {number}
|
|
135
|
+
*/
|
|
136
|
+
initialCoverage: 0.9,
|
|
137
|
+
/**
|
|
138
|
+
* Define the initial index of the image for viewing.
|
|
154
139
|
* @type {number}
|
|
155
140
|
*/
|
|
156
141
|
initialViewIndex: 0,
|
|
157
|
-
|
|
158
142
|
/**
|
|
159
143
|
* Enable inline mode.
|
|
160
144
|
* @type {boolean}
|
|
161
145
|
*/
|
|
162
146
|
inline: false,
|
|
163
|
-
|
|
164
147
|
/**
|
|
165
148
|
* The amount of time to delay between automatically cycling an image when playing.
|
|
166
149
|
* @type {number}
|
|
167
150
|
*/
|
|
168
151
|
interval: 5000,
|
|
169
|
-
|
|
170
152
|
/**
|
|
171
153
|
* Enable keyboard support.
|
|
172
154
|
* @type {boolean}
|
|
173
155
|
*/
|
|
174
156
|
keyboard: true,
|
|
175
|
-
|
|
176
157
|
/**
|
|
177
158
|
* Focus the viewer when initialized.
|
|
178
159
|
* @type {boolean}
|
|
179
160
|
*/
|
|
180
161
|
focus: true,
|
|
181
|
-
|
|
182
162
|
/**
|
|
183
163
|
* Indicate if show a loading spinner when load image or not.
|
|
184
164
|
* @type {boolean}
|
|
185
165
|
*/
|
|
186
166
|
loading: true,
|
|
187
|
-
|
|
188
167
|
/**
|
|
189
168
|
* Indicate if enable loop viewing or not.
|
|
190
169
|
* @type {boolean}
|
|
191
170
|
*/
|
|
192
171
|
loop: true,
|
|
193
|
-
|
|
194
172
|
/**
|
|
195
173
|
* Min width of the viewer in inline mode.
|
|
196
174
|
* @type {number}
|
|
197
175
|
*/
|
|
198
176
|
minWidth: 200,
|
|
199
|
-
|
|
200
177
|
/**
|
|
201
178
|
* Min height of the viewer in inline mode.
|
|
202
179
|
* @type {number}
|
|
203
180
|
*/
|
|
204
181
|
minHeight: 100,
|
|
205
|
-
|
|
206
182
|
/**
|
|
207
183
|
* Enable to move the image.
|
|
208
184
|
* @type {boolean}
|
|
209
185
|
*/
|
|
210
186
|
movable: true,
|
|
211
|
-
|
|
212
187
|
/**
|
|
213
188
|
* Enable to rotate the image.
|
|
214
189
|
* @type {boolean}
|
|
215
190
|
*/
|
|
216
191
|
rotatable: true,
|
|
217
|
-
|
|
218
192
|
/**
|
|
219
193
|
* Enable to scale the image.
|
|
220
194
|
* @type {boolean}
|
|
221
195
|
*/
|
|
222
196
|
scalable: true,
|
|
223
|
-
|
|
224
197
|
/**
|
|
225
198
|
* Enable to zoom the image.
|
|
226
199
|
* @type {boolean}
|
|
227
200
|
*/
|
|
228
201
|
zoomable: true,
|
|
229
|
-
|
|
230
202
|
/**
|
|
231
203
|
* Enable to zoom the current image by dragging on the touch screen.
|
|
232
204
|
* @type {boolean}
|
|
233
205
|
*/
|
|
234
206
|
zoomOnTouch: true,
|
|
235
|
-
|
|
236
207
|
/**
|
|
237
208
|
* Enable to zoom the image by wheeling mouse.
|
|
238
209
|
* @type {boolean}
|
|
239
210
|
*/
|
|
240
211
|
zoomOnWheel: true,
|
|
241
|
-
|
|
242
212
|
/**
|
|
243
213
|
* Enable to slide to the next or previous image by swiping on the touch screen.
|
|
244
214
|
* @type {boolean}
|
|
245
215
|
*/
|
|
246
216
|
slideOnTouch: true,
|
|
247
|
-
|
|
248
217
|
/**
|
|
249
218
|
* Indicate if toggle the image size between its natural size
|
|
250
219
|
* and initial size when double click on the image or not.
|
|
251
220
|
* @type {boolean}
|
|
252
221
|
*/
|
|
253
222
|
toggleOnDblclick: true,
|
|
254
|
-
|
|
255
223
|
/**
|
|
256
224
|
* Show the tooltip with image ratio (percentage) when zoom in or zoom out.
|
|
257
225
|
* @type {boolean}
|
|
258
226
|
*/
|
|
259
227
|
tooltip: true,
|
|
260
|
-
|
|
261
228
|
/**
|
|
262
229
|
* Enable CSS3 Transition for some special elements.
|
|
263
230
|
* @type {boolean}
|
|
264
231
|
*/
|
|
265
232
|
transition: true,
|
|
266
|
-
|
|
267
233
|
/**
|
|
268
234
|
* Define the CSS `z-index` value of viewer in modal mode.
|
|
269
235
|
* @type {number}
|
|
270
236
|
*/
|
|
271
237
|
zIndex: 2015,
|
|
272
|
-
|
|
273
238
|
/**
|
|
274
239
|
* Define the CSS `z-index` value of viewer in inline mode.
|
|
275
240
|
* @type {number}
|
|
276
241
|
*/
|
|
277
242
|
zIndexInline: 0,
|
|
278
|
-
|
|
279
243
|
/**
|
|
280
244
|
* Define the ratio when zoom the image by wheeling mouse.
|
|
281
245
|
* @type {number}
|
|
282
246
|
*/
|
|
283
247
|
zoomRatio: 0.1,
|
|
284
|
-
|
|
285
248
|
/**
|
|
286
249
|
* Define the min ratio of the image when zoom out.
|
|
287
250
|
* @type {number}
|
|
288
251
|
*/
|
|
289
252
|
minZoomRatio: 0.01,
|
|
290
|
-
|
|
291
253
|
/**
|
|
292
254
|
* Define the max ratio of the image when zoom in.
|
|
293
255
|
* @type {number}
|
|
294
256
|
*/
|
|
295
257
|
maxZoomRatio: 100,
|
|
296
|
-
|
|
297
258
|
/**
|
|
298
259
|
* Define where to get the original image URL for viewing.
|
|
299
260
|
* @type {string | Function}
|
|
300
261
|
*/
|
|
301
262
|
url: 'src',
|
|
302
|
-
|
|
303
263
|
/**
|
|
304
264
|
* Event shortcuts.
|
|
305
265
|
* @type {Function}
|
|
@@ -329,12 +289,14 @@ var IS_BROWSER = typeof window !== 'undefined' && typeof window.document !== 'un
|
|
|
329
289
|
var WINDOW = IS_BROWSER ? window : {};
|
|
330
290
|
var IS_TOUCH_DEVICE = IS_BROWSER && WINDOW.document.documentElement ? 'ontouchstart' in WINDOW.document.documentElement : false;
|
|
331
291
|
var HAS_POINTER_EVENT = IS_BROWSER ? 'PointerEvent' in WINDOW : false;
|
|
332
|
-
var NAMESPACE = 'viewer';
|
|
292
|
+
var NAMESPACE = 'viewer';
|
|
333
293
|
|
|
294
|
+
// Actions
|
|
334
295
|
var ACTION_MOVE = 'move';
|
|
335
296
|
var ACTION_SWITCH = 'switch';
|
|
336
|
-
var ACTION_ZOOM = 'zoom';
|
|
297
|
+
var ACTION_ZOOM = 'zoom';
|
|
337
298
|
|
|
299
|
+
// Classes
|
|
338
300
|
var CLASS_ACTIVE = "".concat(NAMESPACE, "-active");
|
|
339
301
|
var CLASS_CLOSE = "".concat(NAMESPACE, "-close");
|
|
340
302
|
var CLASS_FADE = "".concat(NAMESPACE, "-fade");
|
|
@@ -351,8 +313,9 @@ var CLASS_LOADING = "".concat(NAMESPACE, "-loading");
|
|
|
351
313
|
var CLASS_MOVE = "".concat(NAMESPACE, "-move");
|
|
352
314
|
var CLASS_OPEN = "".concat(NAMESPACE, "-open");
|
|
353
315
|
var CLASS_SHOW = "".concat(NAMESPACE, "-show");
|
|
354
|
-
var CLASS_TRANSITION = "".concat(NAMESPACE, "-transition");
|
|
316
|
+
var CLASS_TRANSITION = "".concat(NAMESPACE, "-transition");
|
|
355
317
|
|
|
318
|
+
// Native events
|
|
356
319
|
var EVENT_CLICK = 'click';
|
|
357
320
|
var EVENT_DBLCLICK = 'dblclick';
|
|
358
321
|
var EVENT_DRAG_START = 'dragstart';
|
|
@@ -368,8 +331,9 @@ var EVENT_POINTER_MOVE = HAS_POINTER_EVENT ? 'pointermove' : EVENT_TOUCH_MOVE;
|
|
|
368
331
|
var EVENT_POINTER_UP = HAS_POINTER_EVENT ? 'pointerup pointercancel' : EVENT_TOUCH_END;
|
|
369
332
|
var EVENT_RESIZE = 'resize';
|
|
370
333
|
var EVENT_TRANSITION_END = 'transitionend';
|
|
371
|
-
var EVENT_WHEEL = 'wheel';
|
|
334
|
+
var EVENT_WHEEL = 'wheel';
|
|
372
335
|
|
|
336
|
+
// Custom events
|
|
373
337
|
var EVENT_READY = 'ready';
|
|
374
338
|
var EVENT_SHOW = 'show';
|
|
375
339
|
var EVENT_SHOWN = 'shown';
|
|
@@ -386,12 +350,15 @@ var EVENT_SCALED = 'scaled';
|
|
|
386
350
|
var EVENT_ZOOM = 'zoom';
|
|
387
351
|
var EVENT_ZOOMED = 'zoomed';
|
|
388
352
|
var EVENT_PLAY = 'play';
|
|
389
|
-
var EVENT_STOP = 'stop';
|
|
353
|
+
var EVENT_STOP = 'stop';
|
|
390
354
|
|
|
391
|
-
|
|
355
|
+
// Data keys
|
|
356
|
+
var DATA_ACTION = "".concat(NAMESPACE, "Action");
|
|
392
357
|
|
|
393
|
-
|
|
358
|
+
// RegExps
|
|
359
|
+
var REGEXP_SPACES = /\s\s*/;
|
|
394
360
|
|
|
361
|
+
// Misc
|
|
395
362
|
var BUTTONS = ['zoom-in', 'zoom-out', 'one-to-one', 'reset', 'prev', 'play', 'next', 'rotate-left', 'rotate-right', 'flip-horizontal', 'flip-vertical'];
|
|
396
363
|
|
|
397
364
|
/**
|
|
@@ -399,54 +366,52 @@ var BUTTONS = ['zoom-in', 'zoom-out', 'one-to-one', 'reset', 'prev', 'play', 'ne
|
|
|
399
366
|
* @param {*} value - The value to check.
|
|
400
367
|
* @returns {boolean} Returns `true` if the given value is a string, else `false`.
|
|
401
368
|
*/
|
|
402
|
-
|
|
403
369
|
function isString(value) {
|
|
404
370
|
return typeof value === 'string';
|
|
405
371
|
}
|
|
372
|
+
|
|
406
373
|
/**
|
|
407
374
|
* Check if the given value is not a number.
|
|
408
375
|
*/
|
|
409
|
-
|
|
410
376
|
var isNaN = Number.isNaN || WINDOW.isNaN;
|
|
377
|
+
|
|
411
378
|
/**
|
|
412
379
|
* Check if the given value is a number.
|
|
413
380
|
* @param {*} value - The value to check.
|
|
414
381
|
* @returns {boolean} Returns `true` if the given value is a number, else `false`.
|
|
415
382
|
*/
|
|
416
|
-
|
|
417
383
|
function isNumber(value) {
|
|
418
384
|
return typeof value === 'number' && !isNaN(value);
|
|
419
385
|
}
|
|
386
|
+
|
|
420
387
|
/**
|
|
421
388
|
* Check if the given value is undefined.
|
|
422
389
|
* @param {*} value - The value to check.
|
|
423
390
|
* @returns {boolean} Returns `true` if the given value is undefined, else `false`.
|
|
424
391
|
*/
|
|
425
|
-
|
|
426
392
|
function isUndefined(value) {
|
|
427
393
|
return typeof value === 'undefined';
|
|
428
394
|
}
|
|
395
|
+
|
|
429
396
|
/**
|
|
430
397
|
* Check if the given value is an object.
|
|
431
398
|
* @param {*} value - The value to check.
|
|
432
399
|
* @returns {boolean} Returns `true` if the given value is an object, else `false`.
|
|
433
400
|
*/
|
|
434
|
-
|
|
435
401
|
function isObject(value) {
|
|
436
402
|
return _typeof(value) === 'object' && value !== null;
|
|
437
403
|
}
|
|
438
404
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
405
|
+
|
|
439
406
|
/**
|
|
440
407
|
* Check if the given value is a plain object.
|
|
441
408
|
* @param {*} value - The value to check.
|
|
442
409
|
* @returns {boolean} Returns `true` if the given value is a plain object, else `false`.
|
|
443
410
|
*/
|
|
444
|
-
|
|
445
411
|
function isPlainObject(value) {
|
|
446
412
|
if (!isObject(value)) {
|
|
447
413
|
return false;
|
|
448
414
|
}
|
|
449
|
-
|
|
450
415
|
try {
|
|
451
416
|
var _constructor = value.constructor;
|
|
452
417
|
var prototype = _constructor.prototype;
|
|
@@ -455,30 +420,27 @@ function isPlainObject(value) {
|
|
|
455
420
|
return false;
|
|
456
421
|
}
|
|
457
422
|
}
|
|
423
|
+
|
|
458
424
|
/**
|
|
459
425
|
* Check if the given value is a function.
|
|
460
426
|
* @param {*} value - The value to check.
|
|
461
427
|
* @returns {boolean} Returns `true` if the given value is a function, else `false`.
|
|
462
428
|
*/
|
|
463
|
-
|
|
464
429
|
function isFunction(value) {
|
|
465
430
|
return typeof value === 'function';
|
|
466
431
|
}
|
|
432
|
+
|
|
467
433
|
/**
|
|
468
434
|
* Iterate the given data.
|
|
469
435
|
* @param {*} data - The data to iterate.
|
|
470
436
|
* @param {Function} callback - The process function for each element.
|
|
471
437
|
* @returns {*} The original data.
|
|
472
438
|
*/
|
|
473
|
-
|
|
474
439
|
function forEach(data, callback) {
|
|
475
440
|
if (data && isFunction(callback)) {
|
|
476
|
-
if (Array.isArray(data) || isNumber(data.length)
|
|
477
|
-
/* array-like */
|
|
478
|
-
) {
|
|
441
|
+
if (Array.isArray(data) || isNumber(data.length) /* array-like */) {
|
|
479
442
|
var length = data.length;
|
|
480
443
|
var i;
|
|
481
|
-
|
|
482
444
|
for (i = 0; i < length; i += 1) {
|
|
483
445
|
if (callback.call(data, data[i], i, data) === false) {
|
|
484
446
|
break;
|
|
@@ -490,21 +452,19 @@ function forEach(data, callback) {
|
|
|
490
452
|
});
|
|
491
453
|
}
|
|
492
454
|
}
|
|
493
|
-
|
|
494
455
|
return data;
|
|
495
456
|
}
|
|
457
|
+
|
|
496
458
|
/**
|
|
497
459
|
* Extend the given object.
|
|
498
460
|
* @param {*} obj - The object to be extended.
|
|
499
461
|
* @param {*} args - The rest objects which will be merged to the first object.
|
|
500
462
|
* @returns {Object} The extended object.
|
|
501
463
|
*/
|
|
502
|
-
|
|
503
464
|
var assign = Object.assign || function assign(obj) {
|
|
504
465
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
505
466
|
args[_key - 1] = arguments[_key];
|
|
506
467
|
}
|
|
507
|
-
|
|
508
468
|
if (isObject(obj) && args.length > 0) {
|
|
509
469
|
args.forEach(function (arg) {
|
|
510
470
|
if (isObject(arg)) {
|
|
@@ -514,127 +474,116 @@ var assign = Object.assign || function assign(obj) {
|
|
|
514
474
|
}
|
|
515
475
|
});
|
|
516
476
|
}
|
|
517
|
-
|
|
518
477
|
return obj;
|
|
519
478
|
};
|
|
520
479
|
var REGEXP_SUFFIX = /^(?:width|height|left|top|marginLeft|marginTop)$/;
|
|
480
|
+
|
|
521
481
|
/**
|
|
522
482
|
* Apply styles to the given element.
|
|
523
483
|
* @param {Element} element - The target element.
|
|
524
484
|
* @param {Object} styles - The styles for applying.
|
|
525
485
|
*/
|
|
526
|
-
|
|
527
486
|
function setStyle(element, styles) {
|
|
528
487
|
var style = element.style;
|
|
529
488
|
forEach(styles, function (value, property) {
|
|
530
489
|
if (REGEXP_SUFFIX.test(property) && isNumber(value)) {
|
|
531
490
|
value += 'px';
|
|
532
491
|
}
|
|
533
|
-
|
|
534
492
|
style[property] = value;
|
|
535
493
|
});
|
|
536
494
|
}
|
|
495
|
+
|
|
537
496
|
/**
|
|
538
497
|
* Escape a string for using in HTML.
|
|
539
498
|
* @param {String} value - The string to escape.
|
|
540
499
|
* @returns {String} Returns the escaped string.
|
|
541
500
|
*/
|
|
542
|
-
|
|
543
501
|
function escapeHTMLEntities(value) {
|
|
544
502
|
return isString(value) ? value.replace(/&(?!amp;|quot;|#39;|lt;|gt;)/g, '&').replace(/"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>') : value;
|
|
545
503
|
}
|
|
504
|
+
|
|
546
505
|
/**
|
|
547
506
|
* Check if the given element has a special class.
|
|
548
507
|
* @param {Element} element - The element to check.
|
|
549
508
|
* @param {string} value - The class to search.
|
|
550
509
|
* @returns {boolean} Returns `true` if the special class was found.
|
|
551
510
|
*/
|
|
552
|
-
|
|
553
511
|
function hasClass(element, value) {
|
|
554
512
|
if (!element || !value) {
|
|
555
513
|
return false;
|
|
556
514
|
}
|
|
557
|
-
|
|
558
515
|
return element.classList ? element.classList.contains(value) : element.className.indexOf(value) > -1;
|
|
559
516
|
}
|
|
517
|
+
|
|
560
518
|
/**
|
|
561
519
|
* Add classes to the given element.
|
|
562
520
|
* @param {Element} element - The target element.
|
|
563
521
|
* @param {string} value - The classes to be added.
|
|
564
522
|
*/
|
|
565
|
-
|
|
566
523
|
function addClass(element, value) {
|
|
567
524
|
if (!element || !value) {
|
|
568
525
|
return;
|
|
569
526
|
}
|
|
570
|
-
|
|
571
527
|
if (isNumber(element.length)) {
|
|
572
528
|
forEach(element, function (elem) {
|
|
573
529
|
addClass(elem, value);
|
|
574
530
|
});
|
|
575
531
|
return;
|
|
576
532
|
}
|
|
577
|
-
|
|
578
533
|
if (element.classList) {
|
|
579
534
|
element.classList.add(value);
|
|
580
535
|
return;
|
|
581
536
|
}
|
|
582
|
-
|
|
583
537
|
var className = element.className.trim();
|
|
584
|
-
|
|
585
538
|
if (!className) {
|
|
586
539
|
element.className = value;
|
|
587
540
|
} else if (className.indexOf(value) < 0) {
|
|
588
541
|
element.className = "".concat(className, " ").concat(value);
|
|
589
542
|
}
|
|
590
543
|
}
|
|
544
|
+
|
|
591
545
|
/**
|
|
592
546
|
* Remove classes from the given element.
|
|
593
547
|
* @param {Element} element - The target element.
|
|
594
548
|
* @param {string} value - The classes to be removed.
|
|
595
549
|
*/
|
|
596
|
-
|
|
597
550
|
function removeClass(element, value) {
|
|
598
551
|
if (!element || !value) {
|
|
599
552
|
return;
|
|
600
553
|
}
|
|
601
|
-
|
|
602
554
|
if (isNumber(element.length)) {
|
|
603
555
|
forEach(element, function (elem) {
|
|
604
556
|
removeClass(elem, value);
|
|
605
557
|
});
|
|
606
558
|
return;
|
|
607
559
|
}
|
|
608
|
-
|
|
609
560
|
if (element.classList) {
|
|
610
561
|
element.classList.remove(value);
|
|
611
562
|
return;
|
|
612
563
|
}
|
|
613
|
-
|
|
614
564
|
if (element.className.indexOf(value) >= 0) {
|
|
615
565
|
element.className = element.className.replace(value, '');
|
|
616
566
|
}
|
|
617
567
|
}
|
|
568
|
+
|
|
618
569
|
/**
|
|
619
570
|
* Add or remove classes from the given element.
|
|
620
571
|
* @param {Element} element - The target element.
|
|
621
572
|
* @param {string} value - The classes to be toggled.
|
|
622
573
|
* @param {boolean} added - Add only.
|
|
623
574
|
*/
|
|
624
|
-
|
|
625
575
|
function toggleClass(element, value, added) {
|
|
626
576
|
if (!value) {
|
|
627
577
|
return;
|
|
628
578
|
}
|
|
629
|
-
|
|
630
579
|
if (isNumber(element.length)) {
|
|
631
580
|
forEach(element, function (elem) {
|
|
632
581
|
toggleClass(elem, value, added);
|
|
633
582
|
});
|
|
634
583
|
return;
|
|
635
|
-
}
|
|
636
|
-
|
|
584
|
+
}
|
|
637
585
|
|
|
586
|
+
// IE10-11 doesn't support the second parameter of `classList.toggle`
|
|
638
587
|
if (added) {
|
|
639
588
|
addClass(element, value);
|
|
640
589
|
} else {
|
|
@@ -642,40 +591,38 @@ function toggleClass(element, value, added) {
|
|
|
642
591
|
}
|
|
643
592
|
}
|
|
644
593
|
var REGEXP_HYPHENATE = /([a-z\d])([A-Z])/g;
|
|
594
|
+
|
|
645
595
|
/**
|
|
646
596
|
* Transform the given string from camelCase to kebab-case
|
|
647
597
|
* @param {string} value - The value to transform.
|
|
648
598
|
* @returns {string} The transformed value.
|
|
649
599
|
*/
|
|
650
|
-
|
|
651
600
|
function hyphenate(value) {
|
|
652
601
|
return value.replace(REGEXP_HYPHENATE, '$1-$2').toLowerCase();
|
|
653
602
|
}
|
|
603
|
+
|
|
654
604
|
/**
|
|
655
605
|
* Get data from the given element.
|
|
656
606
|
* @param {Element} element - The target element.
|
|
657
607
|
* @param {string} name - The data key to get.
|
|
658
608
|
* @returns {string} The data value.
|
|
659
609
|
*/
|
|
660
|
-
|
|
661
610
|
function getData(element, name) {
|
|
662
611
|
if (isObject(element[name])) {
|
|
663
612
|
return element[name];
|
|
664
613
|
}
|
|
665
|
-
|
|
666
614
|
if (element.dataset) {
|
|
667
615
|
return element.dataset[name];
|
|
668
616
|
}
|
|
669
|
-
|
|
670
617
|
return element.getAttribute("data-".concat(hyphenate(name)));
|
|
671
618
|
}
|
|
619
|
+
|
|
672
620
|
/**
|
|
673
621
|
* Set data to the given element.
|
|
674
622
|
* @param {Element} element - The target element.
|
|
675
623
|
* @param {string} name - The data key to set.
|
|
676
624
|
* @param {string} data - The data value.
|
|
677
625
|
*/
|
|
678
|
-
|
|
679
626
|
function setData(element, name, data) {
|
|
680
627
|
if (isObject(data)) {
|
|
681
628
|
element[name] = data;
|
|
@@ -685,21 +632,16 @@ function setData(element, name, data) {
|
|
|
685
632
|
element.setAttribute("data-".concat(hyphenate(name)), data);
|
|
686
633
|
}
|
|
687
634
|
}
|
|
688
|
-
|
|
689
635
|
var onceSupported = function () {
|
|
690
636
|
var supported = false;
|
|
691
|
-
|
|
692
637
|
if (IS_BROWSER) {
|
|
693
638
|
var once = false;
|
|
694
|
-
|
|
695
639
|
var listener = function listener() {};
|
|
696
|
-
|
|
697
640
|
var options = Object.defineProperty({}, 'once', {
|
|
698
641
|
get: function get() {
|
|
699
642
|
supported = true;
|
|
700
643
|
return once;
|
|
701
644
|
},
|
|
702
|
-
|
|
703
645
|
/**
|
|
704
646
|
* This setter can fix a `TypeError` in strict mode
|
|
705
647
|
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Getter_only}
|
|
@@ -712,9 +654,9 @@ var onceSupported = function () {
|
|
|
712
654
|
WINDOW.addEventListener('test', listener, options);
|
|
713
655
|
WINDOW.removeEventListener('test', listener, options);
|
|
714
656
|
}
|
|
715
|
-
|
|
716
657
|
return supported;
|
|
717
658
|
}();
|
|
659
|
+
|
|
718
660
|
/**
|
|
719
661
|
* Remove event listener from the target element.
|
|
720
662
|
* @param {Element} element - The event target.
|
|
@@ -722,32 +664,27 @@ var onceSupported = function () {
|
|
|
722
664
|
* @param {Function} listener - The event listener.
|
|
723
665
|
* @param {Object} options - The event options.
|
|
724
666
|
*/
|
|
725
|
-
|
|
726
|
-
|
|
727
667
|
function removeListener(element, type, listener) {
|
|
728
668
|
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
729
669
|
var handler = listener;
|
|
730
670
|
type.trim().split(REGEXP_SPACES).forEach(function (event) {
|
|
731
671
|
if (!onceSupported) {
|
|
732
672
|
var listeners = element.listeners;
|
|
733
|
-
|
|
734
673
|
if (listeners && listeners[event] && listeners[event][listener]) {
|
|
735
674
|
handler = listeners[event][listener];
|
|
736
675
|
delete listeners[event][listener];
|
|
737
|
-
|
|
738
676
|
if (Object.keys(listeners[event]).length === 0) {
|
|
739
677
|
delete listeners[event];
|
|
740
678
|
}
|
|
741
|
-
|
|
742
679
|
if (Object.keys(listeners).length === 0) {
|
|
743
680
|
delete element.listeners;
|
|
744
681
|
}
|
|
745
682
|
}
|
|
746
683
|
}
|
|
747
|
-
|
|
748
684
|
element.removeEventListener(event, handler, options);
|
|
749
685
|
});
|
|
750
686
|
}
|
|
687
|
+
|
|
751
688
|
/**
|
|
752
689
|
* Add event listener to the target element.
|
|
753
690
|
* @param {Element} element - The event target.
|
|
@@ -755,41 +692,34 @@ function removeListener(element, type, listener) {
|
|
|
755
692
|
* @param {Function} listener - The event listener.
|
|
756
693
|
* @param {Object} options - The event options.
|
|
757
694
|
*/
|
|
758
|
-
|
|
759
695
|
function addListener(element, type, listener) {
|
|
760
696
|
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
761
697
|
var _handler = listener;
|
|
762
698
|
type.trim().split(REGEXP_SPACES).forEach(function (event) {
|
|
763
699
|
if (options.once && !onceSupported) {
|
|
764
700
|
var _element$listeners = element.listeners,
|
|
765
|
-
|
|
766
|
-
|
|
701
|
+
listeners = _element$listeners === void 0 ? {} : _element$listeners;
|
|
767
702
|
_handler = function handler() {
|
|
768
703
|
delete listeners[event][listener];
|
|
769
704
|
element.removeEventListener(event, _handler, options);
|
|
770
|
-
|
|
771
705
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
772
706
|
args[_key2] = arguments[_key2];
|
|
773
707
|
}
|
|
774
|
-
|
|
775
708
|
listener.apply(element, args);
|
|
776
709
|
};
|
|
777
|
-
|
|
778
710
|
if (!listeners[event]) {
|
|
779
711
|
listeners[event] = {};
|
|
780
712
|
}
|
|
781
|
-
|
|
782
713
|
if (listeners[event][listener]) {
|
|
783
714
|
element.removeEventListener(event, listeners[event][listener], options);
|
|
784
715
|
}
|
|
785
|
-
|
|
786
716
|
listeners[event][listener] = _handler;
|
|
787
717
|
element.listeners = listeners;
|
|
788
718
|
}
|
|
789
|
-
|
|
790
719
|
element.addEventListener(event, _handler, options);
|
|
791
720
|
});
|
|
792
721
|
}
|
|
722
|
+
|
|
793
723
|
/**
|
|
794
724
|
* Dispatch event on the target element.
|
|
795
725
|
* @param {Element} element - The event target.
|
|
@@ -798,10 +728,10 @@ function addListener(element, type, listener) {
|
|
|
798
728
|
* @param {Object} options - The additional event options.
|
|
799
729
|
* @returns {boolean} Indicate if the event is default prevented or not.
|
|
800
730
|
*/
|
|
801
|
-
|
|
802
731
|
function dispatchEvent(element, type, data, options) {
|
|
803
|
-
var event;
|
|
732
|
+
var event;
|
|
804
733
|
|
|
734
|
+
// Event and CustomEvent on IE9-11 are global objects, not constructors
|
|
805
735
|
if (isFunction(Event) && isFunction(CustomEvent)) {
|
|
806
736
|
event = new CustomEvent(type, _objectSpread2({
|
|
807
737
|
bubbles: true,
|
|
@@ -812,15 +742,14 @@ function dispatchEvent(element, type, data, options) {
|
|
|
812
742
|
event = document.createEvent('CustomEvent');
|
|
813
743
|
event.initCustomEvent(type, true, true, data);
|
|
814
744
|
}
|
|
815
|
-
|
|
816
745
|
return element.dispatchEvent(event);
|
|
817
746
|
}
|
|
747
|
+
|
|
818
748
|
/**
|
|
819
749
|
* Get the offset base on the document.
|
|
820
750
|
* @param {Element} element - The target element.
|
|
821
751
|
* @returns {Object} The offset data.
|
|
822
752
|
*/
|
|
823
|
-
|
|
824
753
|
function getOffset(element) {
|
|
825
754
|
var box = element.getBoundingClientRect();
|
|
826
755
|
return {
|
|
@@ -828,41 +757,36 @@ function getOffset(element) {
|
|
|
828
757
|
top: box.top + (window.pageYOffset - document.documentElement.clientTop)
|
|
829
758
|
};
|
|
830
759
|
}
|
|
760
|
+
|
|
831
761
|
/**
|
|
832
762
|
* Get transforms base on the given object.
|
|
833
763
|
* @param {Object} obj - The target object.
|
|
834
764
|
* @returns {string} A string contains transform values.
|
|
835
765
|
*/
|
|
836
|
-
|
|
837
766
|
function getTransforms(_ref) {
|
|
838
767
|
var rotate = _ref.rotate,
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
768
|
+
scaleX = _ref.scaleX,
|
|
769
|
+
scaleY = _ref.scaleY,
|
|
770
|
+
translateX = _ref.translateX,
|
|
771
|
+
translateY = _ref.translateY;
|
|
843
772
|
var values = [];
|
|
844
|
-
|
|
845
773
|
if (isNumber(translateX) && translateX !== 0) {
|
|
846
774
|
values.push("translateX(".concat(translateX, "px)"));
|
|
847
775
|
}
|
|
848
|
-
|
|
849
776
|
if (isNumber(translateY) && translateY !== 0) {
|
|
850
777
|
values.push("translateY(".concat(translateY, "px)"));
|
|
851
|
-
}
|
|
852
|
-
|
|
778
|
+
}
|
|
853
779
|
|
|
780
|
+
// Rotate should come first before scale to match orientation transform
|
|
854
781
|
if (isNumber(rotate) && rotate !== 0) {
|
|
855
782
|
values.push("rotate(".concat(rotate, "deg)"));
|
|
856
783
|
}
|
|
857
|
-
|
|
858
784
|
if (isNumber(scaleX) && scaleX !== 1) {
|
|
859
785
|
values.push("scaleX(".concat(scaleX, ")"));
|
|
860
786
|
}
|
|
861
|
-
|
|
862
787
|
if (isNumber(scaleY) && scaleY !== 1) {
|
|
863
788
|
values.push("scaleY(".concat(scaleY, ")"));
|
|
864
789
|
}
|
|
865
|
-
|
|
866
790
|
var transform = values.length ? values.join(' ') : 'none';
|
|
867
791
|
return {
|
|
868
792
|
WebkitTransform: transform,
|
|
@@ -870,6 +794,7 @@ function getTransforms(_ref) {
|
|
|
870
794
|
transform: transform
|
|
871
795
|
};
|
|
872
796
|
}
|
|
797
|
+
|
|
873
798
|
/**
|
|
874
799
|
* Get an image name from an image url.
|
|
875
800
|
* @param {string} url - The target url.
|
|
@@ -878,11 +803,11 @@ function getTransforms(_ref) {
|
|
|
878
803
|
* getImageNameFromURL('https://domain.com/path/to/picture.jpg?size=1280×960')
|
|
879
804
|
* @returns {string} A string contains the image name.
|
|
880
805
|
*/
|
|
881
|
-
|
|
882
806
|
function getImageNameFromURL(url) {
|
|
883
807
|
return isString(url) ? decodeURIComponent(url.replace(/^.*\//, '').replace(/[?&#].*$/, '')) : '';
|
|
884
808
|
}
|
|
885
809
|
var IS_SAFARI = WINDOW.navigator && /(Macintosh|iPhone|iPod|iPad).*AppleWebKit/i.test(WINDOW.navigator.userAgent);
|
|
810
|
+
|
|
886
811
|
/**
|
|
887
812
|
* Get an image's natural sizes.
|
|
888
813
|
* @param {string} image - The target image.
|
|
@@ -890,72 +815,63 @@ var IS_SAFARI = WINDOW.navigator && /(Macintosh|iPhone|iPod|iPad).*AppleWebKit/i
|
|
|
890
815
|
* @param {Function} callback - The callback function.
|
|
891
816
|
* @returns {HTMLImageElement} The new image.
|
|
892
817
|
*/
|
|
893
|
-
|
|
894
818
|
function getImageNaturalSizes(image, options, callback) {
|
|
895
|
-
var newImage = document.createElement('img');
|
|
819
|
+
var newImage = document.createElement('img');
|
|
896
820
|
|
|
821
|
+
// Modern browsers (except Safari)
|
|
897
822
|
if (image.naturalWidth && !IS_SAFARI) {
|
|
898
823
|
callback(image.naturalWidth, image.naturalHeight);
|
|
899
824
|
return newImage;
|
|
900
825
|
}
|
|
901
|
-
|
|
902
826
|
var body = document.body || document.documentElement;
|
|
903
|
-
|
|
904
827
|
newImage.onload = function () {
|
|
905
828
|
callback(newImage.width, newImage.height);
|
|
906
|
-
|
|
907
829
|
if (!IS_SAFARI) {
|
|
908
830
|
body.removeChild(newImage);
|
|
909
831
|
}
|
|
910
832
|
};
|
|
911
|
-
|
|
912
833
|
forEach(options.inheritedAttributes, function (name) {
|
|
913
834
|
var value = image.getAttribute(name);
|
|
914
|
-
|
|
915
835
|
if (value !== null) {
|
|
916
836
|
newImage.setAttribute(name, value);
|
|
917
837
|
}
|
|
918
838
|
});
|
|
919
|
-
newImage.src = image.src;
|
|
920
|
-
// with its orientation once append it into DOM
|
|
839
|
+
newImage.src = image.src;
|
|
921
840
|
|
|
841
|
+
// iOS Safari will convert the image automatically
|
|
842
|
+
// with its orientation once append it into DOM
|
|
922
843
|
if (!IS_SAFARI) {
|
|
923
844
|
newImage.style.cssText = 'left:0;' + 'max-height:none!important;' + 'max-width:none!important;' + 'min-height:0!important;' + 'min-width:0!important;' + 'opacity:0;' + 'position:absolute;' + 'top:0;' + 'z-index:-1;';
|
|
924
845
|
body.appendChild(newImage);
|
|
925
846
|
}
|
|
926
|
-
|
|
927
847
|
return newImage;
|
|
928
848
|
}
|
|
849
|
+
|
|
929
850
|
/**
|
|
930
851
|
* Get the related class name of a responsive type number.
|
|
931
852
|
* @param {string} type - The responsive type.
|
|
932
853
|
* @returns {string} The related class name.
|
|
933
854
|
*/
|
|
934
|
-
|
|
935
855
|
function getResponsiveClass(type) {
|
|
936
856
|
switch (type) {
|
|
937
857
|
case 2:
|
|
938
858
|
return CLASS_HIDE_XS_DOWN;
|
|
939
|
-
|
|
940
859
|
case 3:
|
|
941
860
|
return CLASS_HIDE_SM_DOWN;
|
|
942
|
-
|
|
943
861
|
case 4:
|
|
944
862
|
return CLASS_HIDE_MD_DOWN;
|
|
945
|
-
|
|
946
863
|
default:
|
|
947
864
|
return '';
|
|
948
865
|
}
|
|
949
866
|
}
|
|
867
|
+
|
|
950
868
|
/**
|
|
951
869
|
* Get the max ratio of a group of pointers.
|
|
952
870
|
* @param {string} pointers - The target pointers.
|
|
953
871
|
* @returns {number} The result ratio.
|
|
954
872
|
*/
|
|
955
|
-
|
|
956
873
|
function getMaxZoomRatio(pointers) {
|
|
957
874
|
var pointers2 = _objectSpread2({}, pointers);
|
|
958
|
-
|
|
959
875
|
var ratios = [];
|
|
960
876
|
forEach(pointers, function (pointer, pointerId) {
|
|
961
877
|
delete pointers2[pointerId];
|
|
@@ -975,16 +891,16 @@ function getMaxZoomRatio(pointers) {
|
|
|
975
891
|
});
|
|
976
892
|
return ratios[0];
|
|
977
893
|
}
|
|
894
|
+
|
|
978
895
|
/**
|
|
979
896
|
* Get a pointer from an event object.
|
|
980
897
|
* @param {Object} event - The target event object.
|
|
981
898
|
* @param {boolean} endOnly - Indicates if only returns the end point coordinate or not.
|
|
982
899
|
* @returns {Object} The result pointer contains start and/or end point coordinates.
|
|
983
900
|
*/
|
|
984
|
-
|
|
985
901
|
function getPointer(_ref2, endOnly) {
|
|
986
902
|
var pageX = _ref2.pageX,
|
|
987
|
-
|
|
903
|
+
pageY = _ref2.pageY;
|
|
988
904
|
var end = {
|
|
989
905
|
endX: pageX,
|
|
990
906
|
endY: pageY
|
|
@@ -995,19 +911,19 @@ function getPointer(_ref2, endOnly) {
|
|
|
995
911
|
startY: pageY
|
|
996
912
|
}, end);
|
|
997
913
|
}
|
|
914
|
+
|
|
998
915
|
/**
|
|
999
916
|
* Get the center point coordinate of a group of pointers.
|
|
1000
917
|
* @param {Object} pointers - The target pointers.
|
|
1001
918
|
* @returns {Object} The center point coordinate.
|
|
1002
919
|
*/
|
|
1003
|
-
|
|
1004
920
|
function getPointersCenter(pointers) {
|
|
1005
921
|
var pageX = 0;
|
|
1006
922
|
var pageY = 0;
|
|
1007
923
|
var count = 0;
|
|
1008
924
|
forEach(pointers, function (_ref3) {
|
|
1009
925
|
var startX = _ref3.startX,
|
|
1010
|
-
|
|
926
|
+
startY = _ref3.startY;
|
|
1011
927
|
pageX += startX;
|
|
1012
928
|
pageY += startY;
|
|
1013
929
|
count += 1;
|
|
@@ -1043,9 +959,8 @@ var render = {
|
|
|
1043
959
|
},
|
|
1044
960
|
initViewer: function initViewer() {
|
|
1045
961
|
var options = this.options,
|
|
1046
|
-
|
|
962
|
+
parent = this.parent;
|
|
1047
963
|
var viewerData;
|
|
1048
|
-
|
|
1049
964
|
if (options.inline) {
|
|
1050
965
|
viewerData = {
|
|
1051
966
|
width: Math.max(parent.offsetWidth, options.minWidth),
|
|
@@ -1053,11 +968,9 @@ var render = {
|
|
|
1053
968
|
};
|
|
1054
969
|
this.parentData = viewerData;
|
|
1055
970
|
}
|
|
1056
|
-
|
|
1057
971
|
if (this.fulled || !viewerData) {
|
|
1058
972
|
viewerData = this.containerData;
|
|
1059
973
|
}
|
|
1060
|
-
|
|
1061
974
|
this.viewerData = assign({}, viewerData);
|
|
1062
975
|
},
|
|
1063
976
|
renderViewer: function renderViewer() {
|
|
@@ -1067,40 +980,37 @@ var render = {
|
|
|
1067
980
|
},
|
|
1068
981
|
initList: function initList() {
|
|
1069
982
|
var _this = this;
|
|
1070
|
-
|
|
1071
983
|
var element = this.element,
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
var items = [];
|
|
984
|
+
options = this.options,
|
|
985
|
+
list = this.list;
|
|
986
|
+
var items = [];
|
|
1075
987
|
|
|
988
|
+
// initList may be called in this.update, so should keep idempotent
|
|
1076
989
|
list.innerHTML = '';
|
|
1077
990
|
forEach(this.images, function (image, index) {
|
|
1078
991
|
var src = image.src;
|
|
1079
992
|
var alt = image.alt || getImageNameFromURL(src);
|
|
1080
|
-
|
|
1081
993
|
var url = _this.getImageURL(image);
|
|
1082
|
-
|
|
1083
994
|
if (src || url) {
|
|
1084
995
|
var item = document.createElement('li');
|
|
1085
996
|
var img = document.createElement('img');
|
|
1086
997
|
forEach(options.inheritedAttributes, function (name) {
|
|
1087
998
|
var value = image.getAttribute(name);
|
|
1088
|
-
|
|
1089
999
|
if (value !== null) {
|
|
1090
1000
|
img.setAttribute(name, value);
|
|
1091
1001
|
}
|
|
1092
1002
|
});
|
|
1093
|
-
|
|
1003
|
+
if (options.navbar) {
|
|
1004
|
+
img.src = src || url;
|
|
1005
|
+
}
|
|
1094
1006
|
img.alt = alt;
|
|
1095
1007
|
img.setAttribute('data-original-url', url || src);
|
|
1096
1008
|
item.setAttribute('data-index', index);
|
|
1097
1009
|
item.setAttribute('data-viewer-action', 'view');
|
|
1098
1010
|
item.setAttribute('role', 'button');
|
|
1099
|
-
|
|
1100
1011
|
if (options.keyboard) {
|
|
1101
1012
|
item.setAttribute('tabindex', 0);
|
|
1102
1013
|
}
|
|
1103
|
-
|
|
1104
1014
|
item.appendChild(img);
|
|
1105
1015
|
list.appendChild(item);
|
|
1106
1016
|
items.push(item);
|
|
@@ -1112,25 +1022,20 @@ var render = {
|
|
|
1112
1022
|
var onLoad;
|
|
1113
1023
|
var onError;
|
|
1114
1024
|
setData(image, 'filled', true);
|
|
1115
|
-
|
|
1116
1025
|
if (options.loading) {
|
|
1117
1026
|
addClass(item, CLASS_LOADING);
|
|
1118
1027
|
}
|
|
1119
|
-
|
|
1120
1028
|
addListener(image, EVENT_LOAD, onLoad = function onLoad(event) {
|
|
1121
1029
|
removeListener(image, EVENT_ERROR, onError);
|
|
1122
|
-
|
|
1123
1030
|
if (options.loading) {
|
|
1124
1031
|
removeClass(item, CLASS_LOADING);
|
|
1125
1032
|
}
|
|
1126
|
-
|
|
1127
1033
|
_this.loadImage(event);
|
|
1128
1034
|
}, {
|
|
1129
1035
|
once: true
|
|
1130
1036
|
});
|
|
1131
1037
|
addListener(image, EVENT_ERROR, onError = function onError() {
|
|
1132
1038
|
removeListener(image, EVENT_LOAD, onLoad);
|
|
1133
|
-
|
|
1134
1039
|
if (options.loading) {
|
|
1135
1040
|
removeClass(item, CLASS_LOADING);
|
|
1136
1041
|
}
|
|
@@ -1138,7 +1043,6 @@ var render = {
|
|
|
1138
1043
|
once: true
|
|
1139
1044
|
});
|
|
1140
1045
|
});
|
|
1141
|
-
|
|
1142
1046
|
if (options.transition) {
|
|
1143
1047
|
addListener(element, EVENT_VIEWED, function () {
|
|
1144
1048
|
addClass(list, CLASS_TRANSITION);
|
|
@@ -1150,16 +1054,15 @@ var render = {
|
|
|
1150
1054
|
renderList: function renderList() {
|
|
1151
1055
|
var index = this.index;
|
|
1152
1056
|
var item = this.items[index];
|
|
1153
|
-
|
|
1154
1057
|
if (!item) {
|
|
1155
1058
|
return;
|
|
1156
1059
|
}
|
|
1157
|
-
|
|
1158
1060
|
var next = item.nextElementSibling;
|
|
1159
1061
|
var gutter = parseInt(window.getComputedStyle(next || item).marginLeft, 10);
|
|
1160
1062
|
var offsetWidth = item.offsetWidth;
|
|
1161
|
-
var outerWidth = offsetWidth + gutter;
|
|
1063
|
+
var outerWidth = offsetWidth + gutter;
|
|
1162
1064
|
|
|
1065
|
+
// Place the active item in the center of the screen
|
|
1163
1066
|
setStyle(this.list, assign({
|
|
1164
1067
|
width: outerWidth * this.length - gutter
|
|
1165
1068
|
}, getTransforms({
|
|
@@ -1176,10 +1079,9 @@ var render = {
|
|
|
1176
1079
|
},
|
|
1177
1080
|
initImage: function initImage(done) {
|
|
1178
1081
|
var _this2 = this;
|
|
1179
|
-
|
|
1180
1082
|
var options = this.options,
|
|
1181
|
-
|
|
1182
|
-
|
|
1083
|
+
image = this.image,
|
|
1084
|
+
viewerData = this.viewerData;
|
|
1183
1085
|
var footerHeight = this.footer.offsetHeight;
|
|
1184
1086
|
var viewerWidth = viewerData.width;
|
|
1185
1087
|
var viewerHeight = Math.max(viewerData.height - footerHeight, footerHeight);
|
|
@@ -1192,18 +1094,18 @@ var render = {
|
|
|
1192
1094
|
};
|
|
1193
1095
|
sizingImage = getImageNaturalSizes(image, options, function (naturalWidth, naturalHeight) {
|
|
1194
1096
|
var aspectRatio = naturalWidth / naturalHeight;
|
|
1097
|
+
var initialCoverage = Math.max(0, Math.min(1, options.initialCoverage));
|
|
1195
1098
|
var width = viewerWidth;
|
|
1196
1099
|
var height = viewerHeight;
|
|
1197
1100
|
_this2.imageInitializing = false;
|
|
1198
|
-
|
|
1199
1101
|
if (viewerHeight * aspectRatio > viewerWidth) {
|
|
1200
1102
|
height = viewerWidth / aspectRatio;
|
|
1201
1103
|
} else {
|
|
1202
1104
|
width = viewerHeight * aspectRatio;
|
|
1203
1105
|
}
|
|
1204
|
-
|
|
1205
|
-
width = Math.min(width *
|
|
1206
|
-
height = Math.min(height *
|
|
1106
|
+
initialCoverage = isNumber(initialCoverage) ? initialCoverage : 0.9;
|
|
1107
|
+
width = Math.min(width * initialCoverage, naturalWidth);
|
|
1108
|
+
height = Math.min(height * initialCoverage, naturalHeight);
|
|
1207
1109
|
var left = (viewerWidth - width) / 2;
|
|
1208
1110
|
var top = (viewerHeight - height) / 2;
|
|
1209
1111
|
var imageData = {
|
|
@@ -1220,22 +1122,18 @@ var render = {
|
|
|
1220
1122
|
naturalHeight: naturalHeight
|
|
1221
1123
|
};
|
|
1222
1124
|
var initialImageData = assign({}, imageData);
|
|
1223
|
-
|
|
1224
1125
|
if (options.rotatable) {
|
|
1225
1126
|
imageData.rotate = oldImageData.rotate || 0;
|
|
1226
1127
|
initialImageData.rotate = 0;
|
|
1227
1128
|
}
|
|
1228
|
-
|
|
1229
1129
|
if (options.scalable) {
|
|
1230
1130
|
imageData.scaleX = oldImageData.scaleX || 1;
|
|
1231
1131
|
imageData.scaleY = oldImageData.scaleY || 1;
|
|
1232
1132
|
initialImageData.scaleX = 1;
|
|
1233
1133
|
initialImageData.scaleY = 1;
|
|
1234
1134
|
}
|
|
1235
|
-
|
|
1236
1135
|
_this2.imageData = imageData;
|
|
1237
1136
|
_this2.initialImageData = initialImageData;
|
|
1238
|
-
|
|
1239
1137
|
if (done) {
|
|
1240
1138
|
done();
|
|
1241
1139
|
}
|
|
@@ -1243,9 +1141,8 @@ var render = {
|
|
|
1243
1141
|
},
|
|
1244
1142
|
renderImage: function renderImage(done) {
|
|
1245
1143
|
var _this3 = this;
|
|
1246
|
-
|
|
1247
1144
|
var image = this.image,
|
|
1248
|
-
|
|
1145
|
+
imageData = this.imageData;
|
|
1249
1146
|
setStyle(image, assign({
|
|
1250
1147
|
width: imageData.width,
|
|
1251
1148
|
height: imageData.height,
|
|
@@ -1253,14 +1150,12 @@ var render = {
|
|
|
1253
1150
|
marginLeft: imageData.x,
|
|
1254
1151
|
marginTop: imageData.y
|
|
1255
1152
|
}, getTransforms(imageData)));
|
|
1256
|
-
|
|
1257
1153
|
if (done) {
|
|
1258
1154
|
if ((this.viewing || this.moving || this.rotating || this.scaling || this.zooming) && this.options.transition && hasClass(image, CLASS_TRANSITION)) {
|
|
1259
1155
|
var onTransitionEnd = function onTransitionEnd() {
|
|
1260
1156
|
_this3.imageRendering = false;
|
|
1261
1157
|
done();
|
|
1262
1158
|
};
|
|
1263
|
-
|
|
1264
1159
|
this.imageRendering = {
|
|
1265
1160
|
abort: function abort() {
|
|
1266
1161
|
removeListener(image, EVENT_TRANSITION_END, onTransitionEnd);
|
|
@@ -1278,11 +1173,9 @@ var render = {
|
|
|
1278
1173
|
// this.image only defined after viewed
|
|
1279
1174
|
if (this.viewing || this.viewed) {
|
|
1280
1175
|
var image = this.image;
|
|
1281
|
-
|
|
1282
1176
|
if (this.viewing) {
|
|
1283
1177
|
this.viewing.abort();
|
|
1284
1178
|
}
|
|
1285
|
-
|
|
1286
1179
|
image.parentNode.removeChild(image);
|
|
1287
1180
|
this.image = null;
|
|
1288
1181
|
}
|
|
@@ -1292,8 +1185,8 @@ var render = {
|
|
|
1292
1185
|
var events = {
|
|
1293
1186
|
bind: function bind() {
|
|
1294
1187
|
var options = this.options,
|
|
1295
|
-
|
|
1296
|
-
|
|
1188
|
+
viewer = this.viewer,
|
|
1189
|
+
canvas = this.canvas;
|
|
1297
1190
|
var document = this.element.ownerDocument;
|
|
1298
1191
|
addListener(viewer, EVENT_CLICK, this.onClick = this.click.bind(this));
|
|
1299
1192
|
addListener(viewer, EVENT_DRAG_START, this.onDragStart = this.dragstart.bind(this));
|
|
@@ -1302,22 +1195,20 @@ var events = {
|
|
|
1302
1195
|
addListener(document, EVENT_POINTER_UP, this.onPointerUp = this.pointerup.bind(this));
|
|
1303
1196
|
addListener(document, EVENT_KEY_DOWN, this.onKeyDown = this.keydown.bind(this));
|
|
1304
1197
|
addListener(window, EVENT_RESIZE, this.onResize = this.resize.bind(this));
|
|
1305
|
-
|
|
1306
1198
|
if (options.zoomable && options.zoomOnWheel) {
|
|
1307
1199
|
addListener(viewer, EVENT_WHEEL, this.onWheel = this.wheel.bind(this), {
|
|
1308
1200
|
passive: false,
|
|
1309
1201
|
capture: true
|
|
1310
1202
|
});
|
|
1311
1203
|
}
|
|
1312
|
-
|
|
1313
1204
|
if (options.toggleOnDblclick) {
|
|
1314
1205
|
addListener(canvas, EVENT_DBLCLICK, this.onDblclick = this.dblclick.bind(this));
|
|
1315
1206
|
}
|
|
1316
1207
|
},
|
|
1317
1208
|
unbind: function unbind() {
|
|
1318
1209
|
var options = this.options,
|
|
1319
|
-
|
|
1320
|
-
|
|
1210
|
+
viewer = this.viewer,
|
|
1211
|
+
canvas = this.canvas;
|
|
1321
1212
|
var document = this.element.ownerDocument;
|
|
1322
1213
|
removeListener(viewer, EVENT_CLICK, this.onClick);
|
|
1323
1214
|
removeListener(viewer, EVENT_DRAG_START, this.onDragStart);
|
|
@@ -1326,14 +1217,12 @@ var events = {
|
|
|
1326
1217
|
removeListener(document, EVENT_POINTER_UP, this.onPointerUp);
|
|
1327
1218
|
removeListener(document, EVENT_KEY_DOWN, this.onKeyDown);
|
|
1328
1219
|
removeListener(window, EVENT_RESIZE, this.onResize);
|
|
1329
|
-
|
|
1330
1220
|
if (options.zoomable && options.zoomOnWheel) {
|
|
1331
1221
|
removeListener(viewer, EVENT_WHEEL, this.onWheel, {
|
|
1332
1222
|
passive: false,
|
|
1333
1223
|
capture: true
|
|
1334
1224
|
});
|
|
1335
1225
|
}
|
|
1336
|
-
|
|
1337
1226
|
if (options.toggleOnDblclick) {
|
|
1338
1227
|
removeListener(canvas, EVENT_DBLCLICK, this.onDblclick);
|
|
1339
1228
|
}
|
|
@@ -1343,20 +1232,18 @@ var events = {
|
|
|
1343
1232
|
var handlers = {
|
|
1344
1233
|
click: function click(event) {
|
|
1345
1234
|
var options = this.options,
|
|
1346
|
-
|
|
1235
|
+
imageData = this.imageData;
|
|
1347
1236
|
var target = event.target;
|
|
1348
1237
|
var action = getData(target, DATA_ACTION);
|
|
1349
|
-
|
|
1350
1238
|
if (!action && target.localName === 'img' && target.parentElement.localName === 'li') {
|
|
1351
1239
|
target = target.parentElement;
|
|
1352
1240
|
action = getData(target, DATA_ACTION);
|
|
1353
|
-
}
|
|
1354
|
-
|
|
1241
|
+
}
|
|
1355
1242
|
|
|
1243
|
+
// Cancel the emulated click when the native click event was triggered.
|
|
1356
1244
|
if (IS_TOUCH_DEVICE && event.isTrusted && target === this.canvas) {
|
|
1357
1245
|
clearTimeout(this.clickCanvasTimeout);
|
|
1358
1246
|
}
|
|
1359
|
-
|
|
1360
1247
|
switch (action) {
|
|
1361
1248
|
case 'mix':
|
|
1362
1249
|
if (this.played) {
|
|
@@ -1370,115 +1257,91 @@ var handlers = {
|
|
|
1370
1257
|
} else {
|
|
1371
1258
|
this.hide();
|
|
1372
1259
|
}
|
|
1373
|
-
|
|
1374
1260
|
break;
|
|
1375
|
-
|
|
1376
1261
|
case 'hide':
|
|
1377
1262
|
this.hide();
|
|
1378
1263
|
break;
|
|
1379
|
-
|
|
1380
1264
|
case 'view':
|
|
1381
1265
|
this.view(getData(target, 'index'));
|
|
1382
1266
|
break;
|
|
1383
|
-
|
|
1384
1267
|
case 'zoom-in':
|
|
1385
1268
|
this.zoom(0.1, true);
|
|
1386
1269
|
break;
|
|
1387
|
-
|
|
1388
1270
|
case 'zoom-out':
|
|
1389
1271
|
this.zoom(-0.1, true);
|
|
1390
1272
|
break;
|
|
1391
|
-
|
|
1392
1273
|
case 'one-to-one':
|
|
1393
1274
|
this.toggle();
|
|
1394
1275
|
break;
|
|
1395
|
-
|
|
1396
1276
|
case 'reset':
|
|
1397
1277
|
this.reset();
|
|
1398
1278
|
break;
|
|
1399
|
-
|
|
1400
1279
|
case 'prev':
|
|
1401
1280
|
this.prev(options.loop);
|
|
1402
1281
|
break;
|
|
1403
|
-
|
|
1404
1282
|
case 'play':
|
|
1405
1283
|
this.play(options.fullscreen);
|
|
1406
1284
|
break;
|
|
1407
|
-
|
|
1408
1285
|
case 'next':
|
|
1409
1286
|
this.next(options.loop);
|
|
1410
1287
|
break;
|
|
1411
|
-
|
|
1412
1288
|
case 'rotate-left':
|
|
1413
1289
|
this.rotate(-90);
|
|
1414
1290
|
break;
|
|
1415
|
-
|
|
1416
1291
|
case 'rotate-right':
|
|
1417
1292
|
this.rotate(90);
|
|
1418
1293
|
break;
|
|
1419
|
-
|
|
1420
1294
|
case 'flip-horizontal':
|
|
1421
1295
|
this.scaleX(-imageData.scaleX || -1);
|
|
1422
1296
|
break;
|
|
1423
|
-
|
|
1424
1297
|
case 'flip-vertical':
|
|
1425
1298
|
this.scaleY(-imageData.scaleY || -1);
|
|
1426
1299
|
break;
|
|
1427
|
-
|
|
1428
1300
|
default:
|
|
1429
1301
|
if (this.played) {
|
|
1430
1302
|
this.stop();
|
|
1431
1303
|
}
|
|
1432
|
-
|
|
1433
1304
|
}
|
|
1434
1305
|
},
|
|
1435
1306
|
dblclick: function dblclick(event) {
|
|
1436
1307
|
event.preventDefault();
|
|
1437
|
-
|
|
1438
1308
|
if (this.viewed && event.target === this.image) {
|
|
1439
1309
|
// Cancel the emulated double click when the native dblclick event was triggered.
|
|
1440
1310
|
if (IS_TOUCH_DEVICE && event.isTrusted) {
|
|
1441
1311
|
clearTimeout(this.doubleClickImageTimeout);
|
|
1442
|
-
}
|
|
1443
|
-
|
|
1312
|
+
}
|
|
1444
1313
|
|
|
1314
|
+
// XXX: No pageX/Y properties in custom event, fallback to the original event.
|
|
1445
1315
|
this.toggle(event.isTrusted ? event : event.detail && event.detail.originalEvent);
|
|
1446
1316
|
}
|
|
1447
1317
|
},
|
|
1448
1318
|
load: function load() {
|
|
1449
1319
|
var _this = this;
|
|
1450
|
-
|
|
1451
1320
|
if (this.timeout) {
|
|
1452
1321
|
clearTimeout(this.timeout);
|
|
1453
1322
|
this.timeout = false;
|
|
1454
1323
|
}
|
|
1455
|
-
|
|
1456
1324
|
var element = this.element,
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1325
|
+
options = this.options,
|
|
1326
|
+
image = this.image,
|
|
1327
|
+
index = this.index,
|
|
1328
|
+
viewerData = this.viewerData;
|
|
1461
1329
|
removeClass(image, CLASS_INVISIBLE);
|
|
1462
|
-
|
|
1463
1330
|
if (options.loading) {
|
|
1464
1331
|
removeClass(this.canvas, CLASS_LOADING);
|
|
1465
1332
|
}
|
|
1466
|
-
|
|
1467
1333
|
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;';
|
|
1468
1334
|
this.initImage(function () {
|
|
1469
1335
|
toggleClass(image, CLASS_MOVE, options.movable);
|
|
1470
1336
|
toggleClass(image, CLASS_TRANSITION, options.transition);
|
|
1471
|
-
|
|
1472
1337
|
_this.renderImage(function () {
|
|
1473
1338
|
_this.viewed = true;
|
|
1474
1339
|
_this.viewing = false;
|
|
1475
|
-
|
|
1476
1340
|
if (isFunction(options.viewed)) {
|
|
1477
1341
|
addListener(element, EVENT_VIEWED, options.viewed, {
|
|
1478
1342
|
once: true
|
|
1479
1343
|
});
|
|
1480
1344
|
}
|
|
1481
|
-
|
|
1482
1345
|
dispatchEvent(element, EVENT_VIEWED, {
|
|
1483
1346
|
originalImage: _this.images[index],
|
|
1484
1347
|
index: index,
|
|
@@ -1499,7 +1362,6 @@ var handlers = {
|
|
|
1499
1362
|
var aspectRatio = naturalWidth / naturalHeight;
|
|
1500
1363
|
var width = parentWidth;
|
|
1501
1364
|
var height = parentHeight;
|
|
1502
|
-
|
|
1503
1365
|
if (parentHeight * aspectRatio > parentWidth) {
|
|
1504
1366
|
if (filled) {
|
|
1505
1367
|
width = parentHeight * aspectRatio;
|
|
@@ -1511,7 +1373,6 @@ var handlers = {
|
|
|
1511
1373
|
} else {
|
|
1512
1374
|
width = parentHeight * aspectRatio;
|
|
1513
1375
|
}
|
|
1514
|
-
|
|
1515
1376
|
setStyle(image, assign({
|
|
1516
1377
|
width: width,
|
|
1517
1378
|
height: height
|
|
@@ -1523,27 +1384,21 @@ var handlers = {
|
|
|
1523
1384
|
},
|
|
1524
1385
|
keydown: function keydown(event) {
|
|
1525
1386
|
var options = this.options;
|
|
1526
|
-
|
|
1527
1387
|
if (!options.keyboard) {
|
|
1528
1388
|
return;
|
|
1529
1389
|
}
|
|
1530
|
-
|
|
1531
1390
|
var keyCode = event.keyCode || event.which || event.charCode;
|
|
1532
|
-
|
|
1533
1391
|
switch (keyCode) {
|
|
1534
1392
|
// Enter
|
|
1535
1393
|
case 13:
|
|
1536
1394
|
if (this.viewer.contains(event.target)) {
|
|
1537
1395
|
this.click(event);
|
|
1538
1396
|
}
|
|
1539
|
-
|
|
1540
1397
|
break;
|
|
1541
1398
|
}
|
|
1542
|
-
|
|
1543
1399
|
if (!this.fulled) {
|
|
1544
1400
|
return;
|
|
1545
1401
|
}
|
|
1546
|
-
|
|
1547
1402
|
switch (keyCode) {
|
|
1548
1403
|
// Escape
|
|
1549
1404
|
case 27:
|
|
@@ -1556,54 +1411,62 @@ var handlers = {
|
|
|
1556
1411
|
} else {
|
|
1557
1412
|
this.hide();
|
|
1558
1413
|
}
|
|
1559
|
-
|
|
1560
1414
|
break;
|
|
1561
|
-
// Space
|
|
1562
1415
|
|
|
1416
|
+
// Space
|
|
1563
1417
|
case 32:
|
|
1564
1418
|
if (this.played) {
|
|
1565
1419
|
this.stop();
|
|
1566
1420
|
}
|
|
1567
|
-
|
|
1568
1421
|
break;
|
|
1569
|
-
// ArrowLeft
|
|
1570
1422
|
|
|
1423
|
+
// ArrowLeft
|
|
1571
1424
|
case 37:
|
|
1572
|
-
this.
|
|
1425
|
+
if (this.played && this.playing) {
|
|
1426
|
+
this.playing.prev();
|
|
1427
|
+
} else {
|
|
1428
|
+
this.prev(options.loop);
|
|
1429
|
+
}
|
|
1573
1430
|
break;
|
|
1574
|
-
// ArrowUp
|
|
1575
1431
|
|
|
1432
|
+
// ArrowUp
|
|
1576
1433
|
case 38:
|
|
1577
1434
|
// Prevent scroll on Firefox
|
|
1578
|
-
event.preventDefault();
|
|
1435
|
+
event.preventDefault();
|
|
1579
1436
|
|
|
1437
|
+
// Zoom in
|
|
1580
1438
|
this.zoom(options.zoomRatio, true);
|
|
1581
1439
|
break;
|
|
1582
|
-
// ArrowRight
|
|
1583
1440
|
|
|
1441
|
+
// ArrowRight
|
|
1584
1442
|
case 39:
|
|
1585
|
-
this.
|
|
1443
|
+
if (this.played && this.playing) {
|
|
1444
|
+
this.playing.next();
|
|
1445
|
+
} else {
|
|
1446
|
+
this.next(options.loop);
|
|
1447
|
+
}
|
|
1586
1448
|
break;
|
|
1587
|
-
// ArrowDown
|
|
1588
1449
|
|
|
1450
|
+
// ArrowDown
|
|
1589
1451
|
case 40:
|
|
1590
1452
|
// Prevent scroll on Firefox
|
|
1591
|
-
event.preventDefault();
|
|
1453
|
+
event.preventDefault();
|
|
1592
1454
|
|
|
1455
|
+
// Zoom out
|
|
1593
1456
|
this.zoom(-options.zoomRatio, true);
|
|
1594
1457
|
break;
|
|
1458
|
+
|
|
1595
1459
|
// Ctrl + 0
|
|
1460
|
+
case 48:
|
|
1461
|
+
// Fall through
|
|
1596
1462
|
|
|
1597
|
-
case 48: // Fall through
|
|
1598
1463
|
// Ctrl + 1
|
|
1599
1464
|
// eslint-disable-next-line no-fallthrough
|
|
1600
|
-
|
|
1601
1465
|
case 49:
|
|
1602
1466
|
if (event.ctrlKey) {
|
|
1603
1467
|
event.preventDefault();
|
|
1604
1468
|
this.toggle();
|
|
1605
1469
|
}
|
|
1606
|
-
|
|
1607
1470
|
break;
|
|
1608
1471
|
}
|
|
1609
1472
|
},
|
|
@@ -1614,20 +1477,23 @@ var handlers = {
|
|
|
1614
1477
|
},
|
|
1615
1478
|
pointerdown: function pointerdown(event) {
|
|
1616
1479
|
var options = this.options,
|
|
1617
|
-
|
|
1480
|
+
pointers = this.pointers;
|
|
1618
1481
|
var buttons = event.buttons,
|
|
1619
|
-
|
|
1482
|
+
button = event.button;
|
|
1483
|
+
if (!this.viewed || this.showing || this.viewing || this.hiding
|
|
1484
|
+
|
|
1485
|
+
// Handle mouse event and pointer event and ignore touch event
|
|
1486
|
+
|| (event.type === 'mousedown' || event.type === 'pointerdown' && event.pointerType === 'mouse') && (
|
|
1487
|
+
// No primary button (Usually the left button)
|
|
1488
|
+
isNumber(buttons) && buttons !== 1 || isNumber(button) && button !== 0
|
|
1620
1489
|
|
|
1621
|
-
|
|
1622
|
-
|| (event.type === 'mousedown' || event.type === 'pointerdown' && event.pointerType === 'mouse') && ( // No primary button (Usually the left button)
|
|
1623
|
-
isNumber(buttons) && buttons !== 1 || isNumber(button) && button !== 0 // Open context menu
|
|
1490
|
+
// Open context menu
|
|
1624
1491
|
|| event.ctrlKey)) {
|
|
1625
1492
|
return;
|
|
1626
|
-
}
|
|
1627
|
-
|
|
1493
|
+
}
|
|
1628
1494
|
|
|
1495
|
+
// Prevent default behaviours as page zooming in touch devices.
|
|
1629
1496
|
event.preventDefault();
|
|
1630
|
-
|
|
1631
1497
|
if (event.changedTouches) {
|
|
1632
1498
|
forEach(event.changedTouches, function (touch) {
|
|
1633
1499
|
pointers[touch.identifier] = getPointer(touch);
|
|
@@ -1635,31 +1501,24 @@ var handlers = {
|
|
|
1635
1501
|
} else {
|
|
1636
1502
|
pointers[event.pointerId || 0] = getPointer(event);
|
|
1637
1503
|
}
|
|
1638
|
-
|
|
1639
1504
|
var action = options.movable ? ACTION_MOVE : false;
|
|
1640
|
-
|
|
1641
1505
|
if (options.zoomOnTouch && options.zoomable && Object.keys(pointers).length > 1) {
|
|
1642
1506
|
action = ACTION_ZOOM;
|
|
1643
1507
|
} else if (options.slideOnTouch && (event.pointerType === 'touch' || event.type === 'touchstart') && this.isSwitchable()) {
|
|
1644
1508
|
action = ACTION_SWITCH;
|
|
1645
1509
|
}
|
|
1646
|
-
|
|
1647
1510
|
if (options.transition && (action === ACTION_MOVE || action === ACTION_ZOOM)) {
|
|
1648
1511
|
removeClass(this.image, CLASS_TRANSITION);
|
|
1649
1512
|
}
|
|
1650
|
-
|
|
1651
1513
|
this.action = action;
|
|
1652
1514
|
},
|
|
1653
1515
|
pointermove: function pointermove(event) {
|
|
1654
1516
|
var pointers = this.pointers,
|
|
1655
|
-
|
|
1656
|
-
|
|
1517
|
+
action = this.action;
|
|
1657
1518
|
if (!this.viewed || !action) {
|
|
1658
1519
|
return;
|
|
1659
1520
|
}
|
|
1660
|
-
|
|
1661
1521
|
event.preventDefault();
|
|
1662
|
-
|
|
1663
1522
|
if (event.changedTouches) {
|
|
1664
1523
|
forEach(event.changedTouches, function (touch) {
|
|
1665
1524
|
assign(pointers[touch.identifier] || {}, getPointer(touch, true));
|
|
@@ -1667,17 +1526,14 @@ var handlers = {
|
|
|
1667
1526
|
} else {
|
|
1668
1527
|
assign(pointers[event.pointerId || 0] || {}, getPointer(event, true));
|
|
1669
1528
|
}
|
|
1670
|
-
|
|
1671
1529
|
this.change(event);
|
|
1672
1530
|
},
|
|
1673
1531
|
pointerup: function pointerup(event) {
|
|
1674
1532
|
var _this2 = this;
|
|
1675
|
-
|
|
1676
1533
|
var options = this.options,
|
|
1677
|
-
|
|
1678
|
-
|
|
1534
|
+
action = this.action,
|
|
1535
|
+
pointers = this.pointers;
|
|
1679
1536
|
var pointer;
|
|
1680
|
-
|
|
1681
1537
|
if (event.changedTouches) {
|
|
1682
1538
|
forEach(event.changedTouches, function (touch) {
|
|
1683
1539
|
pointer = pointers[touch.identifier];
|
|
@@ -1687,42 +1543,39 @@ var handlers = {
|
|
|
1687
1543
|
pointer = pointers[event.pointerId || 0];
|
|
1688
1544
|
delete pointers[event.pointerId || 0];
|
|
1689
1545
|
}
|
|
1690
|
-
|
|
1691
1546
|
if (!action) {
|
|
1692
1547
|
return;
|
|
1693
1548
|
}
|
|
1694
|
-
|
|
1695
1549
|
event.preventDefault();
|
|
1696
|
-
|
|
1697
1550
|
if (options.transition && (action === ACTION_MOVE || action === ACTION_ZOOM)) {
|
|
1698
1551
|
addClass(this.image, CLASS_TRANSITION);
|
|
1699
1552
|
}
|
|
1553
|
+
this.action = false;
|
|
1700
1554
|
|
|
1701
|
-
|
|
1702
|
-
|
|
1555
|
+
// Emulate click and double click in touch devices to support backdrop and image zooming (#210).
|
|
1703
1556
|
if (IS_TOUCH_DEVICE && action !== ACTION_ZOOM && pointer && Date.now() - pointer.timeStamp < 500) {
|
|
1704
1557
|
clearTimeout(this.clickCanvasTimeout);
|
|
1705
1558
|
clearTimeout(this.doubleClickImageTimeout);
|
|
1706
|
-
|
|
1707
1559
|
if (options.toggleOnDblclick && this.viewed && event.target === this.image) {
|
|
1708
1560
|
if (this.imageClicked) {
|
|
1709
|
-
this.imageClicked = false;
|
|
1561
|
+
this.imageClicked = false;
|
|
1710
1562
|
|
|
1563
|
+
// This timeout will be cleared later when a native dblclick event is triggering
|
|
1711
1564
|
this.doubleClickImageTimeout = setTimeout(function () {
|
|
1712
1565
|
dispatchEvent(_this2.image, EVENT_DBLCLICK, {
|
|
1713
1566
|
originalEvent: event
|
|
1714
1567
|
});
|
|
1715
1568
|
}, 50);
|
|
1716
1569
|
} else {
|
|
1717
|
-
this.imageClicked = true;
|
|
1570
|
+
this.imageClicked = true;
|
|
1718
1571
|
|
|
1572
|
+
// The default timing of a double click in Windows is 500 ms
|
|
1719
1573
|
this.doubleClickImageTimeout = setTimeout(function () {
|
|
1720
1574
|
_this2.imageClicked = false;
|
|
1721
1575
|
}, 500);
|
|
1722
1576
|
}
|
|
1723
1577
|
} else {
|
|
1724
1578
|
this.imageClicked = false;
|
|
1725
|
-
|
|
1726
1579
|
if (options.backdrop && options.backdrop !== 'static' && event.target === this.canvas) {
|
|
1727
1580
|
// This timeout will be cleared later when a native click event is triggering
|
|
1728
1581
|
this.clickCanvasTimeout = setTimeout(function () {
|
|
@@ -1736,34 +1589,28 @@ var handlers = {
|
|
|
1736
1589
|
},
|
|
1737
1590
|
resize: function resize() {
|
|
1738
1591
|
var _this3 = this;
|
|
1739
|
-
|
|
1740
1592
|
if (!this.isShown || this.hiding) {
|
|
1741
1593
|
return;
|
|
1742
1594
|
}
|
|
1743
|
-
|
|
1744
1595
|
if (this.fulled) {
|
|
1745
1596
|
this.close();
|
|
1746
1597
|
this.initBody();
|
|
1747
1598
|
this.open();
|
|
1748
1599
|
}
|
|
1749
|
-
|
|
1750
1600
|
this.initContainer();
|
|
1751
1601
|
this.initViewer();
|
|
1752
1602
|
this.renderViewer();
|
|
1753
1603
|
this.renderList();
|
|
1754
|
-
|
|
1755
1604
|
if (this.viewed) {
|
|
1756
1605
|
this.initImage(function () {
|
|
1757
1606
|
_this3.renderImage();
|
|
1758
1607
|
});
|
|
1759
1608
|
}
|
|
1760
|
-
|
|
1761
1609
|
if (this.played) {
|
|
1762
1610
|
if (this.options.fullscreen && this.fulled && !(document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement)) {
|
|
1763
1611
|
this.stop();
|
|
1764
1612
|
return;
|
|
1765
1613
|
}
|
|
1766
|
-
|
|
1767
1614
|
forEach(this.player.getElementsByTagName('img'), function (image) {
|
|
1768
1615
|
addListener(image, EVENT_LOAD, _this3.loadImage.bind(_this3), {
|
|
1769
1616
|
once: true
|
|
@@ -1774,24 +1621,21 @@ var handlers = {
|
|
|
1774
1621
|
},
|
|
1775
1622
|
wheel: function wheel(event) {
|
|
1776
1623
|
var _this4 = this;
|
|
1777
|
-
|
|
1778
1624
|
if (!this.viewed) {
|
|
1779
1625
|
return;
|
|
1780
1626
|
}
|
|
1627
|
+
event.preventDefault();
|
|
1781
1628
|
|
|
1782
|
-
|
|
1783
|
-
|
|
1629
|
+
// Limit wheel speed to prevent zoom too fast
|
|
1784
1630
|
if (this.wheeling) {
|
|
1785
1631
|
return;
|
|
1786
1632
|
}
|
|
1787
|
-
|
|
1788
1633
|
this.wheeling = true;
|
|
1789
1634
|
setTimeout(function () {
|
|
1790
1635
|
_this4.wheeling = false;
|
|
1791
1636
|
}, 50);
|
|
1792
1637
|
var ratio = Number(this.options.zoomRatio) || 0.1;
|
|
1793
1638
|
var delta = 1;
|
|
1794
|
-
|
|
1795
1639
|
if (event.deltaY) {
|
|
1796
1640
|
delta = event.deltaY > 0 ? 1 : -1;
|
|
1797
1641
|
} else if (event.wheelDelta) {
|
|
@@ -1799,8 +1643,7 @@ var handlers = {
|
|
|
1799
1643
|
} else if (event.detail) {
|
|
1800
1644
|
delta = event.detail > 0 ? 1 : -1;
|
|
1801
1645
|
}
|
|
1802
|
-
|
|
1803
|
-
this.zoom(-delta * ratio, true, event);
|
|
1646
|
+
this.zoom(-delta * ratio, true, null, event);
|
|
1804
1647
|
}
|
|
1805
1648
|
};
|
|
1806
1649
|
|
|
@@ -1812,36 +1655,28 @@ var methods = {
|
|
|
1812
1655
|
show: function show() {
|
|
1813
1656
|
var immediate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1814
1657
|
var element = this.element,
|
|
1815
|
-
|
|
1816
|
-
|
|
1658
|
+
options = this.options;
|
|
1817
1659
|
if (options.inline || this.showing || this.isShown || this.showing) {
|
|
1818
1660
|
return this;
|
|
1819
1661
|
}
|
|
1820
|
-
|
|
1821
1662
|
if (!this.ready) {
|
|
1822
1663
|
this.build();
|
|
1823
|
-
|
|
1824
1664
|
if (this.ready) {
|
|
1825
1665
|
this.show(immediate);
|
|
1826
1666
|
}
|
|
1827
|
-
|
|
1828
1667
|
return this;
|
|
1829
1668
|
}
|
|
1830
|
-
|
|
1831
1669
|
if (isFunction(options.show)) {
|
|
1832
1670
|
addListener(element, EVENT_SHOW, options.show, {
|
|
1833
1671
|
once: true
|
|
1834
1672
|
});
|
|
1835
1673
|
}
|
|
1836
|
-
|
|
1837
1674
|
if (dispatchEvent(element, EVENT_SHOW) === false || !this.ready) {
|
|
1838
1675
|
return this;
|
|
1839
1676
|
}
|
|
1840
|
-
|
|
1841
1677
|
if (this.hiding) {
|
|
1842
1678
|
this.transitioning.abort();
|
|
1843
1679
|
}
|
|
1844
|
-
|
|
1845
1680
|
this.showing = true;
|
|
1846
1681
|
this.open();
|
|
1847
1682
|
var viewer = this.viewer;
|
|
@@ -1850,7 +1685,6 @@ var methods = {
|
|
|
1850
1685
|
viewer.setAttribute('aria-labelledby', this.title.id);
|
|
1851
1686
|
viewer.setAttribute('aria-modal', true);
|
|
1852
1687
|
viewer.removeAttribute('aria-hidden');
|
|
1853
|
-
|
|
1854
1688
|
if (options.transition && !immediate) {
|
|
1855
1689
|
var shown = this.shown.bind(this);
|
|
1856
1690
|
this.transitioning = {
|
|
@@ -1859,8 +1693,9 @@ var methods = {
|
|
|
1859
1693
|
removeClass(viewer, CLASS_IN);
|
|
1860
1694
|
}
|
|
1861
1695
|
};
|
|
1862
|
-
addClass(viewer, CLASS_TRANSITION);
|
|
1696
|
+
addClass(viewer, CLASS_TRANSITION);
|
|
1863
1697
|
|
|
1698
|
+
// Force reflow to enable CSS3 transition
|
|
1864
1699
|
viewer.initialOffsetWidth = viewer.offsetWidth;
|
|
1865
1700
|
addListener(viewer, EVENT_TRANSITION_END, shown, {
|
|
1866
1701
|
once: true
|
|
@@ -1870,10 +1705,8 @@ var methods = {
|
|
|
1870
1705
|
addClass(viewer, CLASS_IN);
|
|
1871
1706
|
this.shown();
|
|
1872
1707
|
}
|
|
1873
|
-
|
|
1874
1708
|
return this;
|
|
1875
1709
|
},
|
|
1876
|
-
|
|
1877
1710
|
/**
|
|
1878
1711
|
* Hide the viewer (only available in modal mode)
|
|
1879
1712
|
* @param {boolean} [immediate=false] - Indicates if hide the viewer immediately or not.
|
|
@@ -1881,56 +1714,43 @@ var methods = {
|
|
|
1881
1714
|
*/
|
|
1882
1715
|
hide: function hide() {
|
|
1883
1716
|
var _this = this;
|
|
1884
|
-
|
|
1885
1717
|
var immediate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1886
1718
|
var element = this.element,
|
|
1887
|
-
|
|
1888
|
-
|
|
1719
|
+
options = this.options;
|
|
1889
1720
|
if (options.inline || this.hiding || !(this.isShown || this.showing)) {
|
|
1890
1721
|
return this;
|
|
1891
1722
|
}
|
|
1892
|
-
|
|
1893
1723
|
if (isFunction(options.hide)) {
|
|
1894
1724
|
addListener(element, EVENT_HIDE, options.hide, {
|
|
1895
1725
|
once: true
|
|
1896
1726
|
});
|
|
1897
1727
|
}
|
|
1898
|
-
|
|
1899
1728
|
if (dispatchEvent(element, EVENT_HIDE) === false) {
|
|
1900
1729
|
return this;
|
|
1901
1730
|
}
|
|
1902
|
-
|
|
1903
1731
|
if (this.showing) {
|
|
1904
1732
|
this.transitioning.abort();
|
|
1905
1733
|
}
|
|
1906
|
-
|
|
1907
1734
|
this.hiding = true;
|
|
1908
|
-
|
|
1909
1735
|
if (this.played) {
|
|
1910
1736
|
this.stop();
|
|
1911
1737
|
} else if (this.viewing) {
|
|
1912
1738
|
this.viewing.abort();
|
|
1913
1739
|
}
|
|
1914
|
-
|
|
1915
1740
|
var viewer = this.viewer,
|
|
1916
|
-
|
|
1917
|
-
|
|
1741
|
+
image = this.image;
|
|
1918
1742
|
var hideImmediately = function hideImmediately() {
|
|
1919
1743
|
removeClass(viewer, CLASS_IN);
|
|
1920
|
-
|
|
1921
1744
|
_this.hidden();
|
|
1922
1745
|
};
|
|
1923
|
-
|
|
1924
1746
|
if (options.transition && !immediate) {
|
|
1925
1747
|
var onViewerTransitionEnd = function onViewerTransitionEnd(event) {
|
|
1926
1748
|
// Ignore all propagating `transitionend` events (#275).
|
|
1927
1749
|
if (event && event.target === viewer) {
|
|
1928
1750
|
removeListener(viewer, EVENT_TRANSITION_END, onViewerTransitionEnd);
|
|
1929
|
-
|
|
1930
1751
|
_this.hidden();
|
|
1931
1752
|
}
|
|
1932
1753
|
};
|
|
1933
|
-
|
|
1934
1754
|
var onImageTransitionEnd = function onImageTransitionEnd() {
|
|
1935
1755
|
// In case of show the viewer by `viewer.show(true)` previously (#407).
|
|
1936
1756
|
if (hasClass(viewer, CLASS_TRANSITION)) {
|
|
@@ -1940,7 +1760,6 @@ var methods = {
|
|
|
1940
1760
|
hideImmediately();
|
|
1941
1761
|
}
|
|
1942
1762
|
};
|
|
1943
|
-
|
|
1944
1763
|
this.transitioning = {
|
|
1945
1764
|
abort: function abort() {
|
|
1946
1765
|
if (_this.viewed && hasClass(image, CLASS_TRANSITION)) {
|
|
@@ -1949,24 +1768,23 @@ var methods = {
|
|
|
1949
1768
|
removeListener(viewer, EVENT_TRANSITION_END, onViewerTransitionEnd);
|
|
1950
1769
|
}
|
|
1951
1770
|
}
|
|
1952
|
-
};
|
|
1953
|
-
// note that the `CLASS_TRANSITION` class will be removed on pointer down.
|
|
1771
|
+
};
|
|
1954
1772
|
|
|
1773
|
+
// In case of hiding the viewer when holding on the image (#255),
|
|
1774
|
+
// note that the `CLASS_TRANSITION` class will be removed on pointer down.
|
|
1955
1775
|
if (this.viewed && hasClass(image, CLASS_TRANSITION)) {
|
|
1956
1776
|
addListener(image, EVENT_TRANSITION_END, onImageTransitionEnd, {
|
|
1957
1777
|
once: true
|
|
1958
1778
|
});
|
|
1959
|
-
this.zoomTo(0, false, null, true);
|
|
1779
|
+
this.zoomTo(0, false, null, null, true);
|
|
1960
1780
|
} else {
|
|
1961
1781
|
onImageTransitionEnd();
|
|
1962
1782
|
}
|
|
1963
1783
|
} else {
|
|
1964
1784
|
hideImmediately();
|
|
1965
1785
|
}
|
|
1966
|
-
|
|
1967
1786
|
return this;
|
|
1968
1787
|
},
|
|
1969
|
-
|
|
1970
1788
|
/**
|
|
1971
1789
|
* View one of the images with image's index
|
|
1972
1790
|
* @param {number} index - The index of the image to view.
|
|
@@ -1974,27 +1792,22 @@ var methods = {
|
|
|
1974
1792
|
*/
|
|
1975
1793
|
view: function view() {
|
|
1976
1794
|
var _this2 = this;
|
|
1977
|
-
|
|
1978
1795
|
var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.options.initialViewIndex;
|
|
1979
1796
|
index = Number(index) || 0;
|
|
1980
|
-
|
|
1981
1797
|
if (this.hiding || this.played || index < 0 || index >= this.length || this.viewed && index === this.index) {
|
|
1982
1798
|
return this;
|
|
1983
1799
|
}
|
|
1984
|
-
|
|
1985
1800
|
if (!this.isShown) {
|
|
1986
1801
|
this.index = index;
|
|
1987
1802
|
return this.show();
|
|
1988
1803
|
}
|
|
1989
|
-
|
|
1990
1804
|
if (this.viewing) {
|
|
1991
1805
|
this.viewing.abort();
|
|
1992
1806
|
}
|
|
1993
|
-
|
|
1994
1807
|
var element = this.element,
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1808
|
+
options = this.options,
|
|
1809
|
+
title = this.title,
|
|
1810
|
+
canvas = this.canvas;
|
|
1998
1811
|
var item = this.items[index];
|
|
1999
1812
|
var img = item.querySelector('img');
|
|
2000
1813
|
var url = getData(img, 'originalUrl');
|
|
@@ -2002,20 +1815,17 @@ var methods = {
|
|
|
2002
1815
|
var image = document.createElement('img');
|
|
2003
1816
|
forEach(options.inheritedAttributes, function (name) {
|
|
2004
1817
|
var value = img.getAttribute(name);
|
|
2005
|
-
|
|
2006
1818
|
if (value !== null) {
|
|
2007
1819
|
image.setAttribute(name, value);
|
|
2008
1820
|
}
|
|
2009
1821
|
});
|
|
2010
1822
|
image.src = url;
|
|
2011
1823
|
image.alt = alt;
|
|
2012
|
-
|
|
2013
1824
|
if (isFunction(options.view)) {
|
|
2014
1825
|
addListener(element, EVENT_VIEW, options.view, {
|
|
2015
1826
|
once: true
|
|
2016
1827
|
});
|
|
2017
1828
|
}
|
|
2018
|
-
|
|
2019
1829
|
if (dispatchEvent(element, EVENT_VIEW, {
|
|
2020
1830
|
originalImage: this.images[index],
|
|
2021
1831
|
index: index,
|
|
@@ -2023,44 +1833,39 @@ var methods = {
|
|
|
2023
1833
|
}) === false || !this.isShown || this.hiding || this.played) {
|
|
2024
1834
|
return this;
|
|
2025
1835
|
}
|
|
2026
|
-
|
|
2027
1836
|
var activeItem = this.items[this.index];
|
|
2028
|
-
|
|
2029
1837
|
if (activeItem) {
|
|
2030
1838
|
removeClass(activeItem, CLASS_ACTIVE);
|
|
2031
1839
|
activeItem.removeAttribute('aria-selected');
|
|
2032
1840
|
}
|
|
2033
|
-
|
|
2034
1841
|
addClass(item, CLASS_ACTIVE);
|
|
2035
1842
|
item.setAttribute('aria-selected', true);
|
|
2036
|
-
|
|
2037
1843
|
if (options.focus) {
|
|
2038
1844
|
item.focus();
|
|
2039
1845
|
}
|
|
2040
|
-
|
|
2041
1846
|
this.image = image;
|
|
2042
1847
|
this.viewed = false;
|
|
2043
1848
|
this.index = index;
|
|
2044
1849
|
this.imageData = {};
|
|
2045
1850
|
addClass(image, CLASS_INVISIBLE);
|
|
2046
|
-
|
|
2047
1851
|
if (options.loading) {
|
|
2048
1852
|
addClass(canvas, CLASS_LOADING);
|
|
2049
1853
|
}
|
|
2050
|
-
|
|
2051
1854
|
canvas.innerHTML = '';
|
|
2052
|
-
canvas.appendChild(image);
|
|
1855
|
+
canvas.appendChild(image);
|
|
2053
1856
|
|
|
2054
|
-
|
|
1857
|
+
// Center current item
|
|
1858
|
+
this.renderList();
|
|
2055
1859
|
|
|
2056
|
-
|
|
1860
|
+
// Clear title
|
|
1861
|
+
title.innerHTML = '';
|
|
2057
1862
|
|
|
1863
|
+
// Generate title after viewed
|
|
2058
1864
|
var onViewed = function onViewed() {
|
|
2059
1865
|
var imageData = _this2.imageData;
|
|
2060
1866
|
var render = Array.isArray(options.title) ? options.title[1] : options.title;
|
|
2061
1867
|
title.innerHTML = escapeHTMLEntities(isFunction(render) ? render.call(_this2, image, imageData) : "".concat(alt, " (").concat(imageData.naturalWidth, " \xD7 ").concat(imageData.naturalHeight, ")"));
|
|
2062
1868
|
};
|
|
2063
|
-
|
|
2064
1869
|
var onLoad;
|
|
2065
1870
|
var onError;
|
|
2066
1871
|
addListener(element, EVENT_VIEWED, onViewed, {
|
|
@@ -2069,7 +1874,6 @@ var methods = {
|
|
|
2069
1874
|
this.viewing = {
|
|
2070
1875
|
abort: function abort() {
|
|
2071
1876
|
removeListener(element, EVENT_VIEWED, onViewed);
|
|
2072
|
-
|
|
2073
1877
|
if (image.complete) {
|
|
2074
1878
|
if (_this2.imageRendering) {
|
|
2075
1879
|
_this2.imageRendering.abort();
|
|
@@ -2080,55 +1884,46 @@ var methods = {
|
|
|
2080
1884
|
// Cancel download to save bandwidth.
|
|
2081
1885
|
image.src = '';
|
|
2082
1886
|
removeListener(image, EVENT_LOAD, onLoad);
|
|
2083
|
-
|
|
2084
1887
|
if (_this2.timeout) {
|
|
2085
1888
|
clearTimeout(_this2.timeout);
|
|
2086
1889
|
}
|
|
2087
1890
|
}
|
|
2088
1891
|
}
|
|
2089
1892
|
};
|
|
2090
|
-
|
|
2091
1893
|
if (image.complete) {
|
|
2092
1894
|
this.load();
|
|
2093
1895
|
} else {
|
|
2094
1896
|
addListener(image, EVENT_LOAD, onLoad = function onLoad() {
|
|
2095
1897
|
removeListener(image, EVENT_ERROR, onError);
|
|
2096
|
-
|
|
2097
1898
|
_this2.load();
|
|
2098
1899
|
}, {
|
|
2099
1900
|
once: true
|
|
2100
1901
|
});
|
|
2101
1902
|
addListener(image, EVENT_ERROR, onError = function onError() {
|
|
2102
1903
|
removeListener(image, EVENT_LOAD, onLoad);
|
|
2103
|
-
|
|
2104
1904
|
if (_this2.timeout) {
|
|
2105
1905
|
clearTimeout(_this2.timeout);
|
|
2106
1906
|
_this2.timeout = false;
|
|
2107
1907
|
}
|
|
2108
|
-
|
|
2109
1908
|
removeClass(image, CLASS_INVISIBLE);
|
|
2110
|
-
|
|
2111
1909
|
if (options.loading) {
|
|
2112
1910
|
removeClass(_this2.canvas, CLASS_LOADING);
|
|
2113
1911
|
}
|
|
2114
1912
|
}, {
|
|
2115
1913
|
once: true
|
|
2116
1914
|
});
|
|
2117
|
-
|
|
2118
1915
|
if (this.timeout) {
|
|
2119
1916
|
clearTimeout(this.timeout);
|
|
2120
|
-
}
|
|
2121
|
-
|
|
1917
|
+
}
|
|
2122
1918
|
|
|
1919
|
+
// Make the image visible if it fails to load within 1s
|
|
2123
1920
|
this.timeout = setTimeout(function () {
|
|
2124
1921
|
removeClass(image, CLASS_INVISIBLE);
|
|
2125
1922
|
_this2.timeout = false;
|
|
2126
1923
|
}, 1000);
|
|
2127
1924
|
}
|
|
2128
|
-
|
|
2129
1925
|
return this;
|
|
2130
1926
|
},
|
|
2131
|
-
|
|
2132
1927
|
/**
|
|
2133
1928
|
* View the previous image
|
|
2134
1929
|
* @param {boolean} [loop=false] - Indicate if view the last one
|
|
@@ -2138,15 +1933,12 @@ var methods = {
|
|
|
2138
1933
|
prev: function prev() {
|
|
2139
1934
|
var loop = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
2140
1935
|
var index = this.index - 1;
|
|
2141
|
-
|
|
2142
1936
|
if (index < 0) {
|
|
2143
1937
|
index = loop ? this.length - 1 : 0;
|
|
2144
1938
|
}
|
|
2145
|
-
|
|
2146
1939
|
this.view(index);
|
|
2147
1940
|
return this;
|
|
2148
1941
|
},
|
|
2149
|
-
|
|
2150
1942
|
/**
|
|
2151
1943
|
* View the next image
|
|
2152
1944
|
* @param {boolean} [loop=false] - Indicate if view the first one
|
|
@@ -2157,15 +1949,12 @@ var methods = {
|
|
|
2157
1949
|
var loop = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
2158
1950
|
var maxIndex = this.length - 1;
|
|
2159
1951
|
var index = this.index + 1;
|
|
2160
|
-
|
|
2161
1952
|
if (index > maxIndex) {
|
|
2162
1953
|
index = loop ? 0 : maxIndex;
|
|
2163
1954
|
}
|
|
2164
|
-
|
|
2165
1955
|
this.view(index);
|
|
2166
1956
|
return this;
|
|
2167
1957
|
},
|
|
2168
|
-
|
|
2169
1958
|
/**
|
|
2170
1959
|
* Move the image with relative offsets.
|
|
2171
1960
|
* @param {number} x - The moving distance in the horizontal direction.
|
|
@@ -2178,7 +1967,6 @@ var methods = {
|
|
|
2178
1967
|
this.moveTo(isUndefined(x) ? x : imageData.x + Number(x), isUndefined(y) ? y : imageData.y + Number(y));
|
|
2179
1968
|
return this;
|
|
2180
1969
|
},
|
|
2181
|
-
|
|
2182
1970
|
/**
|
|
2183
1971
|
* Move the image to an absolute point.
|
|
2184
1972
|
* @param {number} x - The new position in the horizontal direction.
|
|
@@ -2188,41 +1976,33 @@ var methods = {
|
|
|
2188
1976
|
*/
|
|
2189
1977
|
moveTo: function moveTo(x) {
|
|
2190
1978
|
var _this3 = this;
|
|
2191
|
-
|
|
2192
1979
|
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : x;
|
|
2193
|
-
|
|
2194
1980
|
var _originalEvent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
2195
|
-
|
|
2196
1981
|
var element = this.element,
|
|
2197
|
-
|
|
2198
|
-
|
|
1982
|
+
options = this.options,
|
|
1983
|
+
imageData = this.imageData;
|
|
2199
1984
|
x = Number(x);
|
|
2200
1985
|
y = Number(y);
|
|
2201
|
-
|
|
2202
1986
|
if (this.viewed && !this.played && options.movable) {
|
|
2203
1987
|
var oldX = imageData.x;
|
|
2204
1988
|
var oldY = imageData.y;
|
|
2205
1989
|
var changed = false;
|
|
2206
|
-
|
|
2207
1990
|
if (isNumber(x)) {
|
|
2208
1991
|
changed = true;
|
|
2209
1992
|
} else {
|
|
2210
1993
|
x = oldX;
|
|
2211
1994
|
}
|
|
2212
|
-
|
|
2213
1995
|
if (isNumber(y)) {
|
|
2214
1996
|
changed = true;
|
|
2215
1997
|
} else {
|
|
2216
1998
|
y = oldY;
|
|
2217
1999
|
}
|
|
2218
|
-
|
|
2219
2000
|
if (changed) {
|
|
2220
2001
|
if (isFunction(options.move)) {
|
|
2221
2002
|
addListener(element, EVENT_MOVE, options.move, {
|
|
2222
2003
|
once: true
|
|
2223
2004
|
});
|
|
2224
2005
|
}
|
|
2225
|
-
|
|
2226
2006
|
if (dispatchEvent(element, EVENT_MOVE, {
|
|
2227
2007
|
x: x,
|
|
2228
2008
|
y: y,
|
|
@@ -2232,7 +2012,6 @@ var methods = {
|
|
|
2232
2012
|
}) === false) {
|
|
2233
2013
|
return this;
|
|
2234
2014
|
}
|
|
2235
|
-
|
|
2236
2015
|
imageData.x = x;
|
|
2237
2016
|
imageData.y = y;
|
|
2238
2017
|
imageData.left = x;
|
|
@@ -2240,13 +2019,11 @@ var methods = {
|
|
|
2240
2019
|
this.moving = true;
|
|
2241
2020
|
this.renderImage(function () {
|
|
2242
2021
|
_this3.moving = false;
|
|
2243
|
-
|
|
2244
2022
|
if (isFunction(options.moved)) {
|
|
2245
2023
|
addListener(element, EVENT_MOVED, options.moved, {
|
|
2246
2024
|
once: true
|
|
2247
2025
|
});
|
|
2248
2026
|
}
|
|
2249
|
-
|
|
2250
2027
|
dispatchEvent(element, EVENT_MOVED, {
|
|
2251
2028
|
x: x,
|
|
2252
2029
|
y: y,
|
|
@@ -2259,10 +2036,8 @@ var methods = {
|
|
|
2259
2036
|
});
|
|
2260
2037
|
}
|
|
2261
2038
|
}
|
|
2262
|
-
|
|
2263
2039
|
return this;
|
|
2264
2040
|
},
|
|
2265
|
-
|
|
2266
2041
|
/**
|
|
2267
2042
|
* Rotate the image with a relative degree.
|
|
2268
2043
|
* @param {number} degree - The rotate degree.
|
|
@@ -2272,7 +2047,6 @@ var methods = {
|
|
|
2272
2047
|
this.rotateTo((this.imageData.rotate || 0) + Number(degree));
|
|
2273
2048
|
return this;
|
|
2274
2049
|
},
|
|
2275
|
-
|
|
2276
2050
|
/**
|
|
2277
2051
|
* Rotate the image to an absolute degree.
|
|
2278
2052
|
* @param {number} degree - The rotate degree.
|
|
@@ -2280,39 +2054,32 @@ var methods = {
|
|
|
2280
2054
|
*/
|
|
2281
2055
|
rotateTo: function rotateTo(degree) {
|
|
2282
2056
|
var _this4 = this;
|
|
2283
|
-
|
|
2284
2057
|
var element = this.element,
|
|
2285
|
-
|
|
2286
|
-
|
|
2058
|
+
options = this.options,
|
|
2059
|
+
imageData = this.imageData;
|
|
2287
2060
|
degree = Number(degree);
|
|
2288
|
-
|
|
2289
2061
|
if (isNumber(degree) && this.viewed && !this.played && options.rotatable) {
|
|
2290
2062
|
var oldDegree = imageData.rotate;
|
|
2291
|
-
|
|
2292
2063
|
if (isFunction(options.rotate)) {
|
|
2293
2064
|
addListener(element, EVENT_ROTATE, options.rotate, {
|
|
2294
2065
|
once: true
|
|
2295
2066
|
});
|
|
2296
2067
|
}
|
|
2297
|
-
|
|
2298
2068
|
if (dispatchEvent(element, EVENT_ROTATE, {
|
|
2299
2069
|
degree: degree,
|
|
2300
2070
|
oldDegree: oldDegree
|
|
2301
2071
|
}) === false) {
|
|
2302
2072
|
return this;
|
|
2303
2073
|
}
|
|
2304
|
-
|
|
2305
2074
|
imageData.rotate = degree;
|
|
2306
2075
|
this.rotating = true;
|
|
2307
2076
|
this.renderImage(function () {
|
|
2308
2077
|
_this4.rotating = false;
|
|
2309
|
-
|
|
2310
2078
|
if (isFunction(options.rotated)) {
|
|
2311
2079
|
addListener(element, EVENT_ROTATED, options.rotated, {
|
|
2312
2080
|
once: true
|
|
2313
2081
|
});
|
|
2314
2082
|
}
|
|
2315
|
-
|
|
2316
2083
|
dispatchEvent(element, EVENT_ROTATED, {
|
|
2317
2084
|
degree: degree,
|
|
2318
2085
|
oldDegree: oldDegree
|
|
@@ -2321,10 +2088,8 @@ var methods = {
|
|
|
2321
2088
|
});
|
|
2322
2089
|
});
|
|
2323
2090
|
}
|
|
2324
|
-
|
|
2325
2091
|
return this;
|
|
2326
2092
|
},
|
|
2327
|
-
|
|
2328
2093
|
/**
|
|
2329
2094
|
* Scale the image on the x-axis.
|
|
2330
2095
|
* @param {number} scaleX - The scale ratio on the x-axis.
|
|
@@ -2334,7 +2099,6 @@ var methods = {
|
|
|
2334
2099
|
this.scale(_scaleX, this.imageData.scaleY);
|
|
2335
2100
|
return this;
|
|
2336
2101
|
},
|
|
2337
|
-
|
|
2338
2102
|
/**
|
|
2339
2103
|
* Scale the image on the y-axis.
|
|
2340
2104
|
* @param {number} scaleY - The scale ratio on the y-axis.
|
|
@@ -2344,7 +2108,6 @@ var methods = {
|
|
|
2344
2108
|
this.scale(this.imageData.scaleX, _scaleY);
|
|
2345
2109
|
return this;
|
|
2346
2110
|
},
|
|
2347
|
-
|
|
2348
2111
|
/**
|
|
2349
2112
|
* Scale the image.
|
|
2350
2113
|
* @param {number} scaleX - The scale ratio on the x-axis.
|
|
@@ -2353,38 +2116,32 @@ var methods = {
|
|
|
2353
2116
|
*/
|
|
2354
2117
|
scale: function scale(scaleX) {
|
|
2355
2118
|
var _this5 = this;
|
|
2356
|
-
|
|
2357
2119
|
var scaleY = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : scaleX;
|
|
2358
2120
|
var element = this.element,
|
|
2359
|
-
|
|
2360
|
-
|
|
2121
|
+
options = this.options,
|
|
2122
|
+
imageData = this.imageData;
|
|
2361
2123
|
scaleX = Number(scaleX);
|
|
2362
2124
|
scaleY = Number(scaleY);
|
|
2363
|
-
|
|
2364
2125
|
if (this.viewed && !this.played && options.scalable) {
|
|
2365
2126
|
var oldScaleX = imageData.scaleX;
|
|
2366
2127
|
var oldScaleY = imageData.scaleY;
|
|
2367
2128
|
var changed = false;
|
|
2368
|
-
|
|
2369
2129
|
if (isNumber(scaleX)) {
|
|
2370
2130
|
changed = true;
|
|
2371
2131
|
} else {
|
|
2372
2132
|
scaleX = oldScaleX;
|
|
2373
2133
|
}
|
|
2374
|
-
|
|
2375
2134
|
if (isNumber(scaleY)) {
|
|
2376
2135
|
changed = true;
|
|
2377
2136
|
} else {
|
|
2378
2137
|
scaleY = oldScaleY;
|
|
2379
2138
|
}
|
|
2380
|
-
|
|
2381
2139
|
if (changed) {
|
|
2382
2140
|
if (isFunction(options.scale)) {
|
|
2383
2141
|
addListener(element, EVENT_SCALE, options.scale, {
|
|
2384
2142
|
once: true
|
|
2385
2143
|
});
|
|
2386
2144
|
}
|
|
2387
|
-
|
|
2388
2145
|
if (dispatchEvent(element, EVENT_SCALE, {
|
|
2389
2146
|
scaleX: scaleX,
|
|
2390
2147
|
scaleY: scaleY,
|
|
@@ -2393,19 +2150,16 @@ var methods = {
|
|
|
2393
2150
|
}) === false) {
|
|
2394
2151
|
return this;
|
|
2395
2152
|
}
|
|
2396
|
-
|
|
2397
2153
|
imageData.scaleX = scaleX;
|
|
2398
2154
|
imageData.scaleY = scaleY;
|
|
2399
2155
|
this.scaling = true;
|
|
2400
2156
|
this.renderImage(function () {
|
|
2401
2157
|
_this5.scaling = false;
|
|
2402
|
-
|
|
2403
2158
|
if (isFunction(options.scaled)) {
|
|
2404
2159
|
addListener(element, EVENT_SCALED, options.scaled, {
|
|
2405
2160
|
once: true
|
|
2406
2161
|
});
|
|
2407
2162
|
}
|
|
2408
|
-
|
|
2409
2163
|
dispatchEvent(element, EVENT_SCALED, {
|
|
2410
2164
|
scaleX: scaleX,
|
|
2411
2165
|
scaleY: scaleY,
|
|
@@ -2417,103 +2171,88 @@ var methods = {
|
|
|
2417
2171
|
});
|
|
2418
2172
|
}
|
|
2419
2173
|
}
|
|
2420
|
-
|
|
2421
2174
|
return this;
|
|
2422
2175
|
},
|
|
2423
|
-
|
|
2424
2176
|
/**
|
|
2425
2177
|
* Zoom the image with a relative ratio.
|
|
2426
2178
|
* @param {number} ratio - The target ratio.
|
|
2427
|
-
* @param {boolean} [
|
|
2179
|
+
* @param {boolean} [showTooltip=false] - Indicates whether to show the tooltip.
|
|
2180
|
+
* @param {Object} [pivot] - The pivot point coordinate for zooming.
|
|
2428
2181
|
* @param {Event} [_originalEvent=null] - The original event if any.
|
|
2429
2182
|
* @returns {Viewer} this
|
|
2430
2183
|
*/
|
|
2431
2184
|
zoom: function zoom(ratio) {
|
|
2432
|
-
var
|
|
2433
|
-
|
|
2434
|
-
var _originalEvent = arguments.length >
|
|
2435
|
-
|
|
2185
|
+
var showTooltip = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
2186
|
+
var pivot = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
2187
|
+
var _originalEvent = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
2436
2188
|
var imageData = this.imageData;
|
|
2437
2189
|
ratio = Number(ratio);
|
|
2438
|
-
|
|
2439
2190
|
if (ratio < 0) {
|
|
2440
2191
|
ratio = 1 / (1 - ratio);
|
|
2441
2192
|
} else {
|
|
2442
2193
|
ratio = 1 + ratio;
|
|
2443
2194
|
}
|
|
2444
|
-
|
|
2445
|
-
this.zoomTo(imageData.width * ratio / imageData.naturalWidth, hasTooltip, _originalEvent);
|
|
2195
|
+
this.zoomTo(imageData.width * ratio / imageData.naturalWidth, showTooltip, pivot, _originalEvent);
|
|
2446
2196
|
return this;
|
|
2447
2197
|
},
|
|
2448
|
-
|
|
2449
2198
|
/**
|
|
2450
2199
|
* Zoom the image to an absolute ratio.
|
|
2451
2200
|
* @param {number} ratio - The target ratio.
|
|
2452
|
-
* @param {boolean} [
|
|
2201
|
+
* @param {boolean} [showTooltip] - Indicates whether to show the tooltip.
|
|
2202
|
+
* @param {Object} [pivot] - The pivot point coordinate for zooming.
|
|
2453
2203
|
* @param {Event} [_originalEvent=null] - The original event if any.
|
|
2454
2204
|
* @param {Event} [_zoomable=false] - Indicates if the current zoom is available or not.
|
|
2455
2205
|
* @returns {Viewer} this
|
|
2456
2206
|
*/
|
|
2457
2207
|
zoomTo: function zoomTo(ratio) {
|
|
2458
2208
|
var _this6 = this;
|
|
2459
|
-
|
|
2460
|
-
var
|
|
2461
|
-
|
|
2462
|
-
var
|
|
2463
|
-
|
|
2464
|
-
var _zoomable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
2465
|
-
|
|
2209
|
+
var showTooltip = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
2210
|
+
var pivot = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
2211
|
+
var _originalEvent = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
2212
|
+
var _zoomable = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
2466
2213
|
var element = this.element,
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2214
|
+
options = this.options,
|
|
2215
|
+
pointers = this.pointers,
|
|
2216
|
+
imageData = this.imageData;
|
|
2470
2217
|
var x = imageData.x,
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2218
|
+
y = imageData.y,
|
|
2219
|
+
width = imageData.width,
|
|
2220
|
+
height = imageData.height,
|
|
2221
|
+
naturalWidth = imageData.naturalWidth,
|
|
2222
|
+
naturalHeight = imageData.naturalHeight;
|
|
2476
2223
|
ratio = Math.max(0, ratio);
|
|
2477
|
-
|
|
2478
2224
|
if (isNumber(ratio) && this.viewed && !this.played && (_zoomable || options.zoomable)) {
|
|
2479
2225
|
if (!_zoomable) {
|
|
2480
2226
|
var minZoomRatio = Math.max(0.01, options.minZoomRatio);
|
|
2481
2227
|
var maxZoomRatio = Math.min(100, options.maxZoomRatio);
|
|
2482
2228
|
ratio = Math.min(Math.max(ratio, minZoomRatio), maxZoomRatio);
|
|
2483
2229
|
}
|
|
2484
|
-
|
|
2485
2230
|
if (_originalEvent) {
|
|
2486
2231
|
switch (_originalEvent.type) {
|
|
2487
2232
|
case 'wheel':
|
|
2488
2233
|
if (options.zoomRatio >= 0.055 && ratio > 0.95 && ratio < 1.05) {
|
|
2489
2234
|
ratio = 1;
|
|
2490
2235
|
}
|
|
2491
|
-
|
|
2492
2236
|
break;
|
|
2493
|
-
|
|
2494
2237
|
case 'pointermove':
|
|
2495
2238
|
case 'touchmove':
|
|
2496
2239
|
case 'mousemove':
|
|
2497
2240
|
if (ratio > 0.99 && ratio < 1.01) {
|
|
2498
2241
|
ratio = 1;
|
|
2499
2242
|
}
|
|
2500
|
-
|
|
2501
2243
|
break;
|
|
2502
2244
|
}
|
|
2503
2245
|
}
|
|
2504
|
-
|
|
2505
2246
|
var newWidth = naturalWidth * ratio;
|
|
2506
2247
|
var newHeight = naturalHeight * ratio;
|
|
2507
2248
|
var offsetWidth = newWidth - width;
|
|
2508
2249
|
var offsetHeight = newHeight - height;
|
|
2509
2250
|
var oldRatio = imageData.ratio;
|
|
2510
|
-
|
|
2511
2251
|
if (isFunction(options.zoom)) {
|
|
2512
2252
|
addListener(element, EVENT_ZOOM, options.zoom, {
|
|
2513
2253
|
once: true
|
|
2514
2254
|
});
|
|
2515
2255
|
}
|
|
2516
|
-
|
|
2517
2256
|
if (dispatchEvent(element, EVENT_ZOOM, {
|
|
2518
2257
|
ratio: ratio,
|
|
2519
2258
|
oldRatio: oldRatio,
|
|
@@ -2521,24 +2260,25 @@ var methods = {
|
|
|
2521
2260
|
}) === false) {
|
|
2522
2261
|
return this;
|
|
2523
2262
|
}
|
|
2524
|
-
|
|
2525
2263
|
this.zooming = true;
|
|
2526
|
-
|
|
2527
2264
|
if (_originalEvent) {
|
|
2528
2265
|
var offset = getOffset(this.viewer);
|
|
2529
2266
|
var center = pointers && Object.keys(pointers).length > 0 ? getPointersCenter(pointers) : {
|
|
2530
2267
|
pageX: _originalEvent.pageX,
|
|
2531
2268
|
pageY: _originalEvent.pageY
|
|
2532
|
-
};
|
|
2269
|
+
};
|
|
2533
2270
|
|
|
2271
|
+
// Zoom from the triggering point of the event
|
|
2534
2272
|
imageData.x -= offsetWidth * ((center.pageX - offset.left - x) / width);
|
|
2535
2273
|
imageData.y -= offsetHeight * ((center.pageY - offset.top - y) / height);
|
|
2274
|
+
} else if (isPlainObject(pivot) && isNumber(pivot.x) && isNumber(pivot.y)) {
|
|
2275
|
+
imageData.x -= offsetWidth * ((pivot.x - x) / width);
|
|
2276
|
+
imageData.y -= offsetHeight * ((pivot.y - y) / height);
|
|
2536
2277
|
} else {
|
|
2537
2278
|
// Zoom from the center of the image
|
|
2538
2279
|
imageData.x -= offsetWidth / 2;
|
|
2539
2280
|
imageData.y -= offsetHeight / 2;
|
|
2540
2281
|
}
|
|
2541
|
-
|
|
2542
2282
|
imageData.left = imageData.x;
|
|
2543
2283
|
imageData.top = imageData.y;
|
|
2544
2284
|
imageData.width = newWidth;
|
|
@@ -2547,13 +2287,11 @@ var methods = {
|
|
|
2547
2287
|
imageData.ratio = ratio;
|
|
2548
2288
|
this.renderImage(function () {
|
|
2549
2289
|
_this6.zooming = false;
|
|
2550
|
-
|
|
2551
2290
|
if (isFunction(options.zoomed)) {
|
|
2552
2291
|
addListener(element, EVENT_ZOOMED, options.zoomed, {
|
|
2553
2292
|
once: true
|
|
2554
2293
|
});
|
|
2555
2294
|
}
|
|
2556
|
-
|
|
2557
2295
|
dispatchEvent(element, EVENT_ZOOMED, {
|
|
2558
2296
|
ratio: ratio,
|
|
2559
2297
|
oldRatio: oldRatio,
|
|
@@ -2562,15 +2300,12 @@ var methods = {
|
|
|
2562
2300
|
cancelable: false
|
|
2563
2301
|
});
|
|
2564
2302
|
});
|
|
2565
|
-
|
|
2566
|
-
if (hasTooltip) {
|
|
2303
|
+
if (showTooltip) {
|
|
2567
2304
|
this.tooltip();
|
|
2568
2305
|
}
|
|
2569
2306
|
}
|
|
2570
|
-
|
|
2571
2307
|
return this;
|
|
2572
2308
|
},
|
|
2573
|
-
|
|
2574
2309
|
/**
|
|
2575
2310
|
* Play the images
|
|
2576
2311
|
* @param {boolean|FullscreenOptions} [fullscreen=false] - Indicate if request fullscreen or not.
|
|
@@ -2578,26 +2313,20 @@ var methods = {
|
|
|
2578
2313
|
*/
|
|
2579
2314
|
play: function play() {
|
|
2580
2315
|
var _this7 = this;
|
|
2581
|
-
|
|
2582
2316
|
var fullscreen = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
2583
|
-
|
|
2584
2317
|
if (!this.isShown || this.played) {
|
|
2585
2318
|
return this;
|
|
2586
2319
|
}
|
|
2587
|
-
|
|
2588
2320
|
var element = this.element,
|
|
2589
|
-
|
|
2590
|
-
|
|
2321
|
+
options = this.options;
|
|
2591
2322
|
if (isFunction(options.play)) {
|
|
2592
2323
|
addListener(element, EVENT_PLAY, options.play, {
|
|
2593
2324
|
once: true
|
|
2594
2325
|
});
|
|
2595
2326
|
}
|
|
2596
|
-
|
|
2597
2327
|
if (dispatchEvent(element, EVENT_PLAY) === false) {
|
|
2598
2328
|
return this;
|
|
2599
2329
|
}
|
|
2600
|
-
|
|
2601
2330
|
var player = this.player;
|
|
2602
2331
|
var onLoad = this.loadImage.bind(this);
|
|
2603
2332
|
var list = [];
|
|
@@ -2605,11 +2334,9 @@ var methods = {
|
|
|
2605
2334
|
var index = 0;
|
|
2606
2335
|
this.played = true;
|
|
2607
2336
|
this.onLoadWhenPlay = onLoad;
|
|
2608
|
-
|
|
2609
2337
|
if (fullscreen) {
|
|
2610
2338
|
this.requestFullscreen(fullscreen);
|
|
2611
2339
|
}
|
|
2612
|
-
|
|
2613
2340
|
addClass(player, CLASS_SHOW);
|
|
2614
2341
|
forEach(this.items, function (item, i) {
|
|
2615
2342
|
var img = item.querySelector('img');
|
|
@@ -2620,61 +2347,63 @@ var methods = {
|
|
|
2620
2347
|
total += 1;
|
|
2621
2348
|
addClass(image, CLASS_FADE);
|
|
2622
2349
|
toggleClass(image, CLASS_TRANSITION, options.transition);
|
|
2623
|
-
|
|
2624
2350
|
if (hasClass(item, CLASS_ACTIVE)) {
|
|
2625
2351
|
addClass(image, CLASS_IN);
|
|
2626
2352
|
index = i;
|
|
2627
2353
|
}
|
|
2628
|
-
|
|
2629
2354
|
list.push(image);
|
|
2630
2355
|
addListener(image, EVENT_LOAD, onLoad, {
|
|
2631
2356
|
once: true
|
|
2632
2357
|
});
|
|
2633
2358
|
player.appendChild(image);
|
|
2634
2359
|
});
|
|
2635
|
-
|
|
2636
2360
|
if (isNumber(options.interval) && options.interval > 0) {
|
|
2637
|
-
var
|
|
2638
|
-
_this7.playing
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2361
|
+
var prev = function prev() {
|
|
2362
|
+
clearTimeout(_this7.playing.timeout);
|
|
2363
|
+
removeClass(list[index], CLASS_IN);
|
|
2364
|
+
index -= 1;
|
|
2365
|
+
index = index >= 0 ? index : total - 1;
|
|
2366
|
+
addClass(list[index], CLASS_IN);
|
|
2367
|
+
_this7.playing.timeout = setTimeout(prev, options.interval);
|
|
2368
|
+
};
|
|
2369
|
+
var next = function next() {
|
|
2370
|
+
clearTimeout(_this7.playing.timeout);
|
|
2371
|
+
removeClass(list[index], CLASS_IN);
|
|
2372
|
+
index += 1;
|
|
2373
|
+
index = index < total ? index : 0;
|
|
2374
|
+
addClass(list[index], CLASS_IN);
|
|
2375
|
+
_this7.playing.timeout = setTimeout(next, options.interval);
|
|
2645
2376
|
};
|
|
2646
|
-
|
|
2647
2377
|
if (total > 1) {
|
|
2648
|
-
|
|
2378
|
+
this.playing = {
|
|
2379
|
+
prev: prev,
|
|
2380
|
+
next: next,
|
|
2381
|
+
timeout: setTimeout(next, options.interval)
|
|
2382
|
+
};
|
|
2649
2383
|
}
|
|
2650
2384
|
}
|
|
2651
|
-
|
|
2652
2385
|
return this;
|
|
2653
2386
|
},
|
|
2654
2387
|
// Stop play
|
|
2655
2388
|
stop: function stop() {
|
|
2656
2389
|
var _this8 = this;
|
|
2657
|
-
|
|
2658
2390
|
if (!this.played) {
|
|
2659
2391
|
return this;
|
|
2660
2392
|
}
|
|
2661
|
-
|
|
2662
2393
|
var element = this.element,
|
|
2663
|
-
|
|
2664
|
-
|
|
2394
|
+
options = this.options;
|
|
2665
2395
|
if (isFunction(options.stop)) {
|
|
2666
2396
|
addListener(element, EVENT_STOP, options.stop, {
|
|
2667
2397
|
once: true
|
|
2668
2398
|
});
|
|
2669
2399
|
}
|
|
2670
|
-
|
|
2671
2400
|
if (dispatchEvent(element, EVENT_STOP) === false) {
|
|
2672
2401
|
return this;
|
|
2673
2402
|
}
|
|
2674
|
-
|
|
2675
2403
|
var player = this.player;
|
|
2404
|
+
clearTimeout(this.playing.timeout);
|
|
2405
|
+
this.playing = false;
|
|
2676
2406
|
this.played = false;
|
|
2677
|
-
clearTimeout(this.playing);
|
|
2678
2407
|
forEach(player.getElementsByTagName('img'), function (image) {
|
|
2679
2408
|
removeListener(image, EVENT_LOAD, _this8.onLoadWhenPlay);
|
|
2680
2409
|
});
|
|
@@ -2686,28 +2415,22 @@ var methods = {
|
|
|
2686
2415
|
// Enter modal mode (only available in inline mode)
|
|
2687
2416
|
full: function full() {
|
|
2688
2417
|
var _this9 = this;
|
|
2689
|
-
|
|
2690
2418
|
var options = this.options,
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2419
|
+
viewer = this.viewer,
|
|
2420
|
+
image = this.image,
|
|
2421
|
+
list = this.list;
|
|
2695
2422
|
if (!this.isShown || this.played || this.fulled || !options.inline) {
|
|
2696
2423
|
return this;
|
|
2697
2424
|
}
|
|
2698
|
-
|
|
2699
2425
|
this.fulled = true;
|
|
2700
2426
|
this.open();
|
|
2701
2427
|
addClass(this.button, CLASS_FULLSCREEN_EXIT);
|
|
2702
|
-
|
|
2703
2428
|
if (options.transition) {
|
|
2704
2429
|
removeClass(list, CLASS_TRANSITION);
|
|
2705
|
-
|
|
2706
2430
|
if (this.viewed) {
|
|
2707
2431
|
removeClass(image, CLASS_TRANSITION);
|
|
2708
2432
|
}
|
|
2709
2433
|
}
|
|
2710
|
-
|
|
2711
2434
|
addClass(viewer, CLASS_FIXED);
|
|
2712
2435
|
viewer.setAttribute('role', 'dialog');
|
|
2713
2436
|
viewer.setAttribute('aria-labelledby', this.title.id);
|
|
@@ -2716,15 +2439,12 @@ var methods = {
|
|
|
2716
2439
|
setStyle(viewer, {
|
|
2717
2440
|
zIndex: options.zIndex
|
|
2718
2441
|
});
|
|
2719
|
-
|
|
2720
2442
|
if (options.focus) {
|
|
2721
2443
|
this.enforceFocus();
|
|
2722
2444
|
}
|
|
2723
|
-
|
|
2724
2445
|
this.initContainer();
|
|
2725
2446
|
this.viewerData = assign({}, this.containerData);
|
|
2726
2447
|
this.renderList();
|
|
2727
|
-
|
|
2728
2448
|
if (this.viewed) {
|
|
2729
2449
|
this.initImage(function () {
|
|
2730
2450
|
_this9.renderImage(function () {
|
|
@@ -2737,38 +2457,30 @@ var methods = {
|
|
|
2737
2457
|
});
|
|
2738
2458
|
});
|
|
2739
2459
|
}
|
|
2740
|
-
|
|
2741
2460
|
return this;
|
|
2742
2461
|
},
|
|
2743
2462
|
// Exit modal mode (only available in inline mode)
|
|
2744
2463
|
exit: function exit() {
|
|
2745
2464
|
var _this10 = this;
|
|
2746
|
-
|
|
2747
2465
|
var options = this.options,
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2466
|
+
viewer = this.viewer,
|
|
2467
|
+
image = this.image,
|
|
2468
|
+
list = this.list;
|
|
2752
2469
|
if (!this.isShown || this.played || !this.fulled || !options.inline) {
|
|
2753
2470
|
return this;
|
|
2754
2471
|
}
|
|
2755
|
-
|
|
2756
2472
|
this.fulled = false;
|
|
2757
2473
|
this.close();
|
|
2758
2474
|
removeClass(this.button, CLASS_FULLSCREEN_EXIT);
|
|
2759
|
-
|
|
2760
2475
|
if (options.transition) {
|
|
2761
2476
|
removeClass(list, CLASS_TRANSITION);
|
|
2762
|
-
|
|
2763
2477
|
if (this.viewed) {
|
|
2764
2478
|
removeClass(image, CLASS_TRANSITION);
|
|
2765
2479
|
}
|
|
2766
2480
|
}
|
|
2767
|
-
|
|
2768
2481
|
if (options.focus) {
|
|
2769
2482
|
this.clearEnforceFocus();
|
|
2770
2483
|
}
|
|
2771
|
-
|
|
2772
2484
|
viewer.removeAttribute('role');
|
|
2773
2485
|
viewer.removeAttribute('aria-labelledby');
|
|
2774
2486
|
viewer.removeAttribute('aria-modal');
|
|
@@ -2779,7 +2491,6 @@ var methods = {
|
|
|
2779
2491
|
this.viewerData = assign({}, this.parentData);
|
|
2780
2492
|
this.renderViewer();
|
|
2781
2493
|
this.renderList();
|
|
2782
|
-
|
|
2783
2494
|
if (this.viewed) {
|
|
2784
2495
|
this.initImage(function () {
|
|
2785
2496
|
_this10.renderImage(function () {
|
|
@@ -2792,34 +2503,29 @@ var methods = {
|
|
|
2792
2503
|
});
|
|
2793
2504
|
});
|
|
2794
2505
|
}
|
|
2795
|
-
|
|
2796
2506
|
return this;
|
|
2797
2507
|
},
|
|
2798
2508
|
// Show the current ratio of the image with percentage
|
|
2799
2509
|
tooltip: function tooltip() {
|
|
2800
2510
|
var _this11 = this;
|
|
2801
|
-
|
|
2802
2511
|
var options = this.options,
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2512
|
+
tooltipBox = this.tooltipBox,
|
|
2513
|
+
imageData = this.imageData;
|
|
2806
2514
|
if (!this.viewed || this.played || !options.tooltip) {
|
|
2807
2515
|
return this;
|
|
2808
2516
|
}
|
|
2809
|
-
|
|
2810
2517
|
tooltipBox.textContent = "".concat(Math.round(imageData.ratio * 100), "%");
|
|
2811
|
-
|
|
2812
2518
|
if (!this.tooltipping) {
|
|
2813
2519
|
if (options.transition) {
|
|
2814
2520
|
if (this.fading) {
|
|
2815
2521
|
dispatchEvent(tooltipBox, EVENT_TRANSITION_END);
|
|
2816
2522
|
}
|
|
2817
|
-
|
|
2818
2523
|
addClass(tooltipBox, CLASS_SHOW);
|
|
2819
2524
|
addClass(tooltipBox, CLASS_FADE);
|
|
2820
2525
|
addClass(tooltipBox, CLASS_TRANSITION);
|
|
2821
|
-
tooltipBox.removeAttribute('aria-hidden');
|
|
2526
|
+
tooltipBox.removeAttribute('aria-hidden');
|
|
2822
2527
|
|
|
2528
|
+
// Force reflow to enable CSS3 transition
|
|
2823
2529
|
tooltipBox.initialOffsetWidth = tooltipBox.offsetWidth;
|
|
2824
2530
|
addClass(tooltipBox, CLASS_IN);
|
|
2825
2531
|
} else {
|
|
@@ -2829,7 +2535,6 @@ var methods = {
|
|
|
2829
2535
|
} else {
|
|
2830
2536
|
clearTimeout(this.tooltipping);
|
|
2831
2537
|
}
|
|
2832
|
-
|
|
2833
2538
|
this.tooltipping = setTimeout(function () {
|
|
2834
2539
|
if (options.transition) {
|
|
2835
2540
|
addListener(tooltipBox, EVENT_TRANSITION_END, function () {
|
|
@@ -2847,12 +2552,10 @@ var methods = {
|
|
|
2847
2552
|
removeClass(tooltipBox, CLASS_SHOW);
|
|
2848
2553
|
tooltipBox.setAttribute('aria-hidden', true);
|
|
2849
2554
|
}
|
|
2850
|
-
|
|
2851
2555
|
_this11.tooltipping = false;
|
|
2852
2556
|
}, 1000);
|
|
2853
2557
|
return this;
|
|
2854
2558
|
},
|
|
2855
|
-
|
|
2856
2559
|
/**
|
|
2857
2560
|
* Toggle the image size between its current size and natural size
|
|
2858
2561
|
* @param {Event} [_originalEvent=null] - The original event if any.
|
|
@@ -2860,13 +2563,11 @@ var methods = {
|
|
|
2860
2563
|
*/
|
|
2861
2564
|
toggle: function toggle() {
|
|
2862
2565
|
var _originalEvent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
2863
|
-
|
|
2864
2566
|
if (this.imageData.ratio === 1) {
|
|
2865
|
-
this.zoomTo(this.imageData.oldRatio, true, _originalEvent);
|
|
2567
|
+
this.zoomTo(this.imageData.oldRatio, true, null, _originalEvent);
|
|
2866
2568
|
} else {
|
|
2867
|
-
this.zoomTo(1, true, _originalEvent);
|
|
2569
|
+
this.zoomTo(1, true, null, _originalEvent);
|
|
2868
2570
|
}
|
|
2869
|
-
|
|
2870
2571
|
return this;
|
|
2871
2572
|
},
|
|
2872
2573
|
// Reset the image to its initial state
|
|
@@ -2875,21 +2576,19 @@ var methods = {
|
|
|
2875
2576
|
this.imageData = assign({}, this.initialImageData);
|
|
2876
2577
|
this.renderImage();
|
|
2877
2578
|
}
|
|
2878
|
-
|
|
2879
2579
|
return this;
|
|
2880
2580
|
},
|
|
2881
2581
|
// Update viewer when images changed
|
|
2882
2582
|
update: function update() {
|
|
2883
2583
|
var _this12 = this;
|
|
2884
|
-
|
|
2885
2584
|
var element = this.element,
|
|
2886
|
-
|
|
2887
|
-
|
|
2585
|
+
options = this.options,
|
|
2586
|
+
isImg = this.isImg;
|
|
2888
2587
|
|
|
2588
|
+
// Destroy viewer if the target image was deleted
|
|
2889
2589
|
if (isImg && !element.parentNode) {
|
|
2890
2590
|
return this.destroy();
|
|
2891
2591
|
}
|
|
2892
|
-
|
|
2893
2592
|
var images = [];
|
|
2894
2593
|
forEach(isImg ? [element] : element.querySelectorAll('img'), function (image) {
|
|
2895
2594
|
if (isFunction(options.filter)) {
|
|
@@ -2900,22 +2599,20 @@ var methods = {
|
|
|
2900
2599
|
images.push(image);
|
|
2901
2600
|
}
|
|
2902
2601
|
});
|
|
2903
|
-
|
|
2904
2602
|
if (!images.length) {
|
|
2905
2603
|
return this;
|
|
2906
2604
|
}
|
|
2907
|
-
|
|
2908
2605
|
this.images = images;
|
|
2909
2606
|
this.length = images.length;
|
|
2910
|
-
|
|
2911
2607
|
if (this.ready) {
|
|
2912
2608
|
var changedIndexes = [];
|
|
2913
2609
|
forEach(this.items, function (item, i) {
|
|
2914
2610
|
var img = item.querySelector('img');
|
|
2915
2611
|
var image = images[i];
|
|
2916
|
-
|
|
2917
2612
|
if (image && img) {
|
|
2918
|
-
if (image.src !== img.src
|
|
2613
|
+
if (image.src !== img.src
|
|
2614
|
+
|
|
2615
|
+
// Title changed (#408)
|
|
2919
2616
|
|| image.alt !== img.alt) {
|
|
2920
2617
|
changedIndexes.push(i);
|
|
2921
2618
|
}
|
|
@@ -2927,18 +2624,17 @@ var methods = {
|
|
|
2927
2624
|
width: 'auto'
|
|
2928
2625
|
});
|
|
2929
2626
|
this.initList();
|
|
2930
|
-
|
|
2931
2627
|
if (this.isShown) {
|
|
2932
2628
|
if (this.length) {
|
|
2933
2629
|
if (this.viewed) {
|
|
2934
2630
|
var changedIndex = changedIndexes.indexOf(this.index);
|
|
2935
|
-
|
|
2936
2631
|
if (changedIndex >= 0) {
|
|
2937
2632
|
this.viewed = false;
|
|
2938
2633
|
this.view(Math.max(Math.min(this.index - changedIndex, this.length - 1), 0));
|
|
2939
2634
|
} else {
|
|
2940
|
-
var activeItem = this.items[this.index];
|
|
2635
|
+
var activeItem = this.items[this.index];
|
|
2941
2636
|
|
|
2637
|
+
// Reactivate the current viewing item after reset the list.
|
|
2942
2638
|
addClass(activeItem, CLASS_ACTIVE);
|
|
2943
2639
|
activeItem.setAttribute('aria-selected', true);
|
|
2944
2640
|
}
|
|
@@ -2955,30 +2651,24 @@ var methods = {
|
|
|
2955
2651
|
} else {
|
|
2956
2652
|
this.build();
|
|
2957
2653
|
}
|
|
2958
|
-
|
|
2959
2654
|
return this;
|
|
2960
2655
|
},
|
|
2961
2656
|
// Destroy the viewer
|
|
2962
2657
|
destroy: function destroy() {
|
|
2963
2658
|
var element = this.element,
|
|
2964
|
-
|
|
2965
|
-
|
|
2659
|
+
options = this.options;
|
|
2966
2660
|
if (!element[NAMESPACE]) {
|
|
2967
2661
|
return this;
|
|
2968
2662
|
}
|
|
2969
|
-
|
|
2970
2663
|
this.destroyed = true;
|
|
2971
|
-
|
|
2972
2664
|
if (this.ready) {
|
|
2973
2665
|
if (this.played) {
|
|
2974
2666
|
this.stop();
|
|
2975
2667
|
}
|
|
2976
|
-
|
|
2977
2668
|
if (options.inline) {
|
|
2978
2669
|
if (this.fulled) {
|
|
2979
2670
|
this.exit();
|
|
2980
2671
|
}
|
|
2981
|
-
|
|
2982
2672
|
this.unbind();
|
|
2983
2673
|
} else if (this.isShown) {
|
|
2984
2674
|
if (this.viewing) {
|
|
@@ -2988,17 +2678,14 @@ var methods = {
|
|
|
2988
2678
|
this.imageInitializing.abort();
|
|
2989
2679
|
}
|
|
2990
2680
|
}
|
|
2991
|
-
|
|
2992
2681
|
if (this.hiding) {
|
|
2993
2682
|
this.transitioning.abort();
|
|
2994
2683
|
}
|
|
2995
|
-
|
|
2996
2684
|
this.hidden();
|
|
2997
2685
|
} else if (this.showing) {
|
|
2998
2686
|
this.transitioning.abort();
|
|
2999
2687
|
this.hidden();
|
|
3000
2688
|
}
|
|
3001
|
-
|
|
3002
2689
|
this.ready = false;
|
|
3003
2690
|
this.viewer.parentNode.removeChild(this.viewer);
|
|
3004
2691
|
} else if (options.inline) {
|
|
@@ -3008,11 +2695,9 @@ var methods = {
|
|
|
3008
2695
|
this.initializing.abort();
|
|
3009
2696
|
}
|
|
3010
2697
|
}
|
|
3011
|
-
|
|
3012
2698
|
if (!options.inline) {
|
|
3013
2699
|
removeListener(element, EVENT_CLICK, this.onStart);
|
|
3014
2700
|
}
|
|
3015
|
-
|
|
3016
2701
|
element[NAMESPACE] = undefined;
|
|
3017
2702
|
return this;
|
|
3018
2703
|
}
|
|
@@ -3021,7 +2706,6 @@ var methods = {
|
|
|
3021
2706
|
var others = {
|
|
3022
2707
|
getImageURL: function getImageURL(image) {
|
|
3023
2708
|
var url = this.options.url;
|
|
3024
|
-
|
|
3025
2709
|
if (isString(url)) {
|
|
3026
2710
|
url = image.getAttribute(url);
|
|
3027
2711
|
} else if (isFunction(url)) {
|
|
@@ -3029,30 +2713,24 @@ var others = {
|
|
|
3029
2713
|
} else {
|
|
3030
2714
|
url = '';
|
|
3031
2715
|
}
|
|
3032
|
-
|
|
3033
2716
|
return url;
|
|
3034
2717
|
},
|
|
3035
2718
|
enforceFocus: function enforceFocus() {
|
|
3036
2719
|
var _this = this;
|
|
3037
|
-
|
|
3038
2720
|
this.clearEnforceFocus();
|
|
3039
2721
|
addListener(document, EVENT_FOCUSIN, this.onFocusin = function (event) {
|
|
3040
2722
|
var viewer = _this.viewer;
|
|
3041
2723
|
var target = event.target;
|
|
3042
|
-
|
|
3043
2724
|
if (target === document || target === viewer || viewer.contains(target)) {
|
|
3044
2725
|
return;
|
|
3045
2726
|
}
|
|
3046
|
-
|
|
3047
2727
|
while (target) {
|
|
3048
2728
|
// Avoid conflicts with other modals (#474, #540)
|
|
3049
2729
|
if (target.getAttribute('tabindex') !== null || target.getAttribute('aria-modal') === 'true') {
|
|
3050
2730
|
return;
|
|
3051
2731
|
}
|
|
3052
|
-
|
|
3053
2732
|
target = target.parentElement;
|
|
3054
2733
|
}
|
|
3055
|
-
|
|
3056
2734
|
viewer.focus();
|
|
3057
2735
|
});
|
|
3058
2736
|
},
|
|
@@ -3065,51 +2743,49 @@ var others = {
|
|
|
3065
2743
|
open: function open() {
|
|
3066
2744
|
var body = this.body;
|
|
3067
2745
|
addClass(body, CLASS_OPEN);
|
|
3068
|
-
|
|
2746
|
+
if (this.scrollbarWidth > 0) {
|
|
2747
|
+
body.style.paddingRight = "".concat(this.scrollbarWidth + (parseFloat(this.initialBodyComputedPaddingRight) || 0), "px");
|
|
2748
|
+
}
|
|
3069
2749
|
},
|
|
3070
2750
|
close: function close() {
|
|
3071
2751
|
var body = this.body;
|
|
3072
2752
|
removeClass(body, CLASS_OPEN);
|
|
3073
|
-
|
|
2753
|
+
if (this.scrollbarWidth > 0) {
|
|
2754
|
+
body.style.paddingRight = this.initialBodyPaddingRight;
|
|
2755
|
+
}
|
|
3074
2756
|
},
|
|
3075
2757
|
shown: function shown() {
|
|
3076
2758
|
var element = this.element,
|
|
3077
|
-
|
|
3078
|
-
|
|
2759
|
+
options = this.options,
|
|
2760
|
+
viewer = this.viewer;
|
|
3079
2761
|
this.fulled = true;
|
|
3080
2762
|
this.isShown = true;
|
|
3081
2763
|
this.render();
|
|
3082
2764
|
this.bind();
|
|
3083
2765
|
this.showing = false;
|
|
3084
|
-
|
|
3085
2766
|
if (options.focus) {
|
|
3086
2767
|
viewer.focus();
|
|
3087
2768
|
this.enforceFocus();
|
|
3088
2769
|
}
|
|
3089
|
-
|
|
3090
2770
|
if (isFunction(options.shown)) {
|
|
3091
2771
|
addListener(element, EVENT_SHOWN, options.shown, {
|
|
3092
2772
|
once: true
|
|
3093
2773
|
});
|
|
3094
2774
|
}
|
|
3095
|
-
|
|
3096
2775
|
if (dispatchEvent(element, EVENT_SHOWN) === false) {
|
|
3097
2776
|
return;
|
|
3098
2777
|
}
|
|
3099
|
-
|
|
3100
2778
|
if (this.ready && this.isShown && !this.hiding) {
|
|
3101
2779
|
this.view(this.index);
|
|
3102
2780
|
}
|
|
3103
2781
|
},
|
|
3104
2782
|
hidden: function hidden() {
|
|
3105
2783
|
var element = this.element,
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
2784
|
+
options = this.options,
|
|
2785
|
+
viewer = this.viewer;
|
|
3109
2786
|
if (options.fucus) {
|
|
3110
2787
|
this.clearEnforceFocus();
|
|
3111
2788
|
}
|
|
3112
|
-
|
|
3113
2789
|
this.fulled = false;
|
|
3114
2790
|
this.viewed = false;
|
|
3115
2791
|
this.isShown = false;
|
|
@@ -3123,14 +2799,12 @@ var others = {
|
|
|
3123
2799
|
this.resetList();
|
|
3124
2800
|
this.resetImage();
|
|
3125
2801
|
this.hiding = false;
|
|
3126
|
-
|
|
3127
2802
|
if (!this.destroyed) {
|
|
3128
2803
|
if (isFunction(options.hidden)) {
|
|
3129
2804
|
addListener(element, EVENT_HIDDEN, options.hidden, {
|
|
3130
2805
|
once: true
|
|
3131
2806
|
});
|
|
3132
2807
|
}
|
|
3133
|
-
|
|
3134
2808
|
dispatchEvent(element, EVENT_HIDDEN, null, {
|
|
3135
2809
|
cancelable: false
|
|
3136
2810
|
});
|
|
@@ -3138,10 +2812,10 @@ var others = {
|
|
|
3138
2812
|
},
|
|
3139
2813
|
requestFullscreen: function requestFullscreen(options) {
|
|
3140
2814
|
var document = this.element.ownerDocument;
|
|
3141
|
-
|
|
3142
2815
|
if (this.fulled && !(document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement)) {
|
|
3143
|
-
var documentElement = document.documentElement;
|
|
2816
|
+
var documentElement = document.documentElement;
|
|
3144
2817
|
|
|
2818
|
+
// Element.requestFullscreen()
|
|
3145
2819
|
if (documentElement.requestFullscreen) {
|
|
3146
2820
|
// Avoid TypeError when convert `options` to dictionary
|
|
3147
2821
|
if (isPlainObject(options)) {
|
|
@@ -3160,7 +2834,6 @@ var others = {
|
|
|
3160
2834
|
},
|
|
3161
2835
|
exitFullscreen: function exitFullscreen() {
|
|
3162
2836
|
var document = this.element.ownerDocument;
|
|
3163
|
-
|
|
3164
2837
|
if (this.fulled && (document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement)) {
|
|
3165
2838
|
// Document.exitFullscreen()
|
|
3166
2839
|
if (document.exitFullscreen) {
|
|
@@ -3176,48 +2849,43 @@ var others = {
|
|
|
3176
2849
|
},
|
|
3177
2850
|
change: function change(event) {
|
|
3178
2851
|
var options = this.options,
|
|
3179
|
-
|
|
3180
|
-
var pointer = pointers[Object.keys(pointers)[0]];
|
|
2852
|
+
pointers = this.pointers;
|
|
2853
|
+
var pointer = pointers[Object.keys(pointers)[0]];
|
|
3181
2854
|
|
|
2855
|
+
// In the case of the `pointers` object is empty (#421)
|
|
3182
2856
|
if (!pointer) {
|
|
3183
2857
|
return;
|
|
3184
2858
|
}
|
|
3185
|
-
|
|
3186
2859
|
var offsetX = pointer.endX - pointer.startX;
|
|
3187
2860
|
var offsetY = pointer.endY - pointer.startY;
|
|
3188
|
-
|
|
3189
2861
|
switch (this.action) {
|
|
3190
2862
|
// Move the current image
|
|
3191
2863
|
case ACTION_MOVE:
|
|
3192
2864
|
this.move(offsetX, offsetY, event);
|
|
3193
2865
|
break;
|
|
3194
|
-
// Zoom the current image
|
|
3195
2866
|
|
|
2867
|
+
// Zoom the current image
|
|
3196
2868
|
case ACTION_ZOOM:
|
|
3197
|
-
this.zoom(getMaxZoomRatio(pointers), false, event);
|
|
2869
|
+
this.zoom(getMaxZoomRatio(pointers), false, null, event);
|
|
3198
2870
|
break;
|
|
3199
|
-
|
|
3200
2871
|
case ACTION_SWITCH:
|
|
3201
2872
|
{
|
|
3202
2873
|
this.action = 'switched';
|
|
3203
2874
|
var absoluteOffsetX = Math.abs(offsetX);
|
|
3204
|
-
|
|
3205
2875
|
if (absoluteOffsetX > 1 && absoluteOffsetX > Math.abs(offsetY)) {
|
|
3206
2876
|
// Empty `pointers` as `touchend` event will not be fired after swiped in iOS browsers.
|
|
3207
2877
|
this.pointers = {};
|
|
3208
|
-
|
|
3209
2878
|
if (offsetX > 1) {
|
|
3210
2879
|
this.prev(options.loop);
|
|
3211
2880
|
} else if (offsetX < -1) {
|
|
3212
2881
|
this.next(options.loop);
|
|
3213
2882
|
}
|
|
3214
2883
|
}
|
|
3215
|
-
|
|
3216
2884
|
break;
|
|
3217
2885
|
}
|
|
3218
|
-
}
|
|
3219
|
-
|
|
2886
|
+
}
|
|
3220
2887
|
|
|
2888
|
+
// Override
|
|
3221
2889
|
forEach(pointers, function (p) {
|
|
3222
2890
|
p.startX = p.endX;
|
|
3223
2891
|
p.startY = p.endY;
|
|
@@ -3225,20 +2893,18 @@ var others = {
|
|
|
3225
2893
|
},
|
|
3226
2894
|
isSwitchable: function isSwitchable() {
|
|
3227
2895
|
var imageData = this.imageData,
|
|
3228
|
-
|
|
2896
|
+
viewerData = this.viewerData;
|
|
3229
2897
|
return this.length > 1 && imageData.x >= 0 && imageData.y >= 0 && imageData.width <= viewerData.width && imageData.height <= viewerData.height;
|
|
3230
2898
|
}
|
|
3231
2899
|
};
|
|
3232
2900
|
|
|
3233
2901
|
var AnotherViewer = WINDOW.Viewer;
|
|
3234
|
-
|
|
3235
2902
|
var getUniqueID = function (id) {
|
|
3236
2903
|
return function () {
|
|
3237
2904
|
id += 1;
|
|
3238
2905
|
return id;
|
|
3239
2906
|
};
|
|
3240
2907
|
}(-1);
|
|
3241
|
-
|
|
3242
2908
|
var Viewer = /*#__PURE__*/function () {
|
|
3243
2909
|
/**
|
|
3244
2910
|
* Create a new Viewer.
|
|
@@ -3247,13 +2913,10 @@ var Viewer = /*#__PURE__*/function () {
|
|
|
3247
2913
|
*/
|
|
3248
2914
|
function Viewer(element) {
|
|
3249
2915
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
3250
|
-
|
|
3251
2916
|
_classCallCheck(this, Viewer);
|
|
3252
|
-
|
|
3253
2917
|
if (!element || element.nodeType !== 1) {
|
|
3254
2918
|
throw new Error('The first argument is required and must be an element.');
|
|
3255
2919
|
}
|
|
3256
|
-
|
|
3257
2920
|
this.element = element;
|
|
3258
2921
|
this.options = assign({}, DEFAULTS, isPlainObject(options) && options);
|
|
3259
2922
|
this.action = false;
|
|
@@ -3283,25 +2946,21 @@ var Viewer = /*#__PURE__*/function () {
|
|
|
3283
2946
|
this.id = getUniqueID();
|
|
3284
2947
|
this.init();
|
|
3285
2948
|
}
|
|
3286
|
-
|
|
3287
2949
|
_createClass(Viewer, [{
|
|
3288
2950
|
key: "init",
|
|
3289
2951
|
value: function init() {
|
|
3290
2952
|
var _this = this;
|
|
3291
|
-
|
|
3292
2953
|
var element = this.element,
|
|
3293
|
-
|
|
3294
|
-
|
|
2954
|
+
options = this.options;
|
|
3295
2955
|
if (element[NAMESPACE]) {
|
|
3296
2956
|
return;
|
|
3297
2957
|
}
|
|
2958
|
+
element[NAMESPACE] = this;
|
|
3298
2959
|
|
|
3299
|
-
|
|
3300
|
-
|
|
2960
|
+
// The `focus` option requires the `keyboard` option set to `true`.
|
|
3301
2961
|
if (options.focus && !options.keyboard) {
|
|
3302
2962
|
options.focus = false;
|
|
3303
2963
|
}
|
|
3304
|
-
|
|
3305
2964
|
var isImg = element.localName === 'img';
|
|
3306
2965
|
var images = [];
|
|
3307
2966
|
forEach(isImg ? [element] : element.querySelectorAll('img'), function (image) {
|
|
@@ -3316,18 +2975,16 @@ var Viewer = /*#__PURE__*/function () {
|
|
|
3316
2975
|
this.isImg = isImg;
|
|
3317
2976
|
this.length = images.length;
|
|
3318
2977
|
this.images = images;
|
|
3319
|
-
this.initBody();
|
|
2978
|
+
this.initBody();
|
|
3320
2979
|
|
|
2980
|
+
// Override `transition` option if it is not supported
|
|
3321
2981
|
if (isUndefined(document.createElement(NAMESPACE).style.transition)) {
|
|
3322
2982
|
options.transition = false;
|
|
3323
2983
|
}
|
|
3324
|
-
|
|
3325
2984
|
if (options.inline) {
|
|
3326
2985
|
var count = 0;
|
|
3327
|
-
|
|
3328
2986
|
var progress = function progress() {
|
|
3329
2987
|
count += 1;
|
|
3330
|
-
|
|
3331
2988
|
if (count === _this.length) {
|
|
3332
2989
|
var timeout;
|
|
3333
2990
|
_this.initializing = false;
|
|
@@ -3335,16 +2992,15 @@ var Viewer = /*#__PURE__*/function () {
|
|
|
3335
2992
|
abort: function abort() {
|
|
3336
2993
|
clearTimeout(timeout);
|
|
3337
2994
|
}
|
|
3338
|
-
};
|
|
2995
|
+
};
|
|
3339
2996
|
|
|
2997
|
+
// build asynchronously to keep `this.viewer` is accessible in `ready` event handler.
|
|
3340
2998
|
timeout = setTimeout(function () {
|
|
3341
2999
|
_this.delaying = false;
|
|
3342
|
-
|
|
3343
3000
|
_this.build();
|
|
3344
3001
|
}, 0);
|
|
3345
3002
|
}
|
|
3346
3003
|
};
|
|
3347
|
-
|
|
3348
3004
|
this.initializing = {
|
|
3349
3005
|
abort: function abort() {
|
|
3350
3006
|
forEach(images, function (image) {
|
|
@@ -3378,7 +3034,6 @@ var Viewer = /*#__PURE__*/function () {
|
|
|
3378
3034
|
} else {
|
|
3379
3035
|
addListener(element, EVENT_CLICK, this.onStart = function (_ref) {
|
|
3380
3036
|
var target = _ref.target;
|
|
3381
|
-
|
|
3382
3037
|
if (target.localName === 'img' && (!isFunction(options.filter) || options.filter.call(_this, target))) {
|
|
3383
3038
|
_this.view(_this.images.indexOf(target));
|
|
3384
3039
|
}
|
|
@@ -3391,9 +3046,8 @@ var Viewer = /*#__PURE__*/function () {
|
|
|
3391
3046
|
if (this.ready) {
|
|
3392
3047
|
return;
|
|
3393
3048
|
}
|
|
3394
|
-
|
|
3395
3049
|
var element = this.element,
|
|
3396
|
-
|
|
3050
|
+
options = this.options;
|
|
3397
3051
|
var parent = element.parentNode;
|
|
3398
3052
|
var template = document.createElement('div');
|
|
3399
3053
|
template.innerHTML = TEMPLATE;
|
|
@@ -3419,82 +3073,65 @@ var Viewer = /*#__PURE__*/function () {
|
|
|
3419
3073
|
addClass(title, !options.title ? CLASS_HIDE : getResponsiveClass(Array.isArray(options.title) ? options.title[0] : options.title));
|
|
3420
3074
|
addClass(navbar, !options.navbar ? CLASS_HIDE : getResponsiveClass(options.navbar));
|
|
3421
3075
|
toggleClass(button, CLASS_HIDE, !options.button);
|
|
3422
|
-
|
|
3423
3076
|
if (options.keyboard) {
|
|
3424
3077
|
button.setAttribute('tabindex', 0);
|
|
3425
3078
|
}
|
|
3426
|
-
|
|
3427
3079
|
if (options.backdrop) {
|
|
3428
3080
|
addClass(viewer, "".concat(NAMESPACE, "-backdrop"));
|
|
3429
|
-
|
|
3430
3081
|
if (!options.inline && options.backdrop !== 'static') {
|
|
3431
3082
|
setData(canvas, DATA_ACTION, 'hide');
|
|
3432
3083
|
}
|
|
3433
3084
|
}
|
|
3434
|
-
|
|
3435
3085
|
if (isString(options.className) && options.className) {
|
|
3436
3086
|
// In case there are multiple class names
|
|
3437
3087
|
options.className.split(REGEXP_SPACES).forEach(function (className) {
|
|
3438
3088
|
addClass(viewer, className);
|
|
3439
3089
|
});
|
|
3440
3090
|
}
|
|
3441
|
-
|
|
3442
3091
|
if (options.toolbar) {
|
|
3443
3092
|
var list = document.createElement('ul');
|
|
3444
3093
|
var custom = isPlainObject(options.toolbar);
|
|
3445
3094
|
var zoomButtons = BUTTONS.slice(0, 3);
|
|
3446
3095
|
var rotateButtons = BUTTONS.slice(7, 9);
|
|
3447
3096
|
var scaleButtons = BUTTONS.slice(9);
|
|
3448
|
-
|
|
3449
3097
|
if (!custom) {
|
|
3450
3098
|
addClass(toolbar, getResponsiveClass(options.toolbar));
|
|
3451
3099
|
}
|
|
3452
|
-
|
|
3453
3100
|
forEach(custom ? options.toolbar : BUTTONS, function (value, index) {
|
|
3454
3101
|
var deep = custom && isPlainObject(value);
|
|
3455
3102
|
var name = custom ? hyphenate(index) : value;
|
|
3456
3103
|
var show = deep && !isUndefined(value.show) ? value.show : value;
|
|
3457
|
-
|
|
3458
3104
|
if (!show || !options.zoomable && zoomButtons.indexOf(name) !== -1 || !options.rotatable && rotateButtons.indexOf(name) !== -1 || !options.scalable && scaleButtons.indexOf(name) !== -1) {
|
|
3459
3105
|
return;
|
|
3460
3106
|
}
|
|
3461
|
-
|
|
3462
3107
|
var size = deep && !isUndefined(value.size) ? value.size : value;
|
|
3463
3108
|
var click = deep && !isUndefined(value.click) ? value.click : value;
|
|
3464
3109
|
var item = document.createElement('li');
|
|
3465
|
-
|
|
3466
3110
|
if (options.keyboard) {
|
|
3467
3111
|
item.setAttribute('tabindex', 0);
|
|
3468
3112
|
}
|
|
3469
|
-
|
|
3470
3113
|
item.setAttribute('role', 'button');
|
|
3471
3114
|
addClass(item, "".concat(NAMESPACE, "-").concat(name));
|
|
3472
|
-
|
|
3473
3115
|
if (!isFunction(click)) {
|
|
3474
3116
|
setData(item, DATA_ACTION, name);
|
|
3475
3117
|
}
|
|
3476
|
-
|
|
3477
3118
|
if (isNumber(show)) {
|
|
3478
3119
|
addClass(item, getResponsiveClass(show));
|
|
3479
3120
|
}
|
|
3480
|
-
|
|
3481
3121
|
if (['small', 'large'].indexOf(size) !== -1) {
|
|
3482
3122
|
addClass(item, "".concat(NAMESPACE, "-").concat(size));
|
|
3483
3123
|
} else if (name === 'play') {
|
|
3484
3124
|
addClass(item, "".concat(NAMESPACE, "-large"));
|
|
3485
3125
|
}
|
|
3486
|
-
|
|
3487
3126
|
if (isFunction(click)) {
|
|
3488
3127
|
addListener(item, EVENT_CLICK, click);
|
|
3489
3128
|
}
|
|
3490
|
-
|
|
3491
3129
|
list.appendChild(item);
|
|
3492
3130
|
});
|
|
3493
3131
|
toolbar.appendChild(list);
|
|
3494
3132
|
} else {
|
|
3495
3133
|
addClass(toolbar, CLASS_HIDE);
|
|
3496
3134
|
}
|
|
3497
|
-
|
|
3498
3135
|
if (!options.rotatable) {
|
|
3499
3136
|
var rotates = toolbar.querySelectorAll('li[class*="rotate"]');
|
|
3500
3137
|
addClass(rotates, CLASS_INVISIBLE);
|
|
@@ -3502,19 +3139,16 @@ var Viewer = /*#__PURE__*/function () {
|
|
|
3502
3139
|
toolbar.appendChild(rotate);
|
|
3503
3140
|
});
|
|
3504
3141
|
}
|
|
3505
|
-
|
|
3506
3142
|
if (options.inline) {
|
|
3507
3143
|
addClass(button, CLASS_FULLSCREEN);
|
|
3508
3144
|
setStyle(viewer, {
|
|
3509
3145
|
zIndex: options.zIndexInline
|
|
3510
3146
|
});
|
|
3511
|
-
|
|
3512
3147
|
if (window.getComputedStyle(parent).position === 'static') {
|
|
3513
3148
|
setStyle(parent, {
|
|
3514
3149
|
position: 'relative'
|
|
3515
3150
|
});
|
|
3516
3151
|
}
|
|
3517
|
-
|
|
3518
3152
|
parent.insertBefore(viewer, element.nextSibling);
|
|
3519
3153
|
} else {
|
|
3520
3154
|
addClass(button, CLASS_CLOSE);
|
|
@@ -3525,67 +3159,57 @@ var Viewer = /*#__PURE__*/function () {
|
|
|
3525
3159
|
zIndex: options.zIndex
|
|
3526
3160
|
});
|
|
3527
3161
|
var container = options.container;
|
|
3528
|
-
|
|
3529
3162
|
if (isString(container)) {
|
|
3530
3163
|
container = element.ownerDocument.querySelector(container);
|
|
3531
3164
|
}
|
|
3532
|
-
|
|
3533
3165
|
if (!container) {
|
|
3534
3166
|
container = this.body;
|
|
3535
3167
|
}
|
|
3536
|
-
|
|
3537
3168
|
container.appendChild(viewer);
|
|
3538
3169
|
}
|
|
3539
|
-
|
|
3540
3170
|
if (options.inline) {
|
|
3541
3171
|
this.render();
|
|
3542
3172
|
this.bind();
|
|
3543
3173
|
this.isShown = true;
|
|
3544
3174
|
}
|
|
3545
|
-
|
|
3546
3175
|
this.ready = true;
|
|
3547
|
-
|
|
3548
3176
|
if (isFunction(options.ready)) {
|
|
3549
3177
|
addListener(element, EVENT_READY, options.ready, {
|
|
3550
3178
|
once: true
|
|
3551
3179
|
});
|
|
3552
3180
|
}
|
|
3553
|
-
|
|
3554
3181
|
if (dispatchEvent(element, EVENT_READY) === false) {
|
|
3555
3182
|
this.ready = false;
|
|
3556
3183
|
return;
|
|
3557
3184
|
}
|
|
3558
|
-
|
|
3559
3185
|
if (this.ready && options.inline) {
|
|
3560
3186
|
this.view(this.index);
|
|
3561
3187
|
}
|
|
3562
3188
|
}
|
|
3189
|
+
|
|
3563
3190
|
/**
|
|
3564
3191
|
* Get the no conflict viewer class.
|
|
3565
3192
|
* @returns {Viewer} The viewer class.
|
|
3566
3193
|
*/
|
|
3567
|
-
|
|
3568
3194
|
}], [{
|
|
3569
3195
|
key: "noConflict",
|
|
3570
3196
|
value: function noConflict() {
|
|
3571
3197
|
window.Viewer = AnotherViewer;
|
|
3572
3198
|
return Viewer;
|
|
3573
3199
|
}
|
|
3200
|
+
|
|
3574
3201
|
/**
|
|
3575
3202
|
* Change the default options.
|
|
3576
3203
|
* @param {Object} options - The new default options.
|
|
3577
3204
|
*/
|
|
3578
|
-
|
|
3579
3205
|
}, {
|
|
3580
3206
|
key: "setDefaults",
|
|
3581
3207
|
value: function setDefaults(options) {
|
|
3582
3208
|
assign(DEFAULTS, isPlainObject(options) && options);
|
|
3583
3209
|
}
|
|
3584
3210
|
}]);
|
|
3585
|
-
|
|
3586
3211
|
return Viewer;
|
|
3587
3212
|
}();
|
|
3588
|
-
|
|
3589
3213
|
assign(Viewer.prototype, render, events, handlers, methods, others);
|
|
3590
3214
|
|
|
3591
3215
|
module.exports = Viewer;
|