Skip to content

Instantly share code, notes, and snippets.

View marshallmurphy's full-sized avatar

Tyler Marshal Murphy marshallmurphy

  • Apply Digital
  • Calgary, Alberta
View GitHub Profile
//...
return (
<div className={`${styles.App} + ' ' + ${darkMode ? styles.darkBg : styles.lightBg}`}> // here
<div onClick={() => animate()}>
<Lottie
options={defaultOptions}
height={400}
width={400}
isClickToPauseDisabled={true}
playSegments={sequence}
//...
if (stop === 1 || stop === 90) {
start = 0;
stop = 60;
setDarkMode(true) // here
} else {
start = 60;
stop = 90;
setDarkMode(false) // and here
//...
import styles from './App.module.css';
function App() {
const [darkMode, setDarkMode] = useState(false) // here
const [sequence, setSequence] = useState({
segments: [0, 1],
forceFlag: true
})
import React, { useState } from 'react';
import Lottie from 'react-lottie-segments';
import animationData from './lotties/toggle.json';
import styles from './App.module.css'; // here
//...
.App {
text-align: center;
min-height: 100vh;
transition: background-color 1s;
}
.darkBg {
background-color: #282c34;
}
.lightBg {
background-color: #fff;
const animate = () => {
let start = sequence.segments[0];
let stop = sequence.segments[1];
if (stop === 1 || stop === 90) {
start = 0;
stop = 60;
} else {
start = 60;
stop = 90;
const animate = () => {
let start = sequence.segments[0];
let stop = sequence.segments[1];
// here
if (stop === 1 || stop === 90) {
start = 0;
stop = 45;
} else {
start = 45;
const animate = () => {
let start = sequence.segments[0];
let stop = sequence.segments[1];
// do stuff here
setSequence({
segments: [start, stop],
//...
const options = {
loop: false,
autoplay: false,
animationData: animationData,
rendererSettings: {
preserveAspectRatio: "xMidYMid slice"
}
};
//...
const options = {
loop: false,
autoplay: false,
animationData: animationData,
rendererSettings: {
preserveAspectRatio: "xMidYMid slice"
}
};