site/includes/modules.js
/**
 * Updates and animates the track offset and
 * @param el The track element
 * @param dir One of -1, 0, 1 determining the direction of the scroll
 * @param loop Whether to loop the scrolling 
 * @param partial Optional
 */
Updates and animates the track offset and
@param el The track element
@param dir One of -1, 0, 1 determining the direction of the scroll
@param loop Whether to loop the scrolling
@param partial Optional
Updates and animates the track offset and @param el The track element @param dir One of - 1 0 1 determining the direction of the scroll @param loop Whether to loop the scrolling @param partial Optional
function scrollTrack(el, dir, loop, partial) {
  const total = el.find(".trackItem").length;
  const style = getComputedStyle(el.get(0));
  const visible = parseInt(style.getPropertyValue("--visible-items"));
  let offset = parseInt(style.getPropertyValue("--offset"));
  let target;
  if (partial) {
    const width = el.find(".trackItem").get(0).clientWidth;
    target = offset + Math.round(partial / width);
  } else {
    target = offset + dir * Math.max(1, partial ? 1 : visible - 1);
  }
  if (loop) {
    offset = (target % total + total) % total;
  } else {
    const endItem = total - 1 > visible;
    const maxOffset = total - visible - (endItem ? 0 : 1);
    offset = Math.max(0, Math.min(maxOffset, target));
    el.find(".trackButtonLeft").toggleClass("hidden", offset <= 0);
    el.find(".trackButtonRight").toggleClass("hidden", offset >= maxOffset);
    el.find(".trackEndItem").toggleClass("hidden", !endItem);
  }
  if (dir !== 0) el.addClass("transitioning");
  el.get(0).style.setProperty("--offset", `${offset}`);
  let trackTransition;
  if (dir !== 0) {
    clearTimeout(trackTransition);
    trackTransition = setTimeout(function(){
      el.removeClass("transitioning");
    }, 1000);
  }
}
function scrollTrack ( el , dir , loop , partial ) { const total = el . find ( ".trackItem" ) . length ; const style = getComputedStyle ( el . get ( 0 ) ) ; const visible = parseInt ( style . getPropertyValue ( "--visible-items" ) ) ; let offset = parseInt ( style . getPropertyValue ( "--offset" ) ) ; let target ; if ( partial ) { const width = el . find ( ".trackItem" ) . get ( 0 ) . clientWidth ; target = offset + Math . round ( partial / width ) ; } else { target = offset + dir * Math . max ( 1 , partial ? 1 : visible - 1 ) ; } if ( loop ) { offset = ( target % total + total ) % total ; } else { const endItem = total - 1 > visible ; const maxOffset = total - visible - ( endItem ? 0 : 1 ) ; offset = Math . max ( 0 , Math . min ( maxOffset , target ) ) ; el . find ( ".trackButtonLeft" ) . toggleClass ( "hidden" , offset <= 0 ) ; el . find ( ".trackButtonRight" ) . toggleClass ( "hidden" , offset >= maxOffset ) ; el . find ( ".trackEndItem" ) . toggleClass ( "hidden" , ! endItem ) ; } if ( dir !== 0 ) el . addClass ( "transitioning" ) ; el . get ( 0 ) . style . setProperty ( "--offset" , ` ${ offset } ` ) ; let trackTransition ; if ( dir !== 0 ) { clearTimeout ( trackTransition ) ; trackTransition = setTimeout ( function ( ) { el . removeClass ( "transitioning" ) ; } , 1000 ) ; } }
Updates and animates the track offset and
 @param el The track element
 @param dir One of -1, 0, 1 determining the direction of the scroll
 @param loop Whether to loop the scrolling
 @param partial Optional
Updates and animates the track offset and @param el The track element @param dir One of - 1 0 1 determining the direction of the scroll @param loop Whether to loop the scrolling @param partial Optional