Martinomagnifico / reveal.js-appearance

An animation plugin for Reveal.js that animates elements sequentially like in Powerpoint. Perfect for online portfolios or other presentations with images.
https://martinomagnifico.github.io/reveal.js-appearance/demo/demo.html
MIT License
104 stars 13 forks source link

Does not work within iframe #2

Closed sp71 closed 5 years ago

sp71 commented 5 years ago

I'm putting my reveal presentation within an iframe. All the plugins work for me except for this. Maybe because some event is not being captured because of the iframe? It works fine when there is no iframe. Any suggestions?

sp71 commented 5 years ago

Found the issue. Within appearance init, I saw the following lines

window.addEventListener("slidechangecomplete", showHideSlide, false);
window.addEventListener("fragmentshowncomplete", showHideFragment, false);
window.addEventListener("fragmenthiddencomplete", showHideFragment, false);

I fixed it by doing the following in apperance.js:

window.parent.addEventListener("slidechangecomplete", showHideSlide, false);
window.parent.addEventListener("fragmentshowncomplete", showHideFragment, false);
window.parent.addEventListener("fragmenthiddencomplete", showHideFragment, false);

Would be good to also consider iframe for other users of this repo. Any chance something like this could be added in?

Possible solution

var isIFramed = window.parent !== window.self
var win = isIFramed ? window.parent : window
win.parent.addEventListener("slidechangecomplete", showHideSlide, false);
win.parent.addEventListener("fragmentshowncomplete", showHideFragment, false);
win.parent.addEventListener("fragmenthiddencomplete", showHideFragment, false);
Martinomagnifico commented 5 years ago

Thanks for the heads up! I'll look into the issue later this week.

Martinomagnifico commented 5 years ago

Hi Satinder, the issue was not in Appearance, but in Transit.js, which tracks if a Reveal transition has really ended. I've changed it there, so you should be good to go now. Thanks!