Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
if (changeInY > 0 && restraints.down !== null) {
const dampFactor =
1 -
linearScale({
domain: [0, restraints.down * 2],
range: [0, 0.5],
value: changeInY,
});
let dampedChangeInY = changeInY * dampFactor;
if (dampedChangeInY > restraints.down) {
dampedChangeInY = restraints.down;
}
changeInY = dampedChangeInY;
} else if (changeInY < 0) {
if (typeof restraints.up === 'number') {
const dampFactor =
1 -
linearScale({
domain: [0, -restraints.up * 2],
range: [0, 0.5],
value: changeInY,
});
let dampedChangeInY = changeInY * dampFactor;
if (dampedChangeInY < -restraints.up) {
dampedChangeInY = -restraints.up;
}
changeInY = dampedChangeInY;
} else if (restraints.up === 'drag') {
const absoluteChange = Math.abs(changeInY);
changeInY = -Math.pow(absoluteChange, 0.7);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.