dasmoth / dalliance

Interactive web-based genome browser.
http://www.biodalliance.org/
BSD 2-Clause "Simplified" License
227 stars 68 forks source link

Onload Event & localStorage #21

Closed greenexile4568 closed 10 years ago

greenexile4568 commented 13 years ago

When Browser javascript function is invoked it adds a listener to the page onload event. For standard alone pages this is okay but for apps where the browser is loaded as a plugin, the page load event may not fire.

Just a suggestion, but it maybe better to leave the invocation of the browser to the caller and not assume which event they may wish to use to trigger the actual rendering of the browser.

On the same topic, if the browser is deployed within a div on a larger page it appears you have to flush localStorage otherwise the browser has a 'fit' if you try to refresh/reload it insitu. ( admittedly some of this behavior may be the result of the application I'm trying to embed the browser)

p.s.

Would like to commend you on a great piece of work !

dasmoth commented 13 years ago

I'm guessing you're creating the Browser object after the onload event has already fired? (i.e. probably in an event handler, rather than in a top-level script?). I'll see if I can find a fix that doesn't break the current API (maybe check to see if the onload event has already fired?). In the mean time, you should be able to work around this using something like:

           Browser b = new Browser{/*config*/};
           b.realInit();

I'm not totally sure what you mean by "flushing localStorage", please could you give an example?

greenexile4568 commented 13 years ago

Aye, thats pretty much how I worked around the issue.

The app I'm using has a pugin frame work that calls an init function when loading a plugin and a unload function when user selects another plugin within the interface. When the latter is invoked I call

localstorage.clear

This removes any data added by dalliance. If the user then reloads the dalliance from the same browser/app session the browser has nothing in localstorage and loads correctly.

If I don't do this it looks like (I haven't had time to look indepth) the browser starts creating multiple tracks - almost seems like it gets suck in a recursive loop whch eventually leaves Firefox session unusable.

On 18 August 2011 04:11, dasmoth < reply@reply.github.com>wrote:

I'm guessing you're creating the Browser object after the onload event has already fired? (i.e. probably in an event handler, rather than in a top-level script?). I'll see if I can find a fix that doesn't break the current API (maybe check to see if the onload event has already fired?). In the mean time, you should be able to work around this using something like:

          Browser b = new Browser{/*config*/};
          b.realInit();

I'm not totally sure what you mean by "flushing localStorage", please could you give an example?

Reply to this email directly or view it on GitHub: https://github.com/dasmoth/dalliance/issues/21#issuecomment-1837176

dasmoth commented 10 years ago

Since 0.12 there has been no need to explicitly initialize newly created Browsers.

I've not been able to reproduce the issue with localStorage.