mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-25 16:11:20 -08:00
调整预览图精度bug
This commit is contained in:
1 parent
09ef4c975b
commit
bf22c92209
6 files changed
+8
-6
No files matched your search
@@ -164,11 +164,12 @@ class ArtplayerToolThumbnail extends Emitter {
|
||||
const { number, width, height, column } = this.option;
|
||||
const { duration } = this.video;
|
||||
const timeGap = duration / number;
|
||||
const timePoints = [0];
|
||||
const timePoints = [timeGap];
|
||||
while (timePoints.length < number) {
|
||||
const last = timePoints[timePoints.length - 1];
|
||||
timePoints.push(last + timeGap);
|
||||
}
|
||||
console.log(timePoints);
|
||||
return timePoints.map((item, index) => ({
|
||||
time: item - timeGap / 2,
|
||||
x: (index % column) * width,
|
||||
|
||||
@@ -17,7 +17,7 @@ export default function thumbnails(controlOption) {
|
||||
const { width: posWidth } = getPosFromEvent(art, event);
|
||||
const { url, height, width, number, column } = art.option.thumbnails;
|
||||
const perWidth = $progress.clientWidth / number;
|
||||
const perIndex = Math.ceil(posWidth / perWidth);
|
||||
const perIndex = Math.floor(posWidth / perWidth);
|
||||
const yIndex = Math.ceil(perIndex / column) - 1;
|
||||
const xIndex = perIndex % column || column - 1;
|
||||
setStyle($control, 'backgroundImage', `url(${url})`);
|
||||
|
||||
Reference in new issue
Block a user