Answer the question
In order to leave comments, you need to log in
How to make an infinite canvas effect?
I found a way, the canvas is increased in the scroll event handler by the amount of the scroll. Is there any other better option?
Answer the question
In order to leave comments, you need to log in
Take a canvas larger than the screen, up to twice the width and height.
When scrolling, you move the canvas. As soon as you get close to the border, add a new canvas of the same size on the other side. Move both canvases around until the first one is out of sight and you can safely remove it.
With this approach, two canvases are enough if you have one-axis movement, and four if you have two-axis movement.
You can imagine that Google Maps has an infinite canvas. But it's not a giant picture, it's a bunch of little pictures. Just then you need to finish the necessary pieces after the scroll.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question