mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-28 02:01:20 -08:00
forEach => for
This commit is contained in:
1 parent
99f5694100
commit
455e2189a7
18 files changed
+159
-103
No files matched your search
@@ -160,7 +160,9 @@ export default class Control extends Component {
|
||||
}),
|
||||
);
|
||||
|
||||
option.controls.forEach((item) => this.add(item));
|
||||
for (let index = 0; index < option.controls.length; index++) {
|
||||
this.add(option.controls[index]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -93,13 +93,14 @@ export default function progress(options) {
|
||||
}
|
||||
}
|
||||
|
||||
option.highlight.forEach((item) => {
|
||||
for (let index = 0; index < option.highlight.length; index++) {
|
||||
const item = option.highlight[index];
|
||||
const left = (clamp(item.time, 0, art.duration) / art.duration) * 100;
|
||||
append(
|
||||
$highlight,
|
||||
`<span data-text="${item.text}" data-time="${item.time}" style="left: ${left}%"></span>`,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
setBar('loaded', art.loaded);
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { secondToTime } from '../utils';
|
||||
|
||||
export default function time(option) {
|
||||
return art => ({
|
||||
return (art) => ({
|
||||
...option,
|
||||
mounted: $control => {
|
||||
mounted: ($control) => {
|
||||
function getTime() {
|
||||
const newTime = `${secondToTime(art.currentTime)} / ${secondToTime(art.duration)}`;
|
||||
if (newTime !== $control.innerText) {
|
||||
@@ -12,9 +12,11 @@ export default function time(option) {
|
||||
}
|
||||
|
||||
getTime();
|
||||
['video:loadedmetadata', 'video:timeupdate', 'video:progress'].forEach(event => {
|
||||
art.on(event, getTime);
|
||||
});
|
||||
|
||||
const events = ['video:loadedmetadata', 'video:timeupdate', 'video:progress'];
|
||||
for (let index = 0; index < events.length; index++) {
|
||||
art.on(events[index], getTime);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user