ericandrewlewis / emoji-mosaic

Other
711 stars 131 forks source link

Duplicate DOM elements when upload multiple pictures in order #8

Open hijiangtao opened 5 years ago

hijiangtao commented 5 years ago

I found it will not remove the older DOM element when I upload a new picture for generating a new emoji-mosaic picture.

Maybe you should change this line a little bit, https://github.com/ericandrewlewis/emoji-mosaic/blob/master/index.html#L112

Just don't generate a canvas element each time, but keep a reference of it when it first generated, so that you can utilize it and just clear it each time you need to re-paint a new picture, codes like this way:

const gl = canvasEl.getContext('webgl');
gl.clearColor(1.0, 1.0, 1.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT);

And thanks for the idea! It's really interesting by the way! :-)

AmbitiousK commented 5 years ago

Keep going, man!