test
parent
46a5c928cd
commit
824edcf012
|
@ -10,6 +10,8 @@
|
||||||
super();
|
super();
|
||||||
// element functionality written in here
|
// element functionality written in here
|
||||||
this.currentVariant = null;
|
this.currentVariant = null;
|
||||||
|
|
||||||
|
this.videoClones = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
|
@ -20,7 +22,7 @@
|
||||||
this.currentVariant = id;
|
this.currentVariant = id;
|
||||||
|
|
||||||
// edit inner html
|
// edit inner html
|
||||||
this.innerHTML = `<div>Init variant: ${this.currentVariant}</div>`;
|
reloadCurrentVariant(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnectedCallback() {
|
disconnectedCallback() {
|
||||||
|
@ -41,13 +43,19 @@
|
||||||
if (video) {
|
if (video) {
|
||||||
|
|
||||||
// clone video to shadow dom
|
// clone video to shadow dom
|
||||||
let videoClone = video.cloneNode(true);
|
let videoClone = null;
|
||||||
this.appendChild(videoClone);
|
if (this.videoClones[this.currentVariant]) {
|
||||||
|
videoClone = this.videoClones[this.currentVariant];
|
||||||
|
} else {
|
||||||
|
videoClone = video.cloneNode(true);
|
||||||
|
this.videoClones[this.currentVariant] = videoClone;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.appendChild(videoClone);
|
||||||
|
|
||||||
// get video element
|
// get video element
|
||||||
let videoElement = this.querySelector('.shx-video');
|
let videoElement = this.querySelector('.shx-video');
|
||||||
videoElement.classList.add('shx-video-for-desc');
|
videoElement.classList.add('shx-video-for-desc');
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue