joseph / Monocle

A silky, tactile browser-based ebook JavaScript library.
http://monocle.inventivelabs.com.au
MIT License
743 stars 200 forks source link

Get active iframe on componentchanging event? #257

Closed f1nnix closed 9 years ago

f1nnix commented 9 years ago

As I got, Monocle operates with two iframes evenly. One for current active component, second (hidden) for content preloading or something about this. Correct me please, if I'm wrong.

I'm interested if it's possible to get current active iframe inside callback of componentchange event? The reason I want to do this is that I bind several events to contents of iframe:0 (maybe 0 is a bad idea) on componentchange event, and when active iframe changed, I need to unbind all events from old iframe and bind them to a new one.

Not sure, but unbinding should be performed on monocle:componentchanging, and new biding on monocle:componentchange, yeah? The question is, how to get one particular iframe to bind/unbind something on these events firied.

Any help is highly appreciated, thank you in advance.

joseph commented 9 years ago

Yes, it uses two iframes, 0 and 1 - if you use the standard flipper, which it sounds like you do. 0 and 1 are flipped as necessary, there's no real difference between them. If you want to find the one that is currently topmost, you can use reader.visiblePages()[0]. If you want to find the one in a componentchanging event that is about to get a new src, use evt.m.pageDiv.m.activeFrame. Or something like that.

f1nnix commented 9 years ago

@joseph brilliant, thank you very much!