Skip to content

Instantly share code, notes, and snippets.

View rossrangle's full-sized avatar

Ross Kelly rossrangle

View GitHub Profile
useEffect(() => {
const timeOut = setTimeout(setCurrentScene, SLIDE_CHANGE_TIME_MS);
return () => clearTimeout(timeOut);
}, [currentScene, setCurrentScene]);
const [currentScene, setCurrentScene] = useCycle(
hedgehogScene,
raccoonScene,
squirrelScene
);
import React from "react";
import { motion } from "framer-motion";
const TRANSITION_TIME_OPACITY_S = 1;
const TRANSITION_TIME_ROTATE_S = { MIN: 1.5, MAX: 2.5 };
function getRandomNumberBetween(min, max) {
return Math.floor(Math.random() * max) + min;
}
transition={{
yoyo: Infinity,
duration: 2,
ease: "easeInOut"
}}
<motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }}>
<span>This text will fade in when created in the DOM</span>
</motion.div>
import React from "react";
import { motion, AnimatePresence } from "framer-motion";
const ANIMATION_DURATION_S = 0.8;
const getVariants = (direction) => ({
initial: {
y: direction === "top" ? "-100%" : "100%",
opacity: 0,
transition: { duration: ANIMATION_DURATION_S, ease: "easeInOut" },
import React from "react";
import { motion, AnimatePresence } from "framer-motion";
const ANIMATION_DURATION_S = 0.8;
function IconHolder({ icon, text }) {
return (
<div className="icon-holder">
<AnimatePresence>
<motion.div
className="icon-holder__icon"
import React from "react";
import { motion, AnimatePresence } from "framer-motion";
const TRANSITION_TIME_OPACITY_S = 1;
const TRANSITION_TIME_ROTATE_S = { MIN: 1.5, MAX: 2.5 };
function getRandomNumberBetween(min, max) {
return Math.floor(Math.random() * max) + min;
}
import React, { useEffect } from "react";
import { useCycle } from "framer-motion";
import ImageHolder from "./ImageHolder";
import IconHolder from "./IconHolder";
import { hedgehogScene, raccoonScene, squirrelScene } from "./scenes";
const SLIDE_CHANGE_TIME_MS = 5000;
import React from "react";
import { motion } from "framer-motion";
const TRANSITION_TIME_OPACITY_S = 1;
const TRANSITION_TIME_ROTATE_S = 2;
function ImageHolder({ img, className }) {
return (
<motion.div
initial={{ opacity: 0 }}