We need TW players to complete the article of the region-locked game Fingertips Breakout.
We're aware of an issue which causes comments to only appear after a long delay and are working on a solution.
You don't need an account to add and correct this Wiki. Learn how to contribute, browse Bounties and join our Discord server.

User:Messing with data/vector.js: Difference between revisions

Welcome to IOP Wiki. This website is maintained by the Girls' Frontline community and is free to edit by anyone.
Jump to navigation Jump to search
Rely on old jQuery...
m Some polish (Removed logs and added safe attribute setting)
Line 1: Line 1:
$(document).ready(function() {
$(document).ready(function() {
  console.log("Starting own vector.js");
   var lazyImages = [].slice.call(document.querySelectorAll(".lazy-beta"));
   var lazyImages = [].slice.call(document.querySelectorAll(".lazy-beta"));
   console.log("lazyImages", lazyImages);
   console.log("Images to lazy load:", lazyImages.length);
   if ("IntersectionObserver" in window) {
   if ("IntersectionObserver" in window) {
    console.log("Defining observer...");
     var lazyImageObserver = new IntersectionObserver(function(entries, observer) {
     var lazyImageObserver = new IntersectionObserver(function(entries, observer) {
       entries.forEach(function(entry) {
       entries.forEach(function(entry) {
         if (entry.isIntersecting) {
         if (entry.isIntersecting) {
           var lazyImage = entry.target;
           var lazyImage = entry.target;
           lazyImage.src = lazyImage.dataset.src;
           if (lazyImage.dataset.src) { lazyImage.src = lazyImage.dataset.src; }
           lazyImage.srcset = lazyImage.dataset.srcset;
           if (lazyImage.dataset.srcset) { lazyImage.srcset = lazyImage.dataset.srcset; }
           lazyImage.classList.remove("lazy-beta");
           lazyImage.classList.remove("lazy-beta");
           lazyImageObserver.unobserve(lazyImage);
           lazyImageObserver.unobserve(lazyImage);
Line 18: Line 16:


     lazyImages.forEach(function(lazyImage) {
     lazyImages.forEach(function(lazyImage) {
      console.log("Processing image", lazyImage);
       lazyImageObserver.observe(lazyImage);
       lazyImageObserver.observe(lazyImage);
     });
     });

Revision as of 23:07, 18 June 2024

$(document).ready(function() {
  var lazyImages = [].slice.call(document.querySelectorAll(".lazy-beta"));
  console.log("Images to lazy load:", lazyImages.length);
  if ("IntersectionObserver" in window) {
    var lazyImageObserver = new IntersectionObserver(function(entries, observer) {
      entries.forEach(function(entry) {
        if (entry.isIntersecting) {
          var lazyImage = entry.target;
          if (lazyImage.dataset.src) { lazyImage.src = lazyImage.dataset.src; }
          if (lazyImage.dataset.srcset) { lazyImage.srcset = lazyImage.dataset.srcset; }
          lazyImage.classList.remove("lazy-beta");
          lazyImageObserver.unobserve(lazyImage);
        }
      });
    });

    lazyImages.forEach(function(lazyImage) {
      lazyImageObserver.observe(lazyImage);
    });
  } else {
    // Possibly fall back to event handlers here
    console.log("Lazy Loading seems to have failed.");
  }
});