We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 74ff7f8 commit 6c2600cCopy full SHA for 6c2600c
src/viewer.js
@@ -40,16 +40,21 @@ class Viewer extends EventEmitter {
40
}
41
42
43
+ // Find the lowest index of all current images
44
+ // and return one less than that
45
get previousIndex() {
- if (this.preloader) {
- return this.preloader.index - 1
46
- } else {
47
- if (this.ready) {
48
- return this.ready.index - 1
49
50
- return -1
51
- }
+ const p = this.preloader?.index
+ const r = this.ready?.index
+ const s = this.showing?.index
+ const indexes = []
+ p !== undefined && indexes.push(p)
+ r !== undefined && indexes.push(r)
52
+ s !== undefined && indexes.push(s)
53
+ if (indexes.length === 0) {
54
+ return -1
55
56
+ const min = Math.min(...indexes)
57
+ return min - 1
58
59
60
get showIndex() {
0 commit comments