Skip to content

Commit

Permalink
build: release 1.10.3
Browse files Browse the repository at this point in the history
  • Loading branch information
fengyuanchen committed Feb 2, 2022
1 parent 800ec9b commit e0b63b6
Show file tree
Hide file tree
Showing 13 changed files with 525 additions and 555 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## next
## 1.10.3 (Feb 2, 2022)

- Get the pageX/Y properties from the original event when it is an emulated double click in touch devices (#527).
- Improve the zoom experience on the touch screen (#510).
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Viewer.js

[![Downloads](https://img.shields.io/npm/dm/viewerjs.svg)](https://www.npmjs.com/package/viewerjs) [![Version](https://img.shields.io/npm/v/viewerjs.svg)](https://www.npmjs.com/package/viewerjs) [![Gzip Size](https://img.shields.io/bundlephobia/minzip/viewerjs.svg)](https://unpkg.com/viewerjs/dist/viewer.common.js) [![Dependencies](https://img.shields.io/david/fengyuanchen/viewerjs.svg)](https://www.npmjs.com/package/viewerjs)
[![Downloads](https://img.shields.io/npm/dm/viewerjs.svg)](https://www.npmjs.com/package/viewerjs) [![Version](https://img.shields.io/npm/v/viewerjs.svg)](https://www.npmjs.com/package/viewerjs) [![Gzip Size](https://img.shields.io/bundlephobia/minzip/viewerjs.svg)](https://unpkg.com/viewerjs/dist/viewer.common.js)

> JavaScript image viewer.
Expand Down Expand Up @@ -36,7 +36,7 @@
- Supports keyboard
- Cross-browser support

## Main
## Main files

```text
dist/
Expand Down
88 changes: 47 additions & 41 deletions dist/viewer.common.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*!
* Viewer.js v1.10.2
* Viewer.js v1.10.3
* https://fengyuanchen.github.io/viewerjs
*
* Copyright 2015-present Chen Fengyuan
* Released under the MIT license
*
* Date: 2021-10-22T13:59:51.046Z
* Date: 2022-02-02T05:15:01.702Z
*/

'use strict';
Expand All @@ -15,34 +15,22 @@ function ownKeys(object, enumerableOnly) {

if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);

if (enumerableOnly) {
symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
}

keys.push.apply(keys, symbols);
enumerableOnly && (symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
}

return keys;
}

function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};

if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}

return target;
Expand All @@ -51,17 +39,11 @@ function _objectSpread2(target) {
function _typeof(obj) {
"@babel/helpers - typeof";

if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}

return _typeof(obj);
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
}, _typeof(obj);
}

function _classCallCheck(instance, Constructor) {
Expand All @@ -83,6 +65,9 @@ function _defineProperties(target, props) {
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;
}

Expand Down Expand Up @@ -1454,9 +1439,10 @@ var handlers = {
// Cancel the emulated double click when the native dblclick event was triggered.
if (IS_TOUCH_DEVICE && event.isTrusted) {
clearTimeout(this.doubleClickImageTimeout);
}
} // XXX: No pageX/Y properties in custom event, fallback to the original event.


this.toggle(event);
this.toggle(event.isTrusted ? event : event.detail && event.detail.originalEvent);
}
},
load: function load() {
Expand Down Expand Up @@ -1723,7 +1709,9 @@ var handlers = {
this.imageClicked = false; // This timeout will be cleared later when a native dblclick event is triggering

this.doubleClickImageTimeout = setTimeout(function () {
dispatchEvent(_this2.image, EVENT_DBLCLICK);
dispatchEvent(_this2.image, EVENT_DBLCLICK, {
originalEvent: event
});
}, 50);
} else {
this.imageClicked = true; // The default timing of a double click in Windows is 500 ms
Expand All @@ -1738,7 +1726,9 @@ var handlers = {
if (options.backdrop && options.backdrop !== 'static' && event.target === this.canvas) {
// This timeout will be cleared later when a native click event is triggering
this.clickCanvasTimeout = setTimeout(function () {
dispatchEvent(_this2.canvas, EVENT_CLICK);
dispatchEvent(_this2.canvas, EVENT_CLICK, {
originalEvent: event
});
}, 50);
}
}
Expand Down Expand Up @@ -2492,8 +2482,24 @@ var methods = {
ratio = Math.min(Math.max(ratio, minZoomRatio), maxZoomRatio);
}

if (_originalEvent && options.zoomRatio >= 0.055 && ratio > 0.95 && ratio < 1.05) {
ratio = 1;
if (_originalEvent) {
switch (_originalEvent.type) {
case 'wheel':
if (options.zoomRatio >= 0.055 && ratio > 0.95 && ratio < 1.05) {
ratio = 1;
}

break;

case 'pointermove':
case 'touchmove':
case 'mousemove':
if (ratio > 0.99 && ratio < 1.01) {
ratio = 1;
}

break;
}
}

var newWidth = naturalWidth * ratio;
Expand All @@ -2520,7 +2526,7 @@ var methods = {

if (_originalEvent) {
var offset = getOffset(this.viewer);
var center = pointers && Object.keys(pointers).length ? getPointersCenter(pointers) : {
var center = pointers && Object.keys(pointers).length > 0 ? getPointersCenter(pointers) : {
pageX: _originalEvent.pageX,
pageY: _originalEvent.pageY
}; // Zoom from the triggering point of the event
Expand Down
Loading

0 comments on commit e0b63b6

Please sign in to comment.