Skip to content

Commit d2f7ce5

Browse files
authored
Merge pull request #44 from TheCodeRaccoons/Fix-issue-39
Update: Adding reset-ix2 to renderstatic - closes #39
2 parents 5f7963e + 986fe84 commit d2f7ce5

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Dist/WebflowOnly/RenderStatic.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ class RenderStatic {
44
constructor(_container) {
55
this.container = _container;
66
this.cloneables = document.querySelectorAll("[wt-renderstatic-element='cloneable']");
7+
this.resetIx2 = this.container.getAttribute('wt-renderstatic-resetix2') || false;
8+
79
this.gap = 0;
810
this.observer = null;
911

@@ -49,6 +51,7 @@ class RenderStatic {
4951
let childClone = child.cloneNode(true);
5052
if (parent) {
5153
parent.insertBefore(childClone, parent.children[index]);
54+
if(this.resetIx2) this.ResetInteraction(childClone);
5255
}
5356
}
5457

@@ -68,6 +71,38 @@ class RenderStatic {
6871

6972
this.observer.observe(this.container, { childList: true });
7073
}
74+
75+
ResetInteraction(element) {
76+
if (!element) {
77+
console.error('Element not found');
78+
return;
79+
}
80+
81+
const WebflowIX2 = window.Webflow && Webflow.require('ix2');
82+
if (!WebflowIX2) {
83+
console.error('Webflow IX2 engine not found.');
84+
return;
85+
}
86+
87+
const targetElement = element.hasAttribute('data-w-id')
88+
? element
89+
: element.querySelector('[data-w-id]');
90+
91+
if (!targetElement) {
92+
console.warn('No IX2 interaction found on the element or its children.');
93+
return;
94+
}
95+
96+
const dataWId = targetElement.getAttribute('data-w-id');
97+
if (dataWId) {
98+
targetElement.removeAttribute('data-w-id');
99+
targetElement.setAttribute('data-w-id', dataWId);
100+
101+
WebflowIX2.init();
102+
} else {
103+
console.warn('No valid data-w-id attribute found.');
104+
}
105+
}
71106
}
72107

73108
const initializeRenderStatic = () => {

0 commit comments

Comments
 (0)