mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-28 02:01:20 -08:00
refactor: Update thumbnail scale in Artplayer
This commit is contained in:
1 parent
3a2e7addd9
commit
5764344aaf
12 files changed
+135
-88
No files matched your search
@@ -1,4 +1,3 @@
|
||||
import { ArtPlayerError } from '../utils/error';
|
||||
import clickInit from './clickInit';
|
||||
import hoverInit from './hoverInit';
|
||||
import moveInit from './moveInit';
|
||||
@@ -13,7 +12,6 @@ export default class Events {
|
||||
this.destroyEvents = [];
|
||||
this.proxy = this.proxy.bind(this);
|
||||
this.hover = this.hover.bind(this);
|
||||
this.loadImg = this.loadImg.bind(this);
|
||||
|
||||
clickInit(art, this);
|
||||
hoverInit(art, this);
|
||||
@@ -45,28 +43,6 @@ export default class Events {
|
||||
}
|
||||
}
|
||||
|
||||
loadImg(img) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let image;
|
||||
|
||||
if (img instanceof HTMLImageElement) {
|
||||
image = img;
|
||||
} else if (typeof img === 'string') {
|
||||
image = new Image();
|
||||
image.src = img;
|
||||
} else {
|
||||
return reject(new ArtPlayerError('Unable to get Image'));
|
||||
}
|
||||
|
||||
if (image.complete) {
|
||||
return resolve(image);
|
||||
}
|
||||
|
||||
this.proxy(image, 'load', () => resolve(image));
|
||||
this.proxy(image, 'error', () => reject(new ArtPlayerError(`Failed to load Image: ${image.src}`)));
|
||||
});
|
||||
}
|
||||
|
||||
remove(destroyEvent) {
|
||||
const index = this.destroyEvents.indexOf(destroyEvent);
|
||||
if (index > -1) {
|
||||
|
||||
Reference in new issue
Block a user