Callbacks

  • onEnter – forward past “start” (typically when trigger is scrolled into view)
  • onLeave – forward past “end” (typically when trigger is scrolled out of view)
  • onEnterBack – backward past “end” (typically when trigger is scrolled back into view)
  • onLeaveBack – backward past “start” (typically when trigger goes backward out of view)
  • onUpdate – every time the scroll position changes while between “start” and “end”.
  • onToggle – passes the start or end in either direction
  • onRefreshInit – immediately before measurements are recalculated (typically on resize)
  • onRefresh – after measurements are recalculated (typically on resize)

When this panel’s top edge reaches 100px from the top of the viewport, the ScrollTrigger will start (start: "top 100px"), then end when its bottom is 100px from the bottom of the viewport (end: "bottom bottom-=100px"). Callbacks are logged to the right, and progress below:

progress: 0

All callbacks receive one parameter – the ScrollTrigger instance itself which has properties like progressdirection, and isActive.