Skip to content

Commit

Permalink
Refactor Artplayer class to update import path for Component
Browse files Browse the repository at this point in the history
  • Loading branch information
zhw2590582 committed Oct 20, 2024
1 parent 2db49bd commit ed88c73
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
2 changes: 2 additions & 0 deletions docs/assets/example/setting.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var art = new Artplayer({
{
width: 200,
html: 'Subtitle',
name: 'subtitle',
tooltip: 'Bilingual',
icon: '<img width="22" heigth="22" src="/assets/img/subtitle.svg">',
selector: [
Expand Down Expand Up @@ -83,6 +84,7 @@ var art = new Artplayer({
await sleep(1000);
art.setting.resize();
await sleep(1000);
art.setting.inactivate(art.setting.find('subtitle'));
art.setting.remove('aspect-ratio');
try {
art.setting.remove('aspect-ratio2');
Expand Down
12 changes: 9 additions & 3 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.

25 changes: 14 additions & 11 deletions packages/artplayer/src/setting/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,33 +172,35 @@ export default class Setting extends Component {
}
}

inactivate(item) {
for (let index = 0; index < item.$events.length; index++) {
this.art.events.remove(item.$events[index]);
}
item.$events.length = 0;
}

remove(name) {
const item = this.find(name);
errorHandle(item, `Can't find [${name}] in the [setting]`);
const index = item.$option.indexOf(item);
item.$option.splice(index, 1);

for (let index = 0; index < item.$events.length; index++) {
this.art.events.remove(item.$events[index]);
}

if (item.$item) {
remove(item.$item);
}

item.$events.length = 0;
this.inactivate(item);
if (item.$item) remove(item.$item);
this.render();
}

update(target) {
const item = this.find(target.name);

if (item) {
this.inactivate(item);
Object.assign(item, target);
this.format();
this.creatItem(item, true);
this.render();
return item;
} else {
this.add(target);
return this.add(target);
}
}

Expand All @@ -207,6 +209,7 @@ export default class Setting extends Component {
this.format();
this.creatItem(item);
this.render();
return item;
}

creatHeader(item) {
Expand Down

0 comments on commit ed88c73

Please sign in to comment.