1function ueScrollMarquee(){ 2 3 //classes 4 5 //selectors 6 7 8 //objects 9 var g_objWidget, g_objWrapper, g_objVideoPlayIcons, g_objVideoCovers; 10 11 //helpers 12 var g_widgetId, g_itemsArray, g_widgetsOptions, g_speed, g_direction, g_offset, g_widgetTop, g_isUpdating, g_nextTranslateX; 13 14 /** 15 * Apply the transform in sync with the browser's repaint 16 */ 17 function updateMarquee() { 18 g_objWrapper[0].style.transform = 'translateX(' + (g_nextTranslateX) + 'px) translateZ(0)'; 19 20 g_isUpdating = false; // Reset the flag 21 } 22 23 /** 24 * on page scroll 25 */ 26 function onScroll(){ 27 var scrollY = jQuery(this).scrollTop(); 28 var windowHeight = jQuery(window).height(); 29 30 // 1. Define Vertical Scroll Boundaries (using g_widgetHeight, which must be in init) 31 var scrollStart = g_widgetTop - windowHeight; 32 var scrollEnd = g_widgetTop + g_widgetHeight + 200; 33 var animationRange = scrollEnd - scrollStart; // Total vertical distance for the effect 34 35 // 2. Calculate the raw scroll progress 36 var relativeScroll = scrollY - scrollStart; 37 38 // 3. Clamp the vertical scroll progress: 39 var effectiveScroll = Math.max(0, relativeScroll); // Lower Bound (Start) 40 // Upper Bound (End of visibility) - This is the ONLY clamp based on vertical scroll 41 effectiveScroll = Math.min(animationRange, effectiveScroll); 42 43 // 4. Calculate the horizontal movement distance 44 45 // The total horizontal travel distance is simply the effective vertical scroll scaled by speed. 46 // When effectiveScroll = animationRange, this gives the total horizontal distance covered. 47 var totalHorizontalMovement = effectiveScroll * g_speed; 48 49 // 5. Calculate the final translation (translateX) 50 var direction = (g_direction == "right") ? 1 : -1; 51 52 var translateX; 53 54 // Start Position: This is where the marquee starts (often the required offset) 55 if (g_direction === "left") { 56 // Start from the desired offset (pushed right) 57 var startPosition = g_offset; 58 59 // Subtract the movement to scroll further left 60 translateX = startPosition - totalHorizontalMovement; 61 62 } else { // g_direction === "right" 63 // Start from the desired offset (pushed right) 64 var startPosition = g_offset; 65 66 // Add the movement to scroll further right 67 translateX = startPosition + totalHorizontalMovement; 68 } 69 70 g_nextTranslateX = translateX; 71 72 // 6. Final CSS Application 73 if (g_isUpdating == false) { 74 g_isUpdating = true; 75 window.requestAnimationFrame(updateMarquee); 76 } 77 } 78 79 /** 80 * on video cover click 81 */ 82 function onVideoCoverClick(objVideoPlayIcon){ 83 var objVideCover = jQuery(this); 84 85 if(objVideoPlayIcon && objVideoPlayIcon.length > 0) 86 objVideCover = objVideoPlayIcon.prev(); 87 88 var objParentItem = objVideCover.closest(".ue-scroll-marquee-item"); 89 var poster = objVideCover.attr("poster"); 90 var title = objVideCover.data("title"); 91 var videoType = objVideCover.data("type"); 92 var videoUrl = objVideCover.data("link").trim(); 93 var videoHTML; 94 95 if(videoType == "self") 96 videoHTML = '<video class="ue-scroll-marquee-item-video" src="'+videoUrl+'" controls autoplay poster="'+poster+'" ></video>'; 97 98 if(videoType == "youtube") 99 videoHTML = '<iframe class="ue-scroll-marquee-item-video" src="https://www.youtube.com/embed/'+videoUrl+'?autoplay=1" title="'+title+'" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'; 100 101 if(videoType == "vimeo") 102 videoHTML = '<iframe class="ue-scroll-marquee-item-video" src="https://player.vimeo.com/video/'+videoUrl+'?autoplay=1&title=0&byline=0&portrait=0" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe>'; 103 104 objParentItem.addClass("ue-scroll-marquee-item-video-active"); 105 objParentItem.append(videoHTML) 106 } 107 108 /** 109 * on video cover click 110 */ 111 function onVideoPlayIconClick(){ 112 var objVideoPlayIcon = jQuery(this); 113 114 onVideoCoverClick(objVideoPlayIcon); 115 } 116 117 /** 118 * init from external file 119 */ 120 this.init = function(options){ 121 //init vars 122 g_itemsArray = options.items; 123 g_widgetsOptions = options.widgetsOptions; 124 g_widgetId = g_widgetsOptions.uc_id; 125 g_speed = Number(g_widgetsOptions.speed); 126 g_direction = g_widgetsOptions.direction; 127 g_offset = Number(g_widgetsOptions.offset); 128 129 //classes 130 131 //selectors 132 133 134 //objects 135 g_objWidget = jQuery('#'+g_widgetId); 136 g_objWrapper = g_objWidget.find(".uc-items-wrapper"); 137 g_objVideoCovers = g_objWidget.find(".ue-scroll-marquee-item-video-cover"); 138 g_objVideoPlayIcons = g_objWidget.find(".ue-scroll-marquee-item-video-play-icon"); 139 140 141 //helpers 142 g_widgetTop = g_objWidget.offset().top; 143 g_widgetHeight = g_objWidget.outerHeight(); 144
145 g_wrapperWidth = g_objWrapper.outerWidth(); 146 g_viewportWidth = jQuery(window).width(); 147 148 // The difference between wrapper width and viewport width (this is the minimum required travel) 149 g_scrollDiff = g_wrapperWidth - g_viewportWidth; 150 151 // Total horizontal distance the wrapper needs to travel (including offsets on both ends) 152 g_maxTravel = g_scrollDiff + (2 * g_offset); 153 g_maxScroll = g_maxTravel / g_speed; 154 g_isUpdating = false; 155 g_nextTranslateX = 0; 156 157 onScroll(); 158 159 //init events 160 jQuery(window).on("scroll", onScroll); 161 g_objVideoPlayIcons.on("click", onVideoPlayIconClick); 162 g_objVideoCovers.on("click", onVideoCoverClick); 163 } 164}
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.