test
parent
2b60c77341
commit
ba9a5c58cc
|
@ -41,6 +41,14 @@
|
||||||
|
|
||||||
.shx-video-card-product {
|
.shx-video-card-product {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
opacity: 0;
|
||||||
|
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
@ -56,8 +64,28 @@
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
console.log('connected');
|
console.log('connected');
|
||||||
console.log(this);
|
this.initVideo();
|
||||||
this.video = this.querySelector('video');
|
this.observer = new MutationObserver(this.initVideo.bind(this));
|
||||||
|
this.observer.observe(this, { childList: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
initVideo() {
|
||||||
|
this.video = this.querySelector('video');
|
||||||
|
if (!this.video) {
|
||||||
|
console.error('No video element found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log("video!", this.video);
|
||||||
|
this.addEventListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
disconnectedCallback() {
|
||||||
|
if (this.observer) {
|
||||||
|
this.observer.disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addEventListeners() {
|
||||||
|
|
||||||
if(!this.video) {
|
if(!this.video) {
|
||||||
console.error('No video element found');
|
console.error('No video element found');
|
||||||
|
@ -68,8 +96,6 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("video",this.video);
|
|
||||||
|
|
||||||
// get parrent with class "card-wrapper product-card-wrapper"
|
// get parrent with class "card-wrapper product-card-wrapper"
|
||||||
this.productCard = this.video.closest('.product-card-wrapper');
|
this.productCard = this.video.closest('.product-card-wrapper');
|
||||||
console.log(this.productCard);
|
console.log(this.productCard);
|
||||||
|
|
Loading…
Reference in New Issue