fix: filter target image when click to view

Fixes #211
This commit is contained in:
Chen Fengyuan 2018-10-24 20:42:14 +08:00
parent f56ae1013d
commit fbfbedfaec
2 changed files with 6 additions and 1 deletions

View File

@ -1,5 +1,9 @@
# Changelog
## next
- Fix wrong click action when the target image is ignored by the `filter` option (#211)
## 1.2.1 (Oct 20, 2018)
- Improve viewer instance storage to avoid side effect.

View File

@ -163,7 +163,8 @@ class Viewer {
});
} else {
addListener(element, EVENT_CLICK, (this.onStart = ({ target }) => {
if (target.tagName.toLowerCase() === 'img') {
if (target.tagName.toLowerCase() === 'img'
&& isFunction(options.filter) && options.filter.call(this, target)) {
this.view(this.images.indexOf(target));
}
}));