1jQuery(document).ready(function(){ 2 // Check how many items we have 3 console.log(jQuery('#cn-feed').width()); //( There should be a limit on how many should be presented at a time...) 4 5 6 //! We have to apply only functionality as the content is loading later... 7 8 //! What should I do with mobile view? 1 in a row with scroll? 9 10 let target = document.getElementById("cn-feed"); 11 12 // Watch for changes inside the div 13 let observer = new MutationObserver(function(mutations) { 14 if (jQuery("#cn-feed").html().trim() !== "" ) { 15 // Add dots to the bottom. 16 jQuery("#cn-feed").after('<div class="dots" id="dots"></div>'); 17 18 let $scrollBox = jQuery("#cn-feed"); 19 let $items = $scrollBox.find(".feedbox"); 20 let $itemwidth = parseInt(jQuery('#cn-feed .feedbox#1').width()) + parseInt(jQuery('#cn-feed .feedbox#1').css('margin-right')); 21 let $dots = jQuery('#dots'); 22 // Create dots - We do not need as many as we can see... Only n-x where (x = how many visible -1) 23 $items.each(function(i) { 24 $dots.append('<span class="dot" data-index="'+i+'"></span>'); 25 }); 26 27 // Activate first dot 28 $dots.find(".dot").first().addClass("active"); 29 30 // Dot click navigation 31 $dots.on("click", ".dot", function() { 32 let index = jQuery(this).data("index"); 33 let scrollTo = $itemwidth*index; 34 $scrollBox.animate({scrollLeft: scrollTo}, 400); 35 }); 36 37 // Update active dot on scroll 38 $scrollBox.on("scroll", function() { 39 let scrollLeft = $scrollBox.scrollLeft(); 40 let index = Math.round(scrollLeft / $itemwidth); 41 $dots.find(".dot").removeClass("active").eq(index).addClass("active"); 42 }); 43 44 // run your script here 45 observer.disconnect(); // stop observing after first trigger 46 } 47 }); 48 49 observer.observe(target, { childList: true, subtree: true }); 50 51});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.