Meta
Meta

Reputation: 425

Move HTML Canvas by javascript

I'm trying to copy element from one in my page to another (via javascript). It's successfully copied but appeared empty.

How to copy/move canvas with content?

Upvotes: 1

Views: 1431

Answers (1)

Fabien Ménager
Fabien Ménager

Reputation: 140185

I think the spec tells that a canvas is cleared when resized, I guess it is the same when cloned in the DOM too. So you need to get the image data with getImageData and put it back with putImageData

See here.

Upvotes: 2

Related Questions