This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
if (stop === 1 || stop === 90) { | |
start = 0; | |
stop = 60; | |
setDarkMode(true) // here | |
} else { | |
start = 60; | |
stop = 90; | |
setDarkMode(false) // and here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
import styles from './App.module.css'; | |
function App() { | |
const [darkMode, setDarkMode] = useState(false) // here | |
const [sequence, setSequence] = useState({ | |
segments: [0, 1], | |
forceFlag: true | |
}) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react'; | |
import Lottie from 'react-lottie-segments'; | |
import animationData from './lotties/toggle.json'; | |
import styles from './App.module.css'; // here | |
//... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.App { | |
text-align: center; | |
min-height: 100vh; | |
transition: background-color 1s; | |
} | |
.darkBg { | |
background-color: #282c34; | |
} | |
.lightBg { | |
background-color: #fff; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const animate = () => { | |
let start = sequence.segments[0]; | |
let stop = sequence.segments[1]; | |
// do stuff here | |
setSequence({ | |
segments: [start, stop], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
const options = { | |
loop: false, | |
autoplay: false, | |
animationData: animationData, | |
rendererSettings: { | |
preserveAspectRatio: "xMidYMid slice" | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
const options = { | |
loop: false, | |
autoplay: false, | |
animationData: animationData, | |
rendererSettings: { | |
preserveAspectRatio: "xMidYMid slice" | |
} | |
}; |
NewerOlder