Skip to content

Instantly share code, notes, and snippets.

@cladley
cladley / foldable.js
Created May 21, 2019 11:25
Folding image effect using react spring
import React from 'react';
import {useSpring, animated, config} from 'react-spring';
import Slider from './Slider';
const convertPercentageToRotation = percentage => {
return percentage * 1.8;
}
function norm(value, min, max) {
return (value - min) / (max - min);
@cladley
cladley / isInParent.js
Created February 21, 2020 09:03
Check if dom node is contained in parent node
/**
* Determines if html element is
* contained within other html element
*
* @param {HTMLElement} refNode
* @param {HTMLElement} otherNode
*/
const isParent = (refNode, otherNode) => {
var parent = otherNode.parentNode;
do {