Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit ceb88ed

Browse files
committed
fixes
- fix images preview not showing after using search - fix cant use fullscreen mode when opening the video in a preview card - fix ratio bar not showing correct details - when video/audio is in preview mode, using `space` will now play/pause the item instead of closing the modal - fix changing the screen size closes the preview card when fullscreen is on or media is playing - some cleanup
1 parent 4f1723a commit ceb88ed

File tree

14 files changed

+166
-93
lines changed

14 files changed

+166
-93
lines changed

src/resources/assets/js/components/manager.vue

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ export default {
101101
moveToPath: null,
102102
newFilename: null,
103103
newFolderName: null,
104-
plyr: null,
104+
player: {
105+
item: null,
106+
fs: false,
107+
playing: false
108+
},
105109
searchFor: null,
106110
searchItemsCount: null,
107111
selectedFile: null,
@@ -142,16 +146,21 @@ export default {
142146
this.scrollObserve()
143147
},
144148
updated: debounce(function() {
145-
this.scrollByRow()
149+
if (this.firstRun) {
150+
this.scrollByRow()
146151
147-
if (this.selectedFileIs('video') || this.selectedFileIs('audio')) {
148-
this.initPlyr()
149-
}
152+
if (this.selectedFileIs('video') || this.selectedFileIs('audio')) {
153+
this.destroyPlyr()
154+
this.$nextTick(() => {
155+
this.initPlyr()
156+
})
157+
}
150158
151-
if (!this.introIsOn) {
152-
this.activeModal || this.inModal
153-
? this.noScroll('add')
154-
: this.noScroll('remove')
159+
if (!this.introIsOn) {
160+
this.activeModal || this.inModal
161+
? this.noScroll('add')
162+
: this.noScroll('remove')
163+
}
155164
}
156165
}, 250),
157166
beforeDestroy() {
@@ -202,7 +211,11 @@ export default {
202211
203212
// get images dimensions
204213
EventHub.listen('save-image-dimensions', (obj) => {
205-
this.dimensions.push(obj)
214+
let dim = this.dimensions
215+
216+
if (!dim.some((e) => e.url === obj.url)) {
217+
dim.push(obj)
218+
}
206219
})
207220
208221
// stop listening to shortcuts
@@ -364,8 +377,9 @@ export default {
364377
else {
365378
if (this.isActiveModal('preview_modal')) {
366379
if (key == 'space') {
367-
e.preventDefault()
368-
this.toggleModal()
380+
this.selectedFileIs('video') || this.selectedFileIs('audio')
381+
? this.playMedia()
382+
: this.toggleModal()
369383
}
370384
371385
this.navigation(e)

src/resources/assets/js/components/utils/ratio.vue

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,27 @@ export default {
4040
immediate: true,
4141
deep: true,
4242
handler(val, oldVal) {
43-
let ratio = {
44-
image: 0,
45-
audio: 0,
46-
video: 0,
47-
text: 0,
48-
folder: 0,
49-
application: 0
50-
}
43+
setTimeout(() => {
44+
let ratio = {
45+
image: 0,
46+
audio: 0,
47+
video: 0,
48+
text: 0,
49+
folder: 0,
50+
application: 0
51+
}
5152
52-
val.forEach((e) => {
53-
if (this.fileTypeIs(e, 'audio')) ratio.audio++
54-
if (this.fileTypeIs(e, 'video')) ratio.video++
55-
if (this.fileTypeIs(e, 'image')) ratio.image++
56-
if (this.fileTypeIs(e, 'folder')) ratio.folder++
57-
if (this.fileTypeIs(e, 'text') || this.fileTypeIs(e, 'pdf')) ratio.text++
58-
if (this.fileTypeIs(e, 'application') || this.fileTypeIs(e, 'compressed')) ratio.application++
59-
})
53+
val.forEach((e) => {
54+
if (this.fileTypeIs(e, 'audio')) ratio.audio++
55+
if (this.fileTypeIs(e, 'video')) ratio.video++
56+
if (this.fileTypeIs(e, 'image')) ratio.image++
57+
if (this.fileTypeIs(e, 'folder')) ratio.folder++
58+
if (this.fileTypeIs(e, 'text') || this.fileTypeIs(e, 'pdf')) ratio.text++
59+
if (this.fileTypeIs(e, 'application') || this.fileTypeIs(e, 'compressed')) ratio.application++
60+
})
6061
61-
this.contentRatio = ratio
62+
this.contentRatio = ratio
63+
}, 100)
6264
}
6365
}
6466
}

src/resources/assets/js/mixins/lazy.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,24 @@ export default {
2424
this.isObserving = true
2525

2626
setTimeout(() => {
27-
if (!this.intersected && this.isObserving) {
27+
if (!this.intersected) {
2828
this.browserSupport('IntersectionObserver')
2929
? this.observe()
3030
: this.intersected = true
3131
}
3232
}, 500)
3333
})
3434

35+
EventHub.listen('start-search-observing', () => {
36+
this.isObserving = true
37+
38+
setTimeout(() => {
39+
this.browserSupport('IntersectionObserver')
40+
? this.observe()
41+
: this.intersected = true
42+
}, 500)
43+
})
44+
3545
EventHub.listen('stop-img-observing', () => {
3646
this.stop()
3747
})

src/resources/assets/js/modules/bulk.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ export default {
3939
this.resetInput(['selectedFile', 'currentFileIndex'])
4040

4141
if (!this.isBulkSelecting()) {
42-
!this.lazyModeIsOn()
43-
? file ? this.setSelected(file, index) : this.selectFirst()
44-
: this.lazySelectFirst()
42+
this.lazyModeIsOn()
43+
? this.lazySelectFirst()
44+
: file
45+
? this.setSelected(file, index)
46+
: this.selectFirst()
4547
}
4648
},
4749
blkSlctAll() {

src/resources/assets/js/modules/filtration.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ export default {
8080
}
8181

8282
if (!this.isBulkSelecting()) {
83-
!this.lazyModeIsOn()
84-
? this.selectFirst()
85-
: this.lazySelectFirst()
83+
this.lazyModeIsOn()
84+
? this.lazySelectFirst()
85+
: this.selectFirst()
8686
}
8787

8888
if (this.searchFor) {
@@ -96,14 +96,24 @@ export default {
9696

9797
// search
9898
updateSearchCount() {
99-
let oldCount = this.searchItemsCount
100-
10199
this.$nextTick(() => {
102100
this.searchItemsCount = this.filesList.length
103101

104-
return this.searchItemsCount == 0
105-
? oldCount == 0 ? false : this.noSearch('show')
106-
: this.noSearch('hide')
102+
this.$nextTick(() => {
103+
if (this.searchItemsCount == 0) {
104+
this.resetInput(['selectedFile', 'currentFileIndex'])
105+
106+
!this.no_search
107+
? this.noSearch('show')
108+
: false
109+
} else {
110+
this.selectFirstInBulkList()
111+
112+
this.no_search
113+
? this.noSearch('hide')
114+
: false
115+
}
116+
})
107117
})
108118
}
109119
}

src/resources/assets/js/modules/form.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ export default {
224224
files.some((e, i) => {
225225
if (prev_file && e.name == prev_file) {
226226
index = lazy
227-
? this.fileTypeIs(e, 'image') ? null : i
227+
? this.fileTypeIs(e, 'image')
228+
? null
229+
: i
228230
: i
229231
}
230232

@@ -236,16 +238,20 @@ export default {
236238
})
237239
}
238240

239-
// no prev found
240-
if (!this.currentFileIndex) {
241-
lazy ? this.lazySelectFirst() : this.selectFirst()
242-
}
241+
this.$nextTick(() => {
242+
// no prev found
243+
if (!this.currentFileIndex) {
244+
lazy ? this.lazySelectFirst() : this.selectFirst()
245+
}
243246

244-
if (this.searchFor) {
245-
this.updateSearchCount()
246-
}
247+
// update search
248+
if (this.searchFor) {
249+
this.updateSearchCount()
250+
}
247251

248-
this.dirsListCheck()
252+
// update dirs
253+
this.dirsListCheck()
254+
})
249255
}
250256

251257
this.isLoading = false
@@ -430,9 +436,9 @@ export default {
430436
? this.blkSlct()
431437
: hasErrors
432438
? false
433-
: !this.lazyModeIsOn()
434-
? this.selectFirst()
435-
: this.lazySelectFirst()
439+
: this.lazyModeIsOn()
440+
? this.lazySelectFirst()
441+
: this.selectFirst()
436442
}
437443
})
438444
}
@@ -491,9 +497,9 @@ export default {
491497
this.isBulkSelecting()
492498
? this.blkSlct()
493499
: this.allItemsCount
494-
? !this.lazyModeIsOn()
495-
? this.selectFirst()
496-
: this.lazySelectFirst()
500+
? this.lazyModeIsOn()
501+
? this.lazySelectFirst()
502+
: this.selectFirst()
497503
: false
498504
})
499505
}

src/resources/assets/js/modules/media-player.js

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,56 @@ export default {
1717
let item = document.querySelector('[data-player]')
1818

1919
if (item) {
20-
this.plyr = new Plyr(item, options)
20+
this.player.item = new Plyr(item, options)
21+
22+
let plr = this.player.item
23+
24+
// status
25+
plr.on('playing', (e) => {
26+
this.player.playing = true
27+
})
28+
plr.on('pause', (e) => {
29+
this.player.playing = false
30+
})
31+
32+
// fs
33+
plr.on('enterfullscreen', (e) => {
34+
this.player.fs = true
35+
document.querySelector('[data-plyr="fullscreen"]').blur()
36+
})
37+
plr.on('exitfullscreen', (e) => {
38+
this.player.fs = false
39+
})
40+
2141
clearInterval(t)
2242
}
2343
}, 50)
2444
}
2545
},
2646
destroyPlyr() {
27-
if (this.plyr) this.plyr.destroy()
28-
this.plyr = null
47+
if (this.player.item) this.player.item.destroy()
48+
this.player = {
49+
item: null,
50+
fs: false,
51+
playing: false
52+
}
2953
},
3054
playMedia() {
31-
return this.plyr ? this.plyr.togglePlay() : false
55+
if (this.player.item) {
56+
this.player.item.togglePlay()
57+
}
3258
},
3359
autoPlay() {
3460
if (this.filterNameIs('audio') || this.filterNameIs('video')) {
35-
let player = this.plyr
36-
37-
player.on('ended', () => {
61+
this.player.item.on('ended', () => {
3862
// stop at the end of list
3963
if (this.currentFileIndex < this.allItemsCount - 1) {
4064
// nav to next
4165
this.goToNext()
4266

4367
// play navigated to
4468
this.$nextTick(() => {
45-
setTimeout(this.plyr.play(), 500)
69+
setTimeout(this.player.item.play(), 500)
4670
})
4771
}
4872
})

src/resources/assets/js/modules/selection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
setSelected(file, index, e = null) {
1313
if (!this.isBulkSelecting() && this.isSelected(file)) return
1414

15-
EventHub.fire('stopHammerPropagate')
15+
// EventHub.fire('stopHammerPropagate')
1616

1717
if (e && e.metaKey && !this.firstMeta) {
1818
this.firstMeta = true

src/resources/assets/js/modules/utils.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ export default {
4040
this.resetInput('bulkList', [])
4141
this.resetInput('searchFor')
4242

43-
!this.lazyModeIsOn()
44-
? this.selectFirst()
45-
: this.lazySelectFirst()
43+
this.lazyModeIsOn()
44+
? this.lazySelectFirst()
45+
: this.selectFirst()
4646
},
4747

4848
/* Resolve */
@@ -203,10 +203,12 @@ export default {
203203
this.infoSidebar = false
204204
this.smallScreen = true
205205
} else {
206-
// hide active player modal
206+
// hide active player modal
207207
if (
208208
this.isActiveModal('preview_modal') &&
209-
(this.selectedFileIs('video') || this.selectedFileIs('audio'))
209+
(this.selectedFileIs('video') || this.selectedFileIs('audio')) &&
210+
!this.player.fs &&
211+
!this.player.playing
210212
) {
211213
this.toggleModal()
212214
}

0 commit comments

Comments
 (0)