/**
 * 
 * Gif parser by @gtk2k
 * https://github.com/gtk2k/gtk2k.github.io/tree/master/animation_gif
 *
 */

exports.parseGIF = function (gif, successCB, errorCB) {

  var pos = 0;
  var delayTimes = [];
  var loadCnt = 0;
  var graphicControl = null;
  var imageData = null;
  var frames = [];
  var loopCnt = 0;
  if (gif[0] === 0x47 && gif[1] === 0x49 && gif[2] === 0x46 && // 'GIF'
    gif[3] === 0x38 && gif[4] === 0x39 && gif[5] === 0x61) { // '89a'
    pos += 13 + (+!!(gif[10] & 0x80) * Math.pow(2, (gif[10] & 0x07) + 1) * 3);
    var gifHeader = gif.subarray(0, pos);
    while (gif[pos] && gif[pos] !== 0x3b) {
      var offset = pos, blockId = gif[pos];
      if (blockId === 0x21) {
        var label = gif[++pos];
        if ([0x01, 0xfe, 0xf9, 0xff].indexOf(label) !== -1) {
          label === 0xf9 && (delayTimes.push((gif[pos + 3] + (gif[pos + 4] << 8)) * 10));
          label === 0xff && (loopCnt = gif[pos + 15] + (gif[pos + 16] << 8));
          while (gif[++pos]) pos += gif[pos];
          label === 0xf9 && (graphicControl = gif.subarray(offset, pos + 1));
        } else { errorCB && errorCB('parseGIF: unknown label'); break; }
      } else if (blockId === 0x2c) {
        pos += 9;
        pos += 1 + (+!!(gif[pos] & 0x80) * (Math.pow(2, (gif[pos] & 0x07) + 1) * 3));
        while (gif[++pos]) pos += gif[pos];
        var imageData = gif.subarray(offset, pos + 1);
        frames.push(URL.createObjectURL(new Blob([gifHeader, graphicControl, imageData])));
      } else { errorCB && errorCB('parseGIF: unknown blockId'); break; }
      pos++;
    }
  } else { errorCB && errorCB('parseGIF: no GIF89a'); }
  if (frames.length) {

    var cnv = document.createElement('canvas');      
    var loadImg = function () {
      frames.forEach(function (src, i) {
        var img = new Image();
        img.onload = function (e, i) {
          if (i === 0) {
            cnv.width = img.width
            cnv.height = img.height
          }
          loadCnt++;
          frames[i] = this;
          if (loadCnt === frames.length) {
            loadCnt = 0;
            imageFix(1);
          }
        }.bind(img, null, i);
        img.src = src;
      });
    }
    var imageFix = function (i) {
      var img = new Image();
      img.onload = function (e, i) {
        loadCnt++;
        frames[i] = this;
        if (loadCnt === frames.length) {
          cnv = null;
          successCB && successCB(delayTimes, loopCnt, frames);
        } else {
          imageFix(++i);
        }
      }.bind(img);
      img.src = cnv.toDataURL('image/gif');
    }
    loadImg();
  }
}
@@ -1400,20 +1400,82 @@
     
+var 
 frame
-s.push(
+ = %7B%0A          disposalMethod: graphicControl%5B3%5D;%0A          blob:
 URL.
@@ -1539,16 +1539,52 @@
 eData%5D))
+%0A        %7D%0A        frames.push(frame
 );%0A     
@@ -1847,40 +1847,45 @@
    f
-rames.forEach(function (src, i) 
+or(var i = 0; i %3C frames.length; i++)
 %7B%0A  
@@ -2261,19 +2261,30 @@
 g.src = 
-src
+frames%5Bi%5D.blob
 ;%0A      
@@ -2284,18 +2284,16 @@
 %0A      %7D
-);
 %0A    %7D%0A 

Update Frame Structure to control Disposal Method