save code

This commit is contained in:
canzit 2023-01-16 10:59:02 +03:00
parent a57be83351
commit 721c967ac8
3 changed files with 8 additions and 4 deletions

View File

@ -7,6 +7,10 @@ canvas {
margin: auto; margin: auto;
display: block; display: block;
} }
/*main{
height: 300px;
}*/
.content { .content {
position: relative; position: relative;
padding: 20px; padding: 20px;

View File

@ -2,14 +2,12 @@ import './App.css';
import ImageCanvas from './imageCanvas' import ImageCanvas from './imageCanvas'
const App = () => ( const App = () => (
<main>
<ImageCanvas <ImageCanvas
scrollHeight={3500} scrollHeight={3500}
width={1440} width={1440}
height={1440} height={1440}
numFrames={241} numFrames={240}
/> />
</main>
); );
export default App; export default App;

View File

@ -52,9 +52,11 @@ const ImageCanvas = ({scrollHeight, numFrames, width, height}) => {
return; return;
} }
if(frameIndex == 241) return
const context = canvasRef.current.getContext("2d"); const context = canvasRef.current.getContext("2d");
let requestId; let requestId;
console.log(frameIndex)
const render = () => { const render = () => {
context.drawImage(images[frameIndex], 0, 0); context.drawImage(images[frameIndex], 0, 0);
requestId = requestAnimationFrame(render); requestId = requestAnimationFrame(render);