Files
ArtPlayer/packages/artplayer/src/layers.js
T
2018-11-28 12:15:33 +08:00

31 lines
785 B
JavaScript

import { setStyle } from './utils';
import component from './utils/component';
export default class Layers {
constructor(art) {
this.id = 0;
this.art = art;
this.add = this.add.bind(this);
this.art.option.layers.forEach(item => {
this.add(item);
});
}
add(item, callback) {
const { $layers } = this.art.template;
component(this.art, this, $layers, item, callback, 'layer');
}
show() {
const { $layers } = this.art.template;
setStyle($layers, 'display', 'block');
this.art.emit('layers:show', $layers);
}
hide() {
const { $layers } = this.art.template;
setStyle($layers, 'display', 'none');
this.art.emit('layers:hide', $layers);
}
}