Skip to content

Instantly share code, notes, and snippets.

View piotr-gawlowski's full-sized avatar

Piotr Gawlowski piotr-gawlowski

View GitHub Profile

Keybase proof

I hereby claim:

  • I am piotr-gawlowski on github.
  • I am d3vilroot (https://keybase.io/d3vilroot) on keybase.
  • I have a public key ASCpTHuxBxfxRC07S2osZxt1k2Aaju8W8h-kM60PTsLEyAo

To claim this, I am signing this object:

@piotr-gawlowski
piotr-gawlowski / syncScroll.js
Created June 26, 2018 12:28
Synchronize scroll position of array of dom elements
// synchronize scrollTop value between multiple dom elements
export const syncScroll = elements => {
const syncElements = (collection, value) => {
collection.forEach(item =>
item.el.scrollTop = (item.el.scrollHeight - item.el.clientHeight) * value,
);
};
const handleNativeScroll = ({currentTarget}) => {
const v = currentTarget.scrollTop / (currentTarget.scrollHeight - currentTarget.clientHeight);