Skip to content
Snippets Groups Projects
  • Eugen Rochko's avatar
    8ee2eb5d
    Allow mounting arbitrary columns (#3207) · 8ee2eb5d
    Eugen Rochko authored
    * Allow mounting arbitrary columns
    
    * Refactor column headers, allow pinning/unpinning and moving columns around
    
    * Collapse animation
    
    * Re-introduce scroll to top
    
    * Save column settings properly, do not display pin options in
    single-column view, do not display collapse icon if there is
    nothing to collapse
    
    * Fix one instance of public timeline being closed closing the stream
    Fix back buttons inconsistently sending you back to / even if history exists
    
    * Getting started displays links to columns that are not mounted
    8ee2eb5d
    History
    Allow mounting arbitrary columns (#3207)
    Eugen Rochko authored
    * Allow mounting arbitrary columns
    
    * Refactor column headers, allow pinning/unpinning and moving columns around
    
    * Collapse animation
    
    * Re-introduce scroll to top
    
    * Save column settings properly, do not display pin options in
    single-column view, do not display collapse icon if there is
    nothing to collapse
    
    * Fix one instance of public timeline being closed closing the stream
    Fix back buttons inconsistently sending you back to / even if history exists
    
    * Getting started displays links to columns that are not mounted
scroll.js 645 B
const easingOutQuint = (x, t, b, c, d) => c * ((t = t / d - 1) * t * t * t * t + 1) + b;

const scrollTop = (node) => {
  const startTime = Date.now();
  const offset    = node.scrollTop;
  const targetY   = -offset;
  const duration  = 1000;
  let interrupt   = false;

  const step = () => {
    const elapsed    = Date.now() - startTime;
    const percentage = elapsed / duration;

    if (percentage > 1 || interrupt) {
      return;
    }

    node.scrollTop = easingOutQuint(0, elapsed, offset, targetY, duration);
    requestAnimationFrame(step);
  };

  step();

  return () => {
    interrupt = true;
  };
};

export default scrollTop;