sole / Animated_GIF

Javascript library for creating animated GIFs
https://sole.github.io/Animated_GIF
225 stars 53 forks source link

old frame stay #40

Open zhenyuaf opened 3 years ago

zhenyuaf commented 3 years ago

Use addFrame or addFrameImageData for more than two image, and 'getBase64GIF' to generate the gif, result get error, the first image does not display when the second image appear.

let gif = new Animated_GIF(); for (let i = 0; i < fileList.length; i++) { let img = fileList[i]; gif.setSize(img.width, img.height); gif.addFrame(img); if (i==fileList.length-1) { gif.getBase64GIF(b64=>{ let el = document.createElement('a'); el.href = URL.createObjectURL(base64ToBlob(b64)); el.download = 'file.gif'; document.body.appendChild(el); let evt = document.createEvent("MouseEvents"); evt.initEvent("click", false, false); el.dispatchEvent(evt); document.body.removeChild(el); }) } }