Dispose frame error

import "https://zimjs.org/cdn/020/zim";
import GUI from 'https://cdn.jsdelivr.net/npm/lil-gui@0.21/+esm';
var tempZimFrame = null;
var guiD = {
  makeZimFrame: function () {
    tempZimFrame = new Frame({
      scaling: "fit",
      color: "#03f",
      outerColor: black
    });
    clearBtn.show();
    makeBtn.hide();
  },
  clearZimFrame: function () {
    tempZimFrame.dispose();
    tempZimFrame = null;
    clearBtn.hide();
    makeBtn.show();
  }
};
var debugGui = new GUI({ title: "调试" });
var makeBtn = debugGui.add(guiD, "makeZimFrame").name("make||创建").show();
var clearBtn = debugGui.add(guiD, "clearZimFrame").name("clear||清除").hide();

if dispose frame then have error
image

import "https://zimjs.org/cdn/020/zim";
new Frame(FIT, 1024, 768, light, dark, ready);
function ready() {

	timeout(2, ()=>{
		F.dispose();
		F = null;
	});
		
}

works fine for us. (Works storing the Frame in let f = and disposing and nullifying that too)

Not sure where the loc_ZIM.js is... Do you possibly have another ZIM running?

image
the error be reported when i use gui,

loc_ZIM.js is my local host file name.
the error be reported when use gui dispose frame.

Oh - maybe because ZIM Frame is passed into the GUI and then you set the Frame to null - so the GUI is trying to access something on null?

no,in ZIM018,no the error.
import "https://zimjs.org/cdn/018/zim.js";

I find the problem ,in zimjs.org/cdn/020/zim_doc.js

1 Like

Ah... interesting. So the event is firing as you press to dispose. And then it disposes and we run the timeout. Okay - we think that is fixed. Cheers. Clear your cache, try it out and let us know.

1 Like

that ok, :white_check_mark:

2 Likes