viewerjs 1.10.2 → 1.10.3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viewerjs",
3
3
  "description": "JavaScript image viewer.",
4
- "version": "1.10.2",
4
+ "version": "1.10.3",
5
5
  "main": "dist/viewer.common.js",
6
6
  "module": "dist/viewer.esm.js",
7
7
  "browser": "dist/viewer.js",
@@ -22,8 +22,8 @@
22
22
  "compress:js": "uglifyjs dist/viewer.js -o dist/viewer.min.js -c -m --comments /^!/",
23
23
  "copy": "cpy dist/viewer.css docs/css",
24
24
  "lint": "npm run lint:js && npm run lint:css",
25
- "lint:css": "stylelint {src,docs}/**/*.{css,scss,html} --fix",
26
- "lint:js": "eslint src test *.js --fix",
25
+ "lint:css": "stylelint **/*.{css,scss} --fix",
26
+ "lint:js": "eslint . --fix",
27
27
  "prepare": "husky install",
28
28
  "release": "npm run clean && npm run lint && npm run build && npm run compress && npm run copy && npm test",
29
29
  "start": "npm-run-all --parallel watch:*",
@@ -57,58 +57,44 @@
57
57
  },
58
58
  "homepage": "https://fengyuanchen.github.io/viewerjs",
59
59
  "devDependencies": {
60
- "@babel/core": "^7.15.8",
61
- "@babel/preset-env": "^7.15.8",
62
- "@commitlint/cli": "^13.2.1",
63
- "@commitlint/config-conventional": "^13.2.0",
60
+ "@babel/core": "^7.16.12",
61
+ "@babel/preset-env": "^7.16.11",
62
+ "@commitlint/cli": "^16.1.0",
63
+ "@commitlint/config-conventional": "^16.0.0",
64
64
  "@rollup/plugin-babel": "^5.3.0",
65
65
  "babel-plugin-istanbul": "^6.1.1",
66
- "chai": "^4.3.4",
66
+ "chai": "^4.3.6",
67
67
  "change-case": "^4.1.2",
68
68
  "codecov": "^3.8.3",
69
69
  "cpy-cli": "^3.1.1",
70
70
  "create-banner": "^2.0.0",
71
- "cssnano": "^5.0.8",
71
+ "cssnano": "^5.0.16",
72
72
  "del-cli": "^4.0.1",
73
- "eslint": "^7.32.0",
74
- "eslint-config-airbnb-base": "^14.2.1",
75
- "eslint-plugin-import": "^2.25.2",
73
+ "eslint": "^8.8.0",
74
+ "eslint-config-airbnb-base": "^15.0.0",
75
+ "eslint-plugin-import": "^2.25.4",
76
76
  "husky": "^7.0.4",
77
- "karma": "^6.3.5",
77
+ "karma": "^6.3.13",
78
78
  "karma-chai": "^0.1.0",
79
79
  "karma-chrome-launcher": "^3.1.0",
80
80
  "karma-coverage-istanbul-reporter": "^3.0.3",
81
81
  "karma-mocha": "^2.0.1",
82
82
  "karma-mocha-reporter": "^2.2.5",
83
83
  "karma-rollup-preprocessor": "^7.0.7",
84
- "lint-staged": "^11.2.3",
85
- "mocha": "^9.1.3",
84
+ "lint-staged": "^12.3.3",
85
+ "mocha": "^9.2.0",
86
86
  "npm-run-all": "^4.1.5",
87
- "postcss": "^8.3.11",
88
- "postcss-cli": "^8.3.1",
87
+ "postcss": "^8.4.6",
88
+ "postcss-cli": "^9.1.0",
89
89
  "postcss-header": "^3.0.1",
90
90
  "postcss-import": "^14.0.2",
91
- "postcss-preset-env": "^6.7.0",
91
+ "postcss-preset-env": "^7.3.0",
92
92
  "postcss-url": "^10.1.3",
93
- "puppeteer": "^10.4.0",
94
- "rollup": "^2.58.0",
95
- "stylelint": "^13.13.1",
96
- "stylelint-config-standard": "^22.0.0",
97
- "stylelint-order": "^4.1.0",
98
- "uglify-js": "^3.14.2"
99
- },
100
- "browserslist": [
101
- "last 2 versions",
102
- "> 1%",
103
- "not ie <= 8"
104
- ],
105
- "commitlint": {
106
- "extends": [
107
- "@commitlint/config-conventional"
108
- ]
109
- },
110
- "lint-staged": {
111
- "{src,test}/**/*.js|*.conf*.js": "eslint --fix",
112
- "{src,docs}/**/*.{css,scss,html}": "stylelint --fix"
93
+ "puppeteer": "^13.1.3",
94
+ "rollup": "^2.66.1",
95
+ "stylelint": "^14.3.0",
96
+ "stylelint-config-standard-scss": "^3.0.0",
97
+ "stylelint-order": "^5.0.0",
98
+ "uglify-js": "^3.15.0"
113
99
  }
114
100
  }
package/src/index.css CHANGED
@@ -1 +1 @@
1
- @import './css/viewer.css';
1
+ @import "./css/viewer.css";
package/src/index.scss CHANGED
@@ -1 +1 @@
1
- @import './css/viewer.scss';
1
+ @import "./css/viewer";
@@ -130,7 +130,8 @@ export default {
130
130
  clearTimeout(this.doubleClickImageTimeout);
131
131
  }
132
132
 
133
- this.toggle(event);
133
+ // XXX: No pageX/Y properties in custom event, fallback to the original event.
134
+ this.toggle(event.isTrusted ? event : (event.detail && event.detail.originalEvent));
134
135
  }
135
136
  },
136
137
 
@@ -436,7 +437,9 @@ export default {
436
437
 
437
438
  // This timeout will be cleared later when a native dblclick event is triggering
438
439
  this.doubleClickImageTimeout = setTimeout(() => {
439
- dispatchEvent(this.image, EVENT_DBLCLICK);
440
+ dispatchEvent(this.image, EVENT_DBLCLICK, {
441
+ originalEvent: event,
442
+ });
440
443
  }, 50);
441
444
  } else {
442
445
  this.imageClicked = true;
@@ -452,7 +455,9 @@ export default {
452
455
  if (options.backdrop && options.backdrop !== 'static' && event.target === this.canvas) {
453
456
  // This timeout will be cleared later when a native click event is triggering
454
457
  this.clickCanvasTimeout = setTimeout(() => {
455
- dispatchEvent(this.canvas, EVENT_CLICK);
458
+ dispatchEvent(this.canvas, EVENT_CLICK, {
459
+ originalEvent: event,
460
+ });
456
461
  }, 50);
457
462
  }
458
463
  }
package/src/js/methods.js CHANGED
@@ -717,8 +717,24 @@ export default {
717
717
  ratio = Math.min(Math.max(ratio, minZoomRatio), maxZoomRatio);
718
718
  }
719
719
 
720
- if (_originalEvent && options.zoomRatio >= 0.055 && ratio > 0.95 && ratio < 1.05) {
721
- ratio = 1;
720
+ if (_originalEvent) {
721
+ switch (_originalEvent.type) {
722
+ case 'wheel':
723
+ if (options.zoomRatio >= 0.055 && ratio > 0.95 && ratio < 1.05) {
724
+ ratio = 1;
725
+ }
726
+ break;
727
+
728
+ case 'pointermove':
729
+ case 'touchmove':
730
+ case 'mousemove':
731
+ if (ratio > 0.99 && ratio < 1.01) {
732
+ ratio = 1;
733
+ }
734
+ break;
735
+
736
+ default:
737
+ }
722
738
  }
723
739
 
724
740
  const newWidth = naturalWidth * ratio;
@@ -745,10 +761,12 @@ export default {
745
761
 
746
762
  if (_originalEvent) {
747
763
  const offset = getOffset(this.viewer);
748
- const center = pointers && Object.keys(pointers).length ? getPointersCenter(pointers) : {
749
- pageX: _originalEvent.pageX,
750
- pageY: _originalEvent.pageY,
751
- };
764
+ const center = pointers && Object.keys(pointers).length > 0
765
+ ? getPointersCenter(pointers)
766
+ : {
767
+ pageX: _originalEvent.pageX,
768
+ pageY: _originalEvent.pageY,
769
+ };
752
770
 
753
771
  // Zoom from the triggering point of the event
754
772
  imageData.x -= offsetWidth * (((center.pageX - offset.left) - x) / width);
package/CHANGELOG.md DELETED
@@ -1,272 +0,0 @@
1
- # Changelog
2
-
3
- ## 1.10.2 (Oct 22, 2021)
4
-
5
- - Increase title height for avoiding truncation (#509).
6
- - Fix a `TypeError` when there are not any images (#504).
7
- - Remove loading class on image load error (#502).
8
-
9
- ## 1.10.1 (Aug 1, 2021)
10
-
11
- - Check if the active item exists to avoid TypeError (#491).
12
- - Compute nav item gutter dynamically (#487).
13
-
14
- ## 1.10.0 (Jun 12, 2021)
15
-
16
- - Enhance `fullscreen` option and `play` method to support [`FullscreenOptions`](https://developer.mozilla.org/en-US/docs/Web/API/FullscreenOptions) (#482, #483).
17
- - Refactor the `toggle` method for toggling image between current/natural ratio (#477).
18
- - Improve the `toggle` method for zooming by double-click (#422).
19
-
20
- ## 1.9.2 (May 29, 2021)
21
-
22
- - Avoid conflicts with other modals (#474).
23
- - Allow `ToolbarOption` to be undefined (#473).
24
-
25
- ## 1.9.1 (May 22, 2021)
26
-
27
- - Fix the missing declaration for the `focus` option (#470).
28
-
29
- ## 1.9.0 (Dec 6, 2020)
30
-
31
- - Add 6 new events: `move`, `moved`, `rotate`, `rotated`, `scale`, and `scaled`.
32
- - Add an example for limiting the moving range with the help of the `move` event.
33
-
34
- ## 1.8.0 (Nov 8, 2020)
35
-
36
- - Add a new option: `focus` .
37
- - Add ARIA attributes for better accessibility.
38
- - Add the `Tab` and `Enter` keys to the keyboard support.
39
- - Check if the `pointer` object is defined or not for better compatibility (#421).
40
-
41
- ## 1.7.1 (Sep 29, 2020)
42
-
43
- - Fix an issue in the `types/index.d.ts` file (#414).
44
-
45
- ## 1.7.0 (Sep 26, 2020)
46
-
47
- - Add 2 new events: `play` and `stop` (#411).
48
- - Let the `viewed`, `zoomed`, and `hidden` events not be canceled.
49
- - Improve the TypeScript declarations in the `types/index.d.ts` file.
50
-
51
- ## 1.6.2 (Aug 30, 2020)
52
-
53
- - Improve the `hide` method for some edge cases (#407).
54
- - Improve the wheel zoom behavior (#396).
55
- - Fix wrong usage about `this` in ES6+ (#395).
56
-
57
- ## 1.6.1 (Jun 14, 2020)
58
-
59
- - Improve image filtering.
60
-
61
- ## 1.6.0 (Jun 6, 2020)
62
-
63
- - Add a new options: `inheritedAttributes`.
64
- - Remove unnecessary `padding-right: 0px` from the `body` element when close the viewer modal (#394).
65
- - Reset the `padding-right` of the `body` element when resizing (#379).
66
- - Improve the `hide` method for unexpected calling (#367).
67
- - Ignore images without the `src` attribute (#326).
68
-
69
- ## 1.5.0 (Nov 23, 2019)
70
-
71
- - Force reflow element in a new way to avoid side-effect (#343).
72
- - Add a new option: `slideOnTouch` (#340).
73
- - Detect if the queried image is existing when updating the image list (#333).
74
-
75
- ## 1.4.0 (Oct 26, 2019)
76
-
77
- - Add two new options: `zoomOnTouch` and `zoomOnWheel` (#329).
78
-
79
- ## 1.3.7 (Oct 2, 2019)
80
-
81
- - Improve event type determining for iOS 13+ (#321).
82
- - Ignore invalid `element` parameter on the class utility functions (#317).
83
- - Do nothing if the `index` value is invalid when calling the `view` method (#312).
84
-
85
- ## 1.3.6 (Jul 4, 2019)
86
-
87
- - Avoid escaping URLs (#298, #301).
88
- - Avoid using the `innerHTML` property for security (#269).
89
-
90
- ## 1.3.5 (Jun 29, 2019)
91
-
92
- - Improve the escaping function to avoid escaping HTML entities repeatedly.
93
-
94
- ## 1.3.4 (Jun 1, 2019)
95
-
96
- - Decode image name when it comes from URL (#282).
97
- - Fix the missing fade-out transition when hiding the viewer (#275).
98
- - Escape all strings that use in HTML for better security (#269).
99
-
100
- ## 1.3.3 (Apr 6, 2019)
101
-
102
- - Fix unexpected modal exiting behavior when the mouse is pressed (#255).
103
- - Abort image downloading when cancel viewing for better performance.
104
-
105
- ## 1.3.2 (Jan 24, 2019)
106
-
107
- - Fix `Document not active` error when calling the `exit` method.
108
- - Improve wheel event listening for better performance (#102).
109
-
110
- ## 1.3.1 (Dec 9, 2018)
111
-
112
- - Ignore pointer events when not the primary button was pressed (#221).
113
- - Emulate click (single tap) and double click (double tap) in touch devices to support backdrop and image zooming (#210).
114
-
115
- ## 1.3.0 (Oct 25, 2018)
116
-
117
- - Fix wrong click action when target image is ignored by the `filter` option (#211)
118
- - Add a new option: `className` (#209).
119
-
120
- ## 1.2.1 (Oct 20, 2018)
121
-
122
- - Improve viewer instance storage to avoid side-effect.
123
- - Fix parameter error of `Object.assign` in iOS devices.
124
-
125
- ## 1.2.0 (Jul 15, 2018)
126
-
127
- - Enhance the `title` option to support to customize title content (#54, #185).
128
- - Add 2 new options: `toggleOnDblclick` (#173) and `initialViewIndex` (#183).
129
-
130
- ## 1.1.0 (May 27, 2018)
131
-
132
- - Make the touch zooming smoother (#162).
133
- - Add 2 new events: `zoom` and `zoomed` (#144).
134
-
135
- ## 1.0.1 (May 20, 2018)
136
-
137
- - Add a namespace to data attribute names (from `data-*` to `data-viewer-*`) to avoid side-effect.
138
- - Make sure the image data is a non-null object to avoid unexpected errors.
139
- - Fix broken zoom feature in iOS browsers (#167).
140
-
141
- ## 1.0.0 (Apr 1, 2018)
142
-
143
- - Add in browser checking to support import in Node.js.
144
- - Cancel update when there are no images when calling the `update` method.
145
-
146
- ## 1.0.0-rc.1 (Mar 13, 2018)
147
-
148
- - Fix the wrong image switching behavior in iOS browsers.
149
- - Fix a `TypeError` in strict mode (#149).
150
- - Fix type definitions issue of the `show` and `hide` methods.
151
-
152
- ## 1.0.0-rc (Mar 10, 2018)
153
-
154
- - Add a new option: `loading`.
155
- - Add type definitions file for TypeScript.
156
- - Enhance the `show`, `hide`, and `play` methods.
157
- - Change the default value of the `loop` option from `false` to `true`.
158
-
159
- ## 1.0.0-beta.2 (Feb 13, 2018)
160
-
161
- - Add a new option: `container`.
162
- - Recover the missing default value of the `interval` option (#133).
163
-
164
- ## 1.0.0-beta.1 (Dec 23, 2017)
165
-
166
- - Add a new option: `backdrop`.
167
-
168
- ## 1.0.0-beta (Dec 12, 2017)
169
-
170
- - Add `style` field to `package.json`.
171
- - Fall back to `document.documentElement` if `document.body` is not existing (#120).
172
- - Fix the issue of NodeList deconstructing (#118).
173
-
174
- ## 0.10.0 (Nov 5, 2017)
175
-
176
- - Add a new option: `loop`.
177
- - Enhance toolbar customization.
178
-
179
- ## 0.9.0 (Nov 4, 2017)
180
-
181
- - Add a new option: `filter`.
182
- - Support to customize the layout of the toolbar (#79).
183
- - Enhance the `prev` and `next` methods (#47).
184
- - Disallow to show again if it had shown.
185
-
186
- ## 0.8.0 (Oct 8, 2017)
187
-
188
- - Refactor - separate constants, simplify utilities, and so on.
189
- - Stop play after exited fullscreen.
190
- - Improve JSDoc.
191
-
192
- ## 0.7.2 (Aug 19, 2017)
193
-
194
- - Fixed multiple active items in the navbar (#75).
195
- - Ignore the mouse down event when the viewer is hiding (#70).
196
-
197
- ## 0.7.1 (May 14, 2017)
198
-
199
- - Support to use the viewer in a modal (#39).
200
-
201
- ## 0.7.0 (Apr 30, 2017)
202
-
203
- - Changed the `main` field value from `dist/viewer.js` (UMD) to `dist/viewer.common.js` (CommonJS).
204
- - Added `module` and `browser` fields to `package.json`.
205
- - Fixed an issue of touch zoom.
206
-
207
- ## 0.6.2 (Mar 4, 2017)
208
-
209
- - Fixed the issue of touch and move problem (#63).
210
-
211
- ## 0.6.1 (Feb 18, 2017)
212
-
213
- - Prevented the default behavior of drag action (#63).
214
-
215
- ## 0.6.0 (Jan 24, 2017)
216
-
217
- - Ported JavaScript code to ECMAScript 6.
218
- - Ported CSS code to CSSNext.
219
-
220
- ## 0.5.1 (Jan 2, 2017)
221
-
222
- - Improve event handler for Pointer Events.
223
-
224
- ## 0.5.0 (July 22, 2016)
225
-
226
- - Improve modal opening and closing.
227
- - Remove the `build` event.
228
- - Rename `built` event to `ready`.
229
- - Fixed a bug of `data-*` attributes setting and getting (#33).
230
-
231
- ## 0.4.0 (Mar 20, 2016)
232
-
233
- - Added some properties to `event.detail` of the "view" and "viewed" events.
234
-
235
- ## 0.3.3 (Mar 19, 2016)
236
-
237
- - Fix the issue of hiding the wrong element in the "view" method (#19).
238
-
239
- ## 0.3.2 (Mar 11, 2016)
240
-
241
- - Fix the error of the parameters on the `url` option when it is a function.
242
-
243
- ## 0.3.1 (Feb 2, 2016)
244
-
245
- - Added tests.
246
- - Ignored the invalid class name.
247
- - Re-render image only when viewed.
248
-
249
- ## 0.3.0 (Jan 21, 2016)
250
-
251
- - Add more available values to the "title", "toolbar" and "navbar" options.
252
- - Support to toggle the visibility of title, toolbar, and navbar between different screen widths.
253
- - Exit fullscreen when stop playing.
254
- - Fixed title not generated bug.
255
-
256
- ## 0.2.0 (Jan 1, 2016)
257
-
258
- - Added "update" method for update image dynamically.
259
- - Hides title and toolbar on small screen (width < 768px).
260
-
261
- ## 0.1.1 (Dec 28, 2015)
262
-
263
- - Supports to zoom from event triggering point.
264
- - Optimized "toggle" method.
265
- - Fixed a bug about the index of the viewing image.
266
-
267
- ## 0.1.0 (Dec 24, 2015)
268
-
269
- - Supports 2 modes: "modal" (default), "inline"
270
- - Supports 30 options: "inline", "button", "navbar", "title", "toolbar", "tooltip", "movable", "zoomable", "rotatable", "scalable", "transition", "fullscreen", "keyboard", "interval", "minWidth", "minHeight", "zoomRatio", "minZoomRatio", "maxZoomRatio", "zIndex", "zIndexInline", "url", "build", "built", "show", "shown", "hide", "hidden", "view", "viewed"
271
- - Supports 22 methods: "show", "hide", "view", "prev", "next", "move", "moveTo", "zoom", "zoomTo", "rotate", "rotateTo", "scale", "scaleX", "scaleY", "play", "stop", "full", "exit", "tooltip", "toggle", "reset", "destroy"
272
- - Supports 8 events: "build", "built", "show", "shown", "hide", "hidden", "view", "viewed"