bilca commited on
Commit
a956cf7
·
verified ·
1 Parent(s): 7d620d5

Update index_3.js

Browse files
Files changed (1) hide show
  1. index_3.js +11 -5
index_3.js CHANGED
@@ -56,11 +56,8 @@
56
  const chosenInitBeta = isMobile ? initBetaPhone : initBetaDesktop;
57
  const chosenInitRadius = isMobile ? initRadiusPhone : initRadiusDesktop;
58
 
59
- // Instead of calculating an aspect ratio from the parent container,
60
- // we force the widget to take the full dimensions of its parent.
61
- // This ensures the GIF preview and PLY viewer match the size of your Squarespace block.
62
-
63
- // Inject CSS styles into the document head, scoped with the unique id.
64
  const styleEl = document.createElement('style');
65
  styleEl.textContent = `
66
  /* Widget container styling - fill the entire parent block */
@@ -212,6 +209,15 @@
212
  </div>
213
  `;
214
  scriptTag.parentNode.appendChild(widgetContainer);
 
 
 
 
 
 
 
 
 
215
 
216
  // Grab element references.
217
  const gifPreview = document.getElementById('gif-preview-container-' + instanceId);
 
56
  const chosenInitBeta = isMobile ? initBetaPhone : initBetaDesktop;
57
  const chosenInitRadius = isMobile ? initRadiusPhone : initRadiusDesktop;
58
 
59
+ // Inject CSS styles into the document head.
60
+ // The container will be set to fill 100% of the parent block; its height will be explicitly updated in the script.
 
 
 
61
  const styleEl = document.createElement('style');
62
  styleEl.textContent = `
63
  /* Widget container styling - fill the entire parent block */
 
209
  </div>
210
  `;
211
  scriptTag.parentNode.appendChild(widgetContainer);
212
+
213
+ // Ensure the widget container takes the full height of its parent.
214
+ function updateWidgetSize() {
215
+ const parentHeight = scriptTag.parentNode.offsetHeight;
216
+ // If the parent height is defined, use it; otherwise fall back to a default height.
217
+ widgetContainer.style.height = (parentHeight && parentHeight > 0) ? parentHeight + "px" : "300px";
218
+ }
219
+ updateWidgetSize();
220
+ window.addEventListener("resize", updateWidgetSize);
221
 
222
  // Grab element references.
223
  const gifPreview = document.getElementById('gif-preview-container-' + instanceId);