Skip to content

Instantly share code, notes, and snippets.

View clauderic's full-sized avatar

Claudéric Demers clauderic

View GitHub Profile
@clauderic
clauderic / animate.js
Last active October 20, 2022 03:50
Smooth scrolling to a given offset in React Virtualized
/**
* Smoothly animate between two values
* @param {Number} fromValue - the initial value
* @param {Function} onUpdate - A function that is called on each tick
* @param {Function} onComplete - A callback that is fired once the scroll animation ends
* @param {Number} duration - the desired duration of the scroll animation
*/
export default function animate({
fromValue,
toValue,
@clauderic
clauderic / index.js
Last active February 13, 2019 18:02
Conditional rendering in React Virtualized based on Scroll Speed
import React, {PureComponent} from 'react';
import {List} from 'react-virtualized';
import debounce from 'lodash/debounce';
class ScrollSpeed {
clear = () => {
this.lastPosition = null;
this.delta = 0;
};
getScrollSpeed(scrollOffset) {