Skip to content

Commit

Permalink
refactor: Simplify thumbnails implementation in Artplayer
Browse files Browse the repository at this point in the history
  • Loading branch information
zhw2590582 committed Aug 15, 2024
1 parent 3e3b38f commit 65b0b2c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 41 deletions.
30 changes: 8 additions & 22 deletions docs/uncompiled/artplayer/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/uncompiled/artplayer/index.js.map

Large diffs are not rendered by default.

13 changes: 5 additions & 8 deletions packages/artplayer/src/control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import progress from './progress';
import time from './time';
import volume from './volume';
import setting from './setting';
import thumbnails from './thumbnails';
import screenshot from './screenshot';
import airplay from './airplay';

Expand Down Expand Up @@ -81,13 +80,11 @@ export default class Control extends Component {
);
}

this.add(
thumbnails({
name: 'thumbnails',
position: 'top',
index: 20,
}),
);
this.add({
name: 'thumbnails',
position: 'top',
index: 20,
});

this.add(
playAndPause({
Expand Down
8 changes: 0 additions & 8 deletions packages/artplayer/src/control/thumbnails.js

This file was deleted.

5 changes: 3 additions & 2 deletions packages/artplayer/src/player/thumbnailsMix.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ export default function thumbnailsMix(art) {

art.on('setBar', async (type, percentage, event) => {
const $thumbnails = art.controls?.thumbnails;
if (!$thumbnails) return;
const { url } = option.thumbnails;
if (!$thumbnails || !url) return;

const isMobileDroging = type === 'played' && event && isMobile;

if (type === 'hover' || isMobileDroging) {
if (!loading) {
loading = true;
image = await loadImg(option.thumbnails.url);
image = await loadImg(url);
isLoad = true;
}

Expand Down

0 comments on commit 65b0b2c

Please sign in to comment.