Skip to content

scrollToY

Mike Byrne edited this page Jan 25, 2022 · 2 revisions

description

Scroll to a y position

requires

  • nothing

parameters

options object:

  • options.el - required - node or document to scroll
  • options.offset - required - number, final scroll to position
  • options.duration - optional - ms, defaults to 250
  • options.easing - optional - "linear" (default) | "easeIn" | "easeOut" | "easeInOut"
  • options.onComplete - optional - function to run on complete

returns

  • nothing

example usage:

scrollToY({
  el: document,
  offset: 1000,
  duration: 250,
  easing: "linear"
});
scrollToY({
  el: document.getElementById("scroll_div"),
  offset: getOffset(document.getElementById("scrollable_content_bottom")).top,
  duration: 500,
  easing: "easeInOut",
  onComplete: function(){
    console.log("complete!");
  }
});