Skip to content

Commit ab86b55

Browse files
committed
fix(player): show thumbnail img once it has loaded
1 parent a17239a commit ab86b55

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

packages/vidstack/player/styles/default/thumbnail.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
will-change: width, height, transform;
3232
}
3333

34+
:where(.vds-thumbnail[data-loading] img) {
35+
opacity: 0;
36+
}
37+
3438
:where(.vds-thumbnail[aria-hidden='true']) {
3539
display: none !important;
3640
}

packages/vidstack/src/components/ui/thumbnails/thumbnail.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export class Thumbnail extends Component<ThumbnailProps, ThumbnailState> {
9292

9393
private _onLoaded() {
9494
const { loading, error } = this.$state;
95+
this._resize();
9596
loading.set(false);
9697
error.set(null);
9798
}
@@ -124,9 +125,11 @@ export class Thumbnail extends Component<ThumbnailProps, ThumbnailState> {
124125
}
125126

126127
private _onFindActiveThumbnail() {
128+
let images = this._loader.$images();
129+
if (!images.length) return;
130+
127131
let time = this._getTime(),
128132
{ src, activeThumbnail } = this.$state,
129-
images = this._loader.$images(),
130133
activeIndex = -1,
131134
activeImage: ThumbnailImage | null = null;
132135

@@ -147,14 +150,13 @@ export class Thumbnail extends Component<ThumbnailProps, ThumbnailState> {
147150
}
148151

149152
private _resize() {
150-
if (!this.scope) return;
153+
if (!this.scope || this.$state.hidden()) return;
151154

152155
const rootEl = this.el,
153156
imgEl = this.$state.img(),
154-
loading = this.$state.loading(),
155157
thumbnail = this.$state.activeThumbnail();
156158

157-
if (!imgEl || !thumbnail || !rootEl || loading) return;
159+
if (!imgEl || !thumbnail || !rootEl) return;
158160

159161
let width = thumbnail.width ?? imgEl.naturalWidth,
160162
height = thumbnail?.height ?? imgEl.naturalHeight,

0 commit comments

Comments
 (0)