优化公用函数

This commit is contained in:
Harvey Zack committed 2018-10-24 22:02:03 +08:00
1 parent a47d93355b
commit a738f97764
8 files changed
+52 -44

No files matched your search

-13
View File
@@ -1,4 +1,3 @@
import { secondToTime, clamp } from '../utils';
import Danmu from './danmu';
import Fullscreen from './fullscreen';
import Pip from './pip';
@@ -143,18 +142,6 @@ export default class Controls {
this.art.emit('control:show', control.option.$control);
}
});
Object.defineProperty(control, 'getPosFromEvent', {
value: event => {
const { $video, $progress } = this.art.refs;
const { left } = $progress.getBoundingClientRect();
const width = clamp(event.x - left, 0, $progress.clientWidth);
const second = width / $progress.clientWidth * $video.duration;
const time = secondToTime(second);
const percentage = clamp(width / $progress.clientWidth, 0, 1);
return { second, time, width, percentage };
}
});
}
show() {