Widget:SlidingGallerySewing: Difference between revisions

From sandbox
Jump to navigation Jump to search
Gfc (talk | contribs)
No edit summary
Tag: Reverted
Gfc (talk | contribs)
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
<!-- =========================================================================
    ⚙️ MASTER VARIABLE CONFIGURATION ZONE
    Update, add, or remove your unique sewing studio equipment here.
    You only need to edit this list once—the script builds the loop for you!
    ========================================================================= -->
<script>
var GALLERY_DATA = [
  {
    link: "/wiki/index.php/Singer_HD_4432",
    img: "/wiki/images/thumb/e/e1/Singer_HD-1_4452.jpg/600px-Singer_HD-1_4452.jpg?20250616215327",
    title: "Singer HD 4432",
    desc: "Basic sewing machine"
  },
  {
    link: "/wiki/index.php/Singer_Simple_3232",
    img: "/wiki/images/thumb/0/08/Singer_Simple.jpg/800px-Singer_Simple.jpg?20191223184102",
    title: "Singer Simple 3232",
    desc: "Starter sewing machine"
  },
  {
    link: "/wiki/index.php/Janome_HD-3000BE",
    img: "/wiki/images/thumb/0/01/Janome_HD-3000BE.jpeg/400px-Janome_HD-3000BE.jpeg",
    title: "Janome HD-3000BE",
    desc: "Intermediate Home Sewing Machine"
  },
  {
    link: "/wiki/index.php/Bernina_model_1000",
    img: "/wiki/images/thumb/f/f9/Bernina1008.png/400px-Bernina1008.png",
    title: "Bernina model 1008",
    desc: "Intermediate Home Sewing Machine"
  },
  {
    link: "/wiki/index.php/Brother_1034DX",
    img: "/wiki/images/thumb/3/3e/Brother-1034DX-Serger.jpeg/120px-Brother-1034DX-Serger.jpeg",
    title: "Brother 1034DX",
    desc: "Serger"
  },
  {
    link: "/wiki/index.php/Brother_PE770",
    img: "/wiki/images/thumb/8/8d/BrotherPE770.jpg/240px-BrotherPE770.jpg",
    title: "Brother PE770",
    desc: "Embroidery machine"
  }
];
</script>
<!-- =========================================================================
    🎨 STYLING CONFIGURATION SYSTEM (Handles the enlarged image profiles)
    ========================================================================= -->
<style>
<style>
/* Layout containers matching your original specifications */
.gallery-outer { position: relative; height: 100%; margin: 20px 0; }
.gallery-outer { position: relative; height: 100%; margin: 20px 0; }
.gallery-bg { position: relative; margin: 0 -1em; padding: 0; background-color: transparent; border: 1px none #ddd; height: 100%; }
.gallery-bg { position: relative; margin: 0 -1em; padding: 0; background-color: transparent; border: 1px none #ddd; height: 100%; }
.gallery-viewport { position: relative; margin: 0 auto; width: 742px; height: 300px; overflow: hidden; }


/* Sliding engine (Pure CSS - Starts automatically) */
/* EXPANDED VIEWPORT BOUNDS: Tall enough to safely clear the new image sizes */
.gallery-viewport {
  position: relative;
  margin: 0 auto;
  width: 742px; /* Total viewable window width area optimized for iPads */
  height: 380px;
  overflow: hidden;
}
 
.wrapper {
.wrapper {
   position: absolute;
   position: absolute;
Line 11: Line 66:
   left: 0;
   left: 0;
   display: flex;
   display: flex;
   gap: 20px;
   gap: 25px; /* Spaces out your columns neatly */
  width: 300px; /* Generous width for the moving track */
   width: max-content;  
   animation: 45s credits linear infinite;
}
}


/* ⏸️ PAUSE ANIMATION ON HOVER */
/* ⏸️ PAUSE ANIMATION ON HOVER */
.wrapper:hover {
.wrapper:hover {
   animation-play-state: paused;
   animation-play-state: paused !important;
}
}


/* EXPANDED ITEM BOX COLUMNS: Boosted cards to make room for wide thumbnails */
.gallery-item {
.gallery-item {
   display: inline-block;
   display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
   text-align: center;
   text-align: center;
   width: 160px;
   width: 220px;  
   flex-shrink: 0;
   flex-shrink: 0;
}
}


/* DYNAMIC LARGE IMAGE BOUNDARIES */
.gallery-item img {
.gallery-item img {
   width: 120px;   
   width: 190px;   
   height: 180px;  
   height: 240px;  
   object-fit: contain;
   object-fit: contain; /* Scales mismatched image formats without distortion */
   transition: transform 0.3s ease;
   transition: transform 0.3s ease;
}
}
Line 37: Line 96:
/* 🔍 ENLARGE IMAGE ON HOVER */
/* 🔍 ENLARGE IMAGE ON HOVER */
.gallery-item img:hover {
.gallery-item img:hover {
   transform: scale(1.15);
   transform: scale(1.12);  
   cursor: pointer;
   cursor: pointer;
}
}


.gallery-caption {
.gallery-caption {
   font-size: 0.85em;
   font-size: 0.9em;  
   color: #333;
   color: #333;
   margin-top: 8px;
   margin-top: 10px;
   line-height: 1.3;
   line-height: 1.3;
}
@keyframes credits {
  0% { transform: translateX(0); }
  100% { transform: translateX(-1620px); } /* Perfect loop reset point based on total item widths */
}
}
</style>
</style>
Line 57: Line 111:
   <div class="gallery-bg">
   <div class="gallery-bg">
     <div class="gallery-viewport">
     <div class="gallery-viewport">
       <div class="wrapper">
       <div class="wrapper" id="sewing-marquee-track">
       
         <!-- Elements will be automatically generated and compiled here by the JavaScript below -->
        <!-- ITEM 1: Singer Heavy Duty -->
        <div class="gallery-item">
          <a href="/wiki/Singer_HD_4432">
            <img src="/wiki/images/thumb/e/e1/Singer_HD-1_4452.jpg/600px-Singer_HD-1_4452.jpg?20250616215327" alt="Singer HD 4432">
          </a>
          <div class="gallery-caption">Singer HD 4432<br><b>Basic sewing machine</b></div>
        </div>
 
        <!-- ITEM 2: Singer Simple -->
        <div class="gallery-item">
          <a href="/wiki/Singer_Simple_3232">
            <img src="/wiki/images/thumb/0/08/Singer_Simple.jpg/800px-Singer_Simple.jpg?20191223184102" alt="Singer Simple 3232">
          </a>
          <div class="gallery-caption">Singer Simple 3232<br><b>Starter sewing machine</b></div>
        </div>
 
         <!-- ITEM 3: Janome (Follows the same FilePath pattern) -->
        <div class="gallery-item">
          <a href="/wiki/Janome_HD-3000BE">
            <img src="/wiki/images/thumb/0/01/Janome_HD-3000BE.jpeg/400px-Janome_HD-3000BE.jpeg" alt="Janome HD-3000BE">
          </a>
          <div class="gallery-caption">Janome HD-3000BE<br><b>Intermediate Home Sewing Machine</b></div>
        </div>
 
        <!-- ITEM 4: Bernina -->
        <div class="gallery-item">
          <a href="/wiki/Bernina_model_1000">
            <img src="/wiki/images/thumb/f/f9/Bernina1008.png/400px-Bernina1008.png" alt="Bernina model 1008">
          </a>
          <div class="gallery-caption">Bernina model 1008<br><b>Intermediate Home Sewing Machine</b></div>
        </div>
 
        <!-- ITEM 5: Brother Serger -->
        <div class="gallery-item">
          <a href="/wiki/Brother_1034DX">
            <img src="/wiki/images/3/3e/Brother-1034DX-Serger.jpeg?20261015223103" alt="Brother 1034DX">
          </a>
          <div class="gallery-caption">Brother 1034DX<br><b>Serger</b></div>
        </div>
 
        <!-- ITEM 6: Brother Embroidery -->
        <div class="gallery-item">
          <a href="/wiki/Brother_PE770">
            <img src="/wiki/images/8/8d/BrotherPE770.jpg" alt="Brother PE770">
          </a>
          <div class="gallery-caption">Brother PE770<br><b>Embroidery machine</b></div>
        </div>
 
 
 
       </div>
       </div>
     </div>
     </div>
Line 114: Line 118:
</div>
</div>


<style>
<!-- =========================================================================
/* Clean override to let JavaScript control the sliding loop metrics */
    ⚡ AUTO-COMPILING INFINITE SLIDER ENGINE
.wrapper {
    ========================================================================= -->
  width: max-content !important;
  animation: none !important;
}
</style>
 
<script>
<script>
(function() {
(function() {
  // Find the scrolling layout track row
   var track = document.getElementById('sewing-marquee-track');
   var track = document.querySelector('.wrapper');
   if (!track || !GALLERY_DATA || GALLERY_DATA.length === 0) return;
   if (!track) return;


  // 1. Grab all your unique items cleanly
   var htmlOutput = '';
   var originalItems = Array.prototype.slice.call(track.getElementsByClassName('gallery-item'));
  var totalItemsCount = originalItems.length;
  if (totalItemsCount === 0) return;


   /* 2. FIXED STEP ENGINE:
   // 1. Build the HTML block for the primary list entries
    Uses your exact CSS parameters: Card width (160px) + Gap space (20px) = 180px per step! */
  for (var i = 0; i < GALLERY_DATA.length; i++) {
  var fullStepWidth = 180;  
    var item = GALLERY_DATA[i];
  var totalOriginalWidth = totalItemsCount * fullStepWidth;
    htmlOutput += '<div class="gallery-item">';
    /* 🌟 Pulls the complete, absolute path directly from your variables */
    htmlOutput += '  <a href="' + item.link + '"><img src="' + item.img + '" alt="' + item.title + '"></a>';
    htmlOutput += '  <div class="gallery-caption">' + item.title + '<br><b>' + item.desc + '</b></div>';
    htmlOutput += '</div>';
  }


   // 3. Smart Looper: Clone just enough items to fill the viewable viewport frame area (742px)
   // 2. Build the HTML block for the duplicate list entries to create the continuous loop
  var clonesNeeded = Math.ceil(742 / fullStepWidth) + 1;
  for (var j = 0; j < GALLERY_DATA.length; j++) {
    var cloneItem = GALLERY_DATA[j];
    htmlOutput += '<div class="gallery-item">';
    /* 🌟 Pulls the complete, absolute path directly from your variables */
    htmlOutput += '  <a href="' + cloneItem.link + '"><img src="' + cloneItem.img + '" alt="' + cloneItem.title + '"></a>';
    htmlOutput += '  <div class="gallery-caption">' + cloneItem.title + '<br><b>' + cloneItem.desc + '</b></div>';
    htmlOutput += '</div>';
  }


   for (var i = 0; i < clonesNeeded; i++) {
   // 3. Inject the compiled loop lists safely into the DOM track container
    var cloneIndex = i % totalItemsCount;
  track.innerHTML = htmlOutput;
    var clonedNode = originalItems[cloneIndex].cloneNode(true);
    track.appendChild(clonedNode);
  }


   // 4. Inject the loop transition keyframes directly into the header layout
   // 4. Calculate the mathematically perfect loop point dynamically using percentage tracking:
   var styleSheet = document.createElement("style");
   var styleSheet = document.createElement("style");
   styleSheet.type = "text/css";
   styleSheet.type = "text/css";
   styleSheet.innerText =  
   styleSheet.innerText =  
     "@keyframes dynamicCredits {" +
     "@keyframes dynamicMarquee {" +
     "  0% { transform: translateX(0); }" +
     "  0% { transform: translateX(0); }" +
     "  100% { transform: translateX(-" + totalOriginalWidth + "px); }" +
     "  100% { transform: translateX(-50%); }" +
     "}\n" +
     "}\n" +
     ".wrapper { animation: 45s dynamicCredits linear infinite !important; }";
     "#sewing-marquee-track { animation: 35s dynamicMarquee linear infinite; }";
   document.head.appendChild(styleSheet);
   document.head.appendChild(styleSheet);
})();
})();
</script>
</script>

Latest revision as of 23:30, 15 October 2026

<script> var GALLERY_DATA = [

 {
   link: "/wiki/index.php/Singer_HD_4432",
   img: "/wiki/images/thumb/e/e1/Singer_HD-1_4452.jpg/600px-Singer_HD-1_4452.jpg?20250616215327",
   title: "Singer HD 4432",
   desc: "Basic sewing machine"
 },
 {
   link: "/wiki/index.php/Singer_Simple_3232",
   img: "/wiki/images/thumb/0/08/Singer_Simple.jpg/800px-Singer_Simple.jpg?20191223184102",
   title: "Singer Simple 3232",
   desc: "Starter sewing machine"
 },
 {
   link: "/wiki/index.php/Janome_HD-3000BE",
   img: "/wiki/images/thumb/0/01/Janome_HD-3000BE.jpeg/400px-Janome_HD-3000BE.jpeg",
   title: "Janome HD-3000BE",
   desc: "Intermediate Home Sewing Machine"
 },
 {
   link: "/wiki/index.php/Bernina_model_1000",
   img: "/wiki/images/thumb/f/f9/Bernina1008.png/400px-Bernina1008.png",
   title: "Bernina model 1008",
   desc: "Intermediate Home Sewing Machine"
 },
 {
   link: "/wiki/index.php/Brother_1034DX",
   img: "/wiki/images/thumb/3/3e/Brother-1034DX-Serger.jpeg/120px-Brother-1034DX-Serger.jpeg",
   title: "Brother 1034DX",
   desc: "Serger"
 },
 {
   link: "/wiki/index.php/Brother_PE770",
   img: "/wiki/images/thumb/8/8d/BrotherPE770.jpg/240px-BrotherPE770.jpg",
   title: "Brother PE770",
   desc: "Embroidery machine"
 }

]; </script>

<style> .gallery-outer { position: relative; height: 100%; margin: 20px 0; } .gallery-bg { position: relative; margin: 0 -1em; padding: 0; background-color: transparent; border: 1px none #ddd; height: 100%; }

/* EXPANDED VIEWPORT BOUNDS: Tall enough to safely clear the new image sizes */ .gallery-viewport {

 position: relative; 
 margin: 0 auto; 
 width: 742px; /* Total viewable window width area optimized for iPads */
 height: 380px; 
 overflow: hidden; 

}

.wrapper {

 position: absolute;
 top: 0;
 left: 0;
 display: flex;
 gap: 25px; /* Spaces out your columns neatly */
 width: max-content; 

}

/* ⏸️ PAUSE ANIMATION ON HOVER */ .wrapper:hover {

 animation-play-state: paused !important;

}

/* EXPANDED ITEM BOX COLUMNS: Boosted cards to make room for wide thumbnails */ .gallery-item {

 display: flex;
 flex-direction: column;
 align-items: center;
 justify-content: flex-start;
 text-align: center;
 width: 220px; 
 flex-shrink: 0;

}

/* DYNAMIC LARGE IMAGE BOUNDARIES */ .gallery-item img {

 width: 190px;  
 height: 240px; 
 object-fit: contain; /* Scales mismatched image formats without distortion */
 transition: transform 0.3s ease;

}

/* 🔍 ENLARGE IMAGE ON HOVER */ .gallery-item img:hover {

 transform: scale(1.12); 
 cursor: pointer;

}

.gallery-caption {

 font-size: 0.9em; 
 color: #333;
 margin-top: 10px;
 line-height: 1.3;

} </style>

<script> (function() {

 var track = document.getElementById('sewing-marquee-track');
 if (!track || !GALLERY_DATA || GALLERY_DATA.length === 0) return;
 var htmlOutput = ;
 // 1. Build the HTML block for the primary list entries
 for (var i = 0; i < GALLERY_DATA.length; i++) {
   var item = GALLERY_DATA[i];

htmlOutput += '

';

 }
 // 2. Build the HTML block for the duplicate list entries to create the continuous loop
 for (var j = 0; j < GALLERY_DATA.length; j++) {
   var cloneItem = GALLERY_DATA[j];

htmlOutput += '

';

 }
 // 3. Inject the compiled loop lists safely into the DOM track container 
 track.innerHTML = htmlOutput;
 // 4. Calculate the mathematically perfect loop point dynamically using percentage tracking:
 var styleSheet = document.createElement("style");
 styleSheet.type = "text/css";
 styleSheet.innerText = 
   "@keyframes dynamicMarquee {" +
   "  0% { transform: translateX(0); }" +
   "  100% { transform: translateX(-50%); }" +
   "}\n" +
   "#sewing-marquee-track { animation: 35s dynamicMarquee linear infinite; }";
 document.head.appendChild(styleSheet);

})(); </script>