• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Hiding and showing a playbar button with Javascript

Contributor ,
Sep 07, 2020 Sep 07, 2020

Copy link to clipboard

Copied

I want to hide the "Forward" button on the playbar when on the last slide of the project, but show it again should the user navigate back to another topic. In the browser console I can toggle the Forward button between visible and hidden using:

var btnFwd=document.getElementById('Forward');
btnFwd.style.visibility='visible';

and

var btnFwd=document.getElementById('Forward');
btnFwd.style.visibility='hidden';

respectively.

I have therefore added the corresponding code to the slide On Enter and On Exit actions. The button hides on slide entry but does not display when navigating to another slide. I have tried adding a short delay before the code executes but that makes no difference.

Can anyone shed any light on this? I have worked around it by adding some code to the On Enter advanced action of the other slides that checks if the button is visible and if not displays it, but I would like to understand why this is happening.

TOPICS
Advanced

Views

301

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 09, 2020 Sep 09, 2020

Copy link to clipboard

Copied

You would likely need the show script for all the other slides or at least the previous to final slide if you only allow linear navigation. The reason is the on exit action of the final slide is seldom run. Navigating away from the slide doesn't run the on exit action. The on exit action is run if the slide plays through to the very end of the slide without being interrupted by click boxes, buttons or the user clicking on the playbar to navigate away. 

Paul Wilson, CTDP

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 11, 2020 Sep 11, 2020

Copy link to clipboard

Copied

Thanks Paul for the explanation. The On Exit should be running in this instance because to navigate away the user would need to use the ToC or back button on the play bar. Maybe it is not run when using the ToC. Very confusing really but now I know!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Sep 11, 2020 Sep 11, 2020

Copy link to clipboard

Copied

In all of the testing I've done, onExit is actually executed on the first frame of the next slide.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 11, 2020 Sep 11, 2020

Copy link to clipboard

Copied

Not sure, David. I definitely recommend to avoid the On Exit action.  In some of the Quick Start Projects it is used to pause the slide. And it will pause on the present slide with the content of the last frame. Although I also think the action, if it works correctly, is done right fater the last frame.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 11, 2020 Sep 11, 2020

Copy link to clipboard

Copied

I think I read/heard Rod Ward saying the same thing.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 11, 2020 Sep 11, 2020

Copy link to clipboard

Copied

LATEST

That is very possible...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Sep 11, 2020 Sep 11, 2020

Copy link to clipboard

Copied

If you just want to hide it on the last slide, in your slide enter advanced actions, add a conditional tab

 

if cpInfoCurrentSlide is equal to cpInfoSlideCount

 

execute JS to hide button

 

else

 

execute JS to show button

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 11, 2020 Sep 11, 2020

Copy link to clipboard

Copied

Now that is a good idea! I shall try it.

I was trying to only execute the relevant code on the last slide, but this does make sense. Thank you 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources