Okay
  Public Ticket #1936857
Changing to slide 1 using API does not always work for me
Closed

Comments

  • mennoluitjes started the conversation

    Hi there! I'm the developer of Foyer - Digital Signage for WordPress.

    https://wordpress.org/plugins/foyer/

    http://demo.foyer.tv/

    I'm trying to add LayerSlider support to my plugin, so users can add those amazing LayerSlider slideshows to their Foyer slideshows.

    I'm using your JavaScript API intensively to start and stop the LayerSlider slideshow and its layers. I'm running into one problem though! I can't explain it, so I hope you can.

    The problem occurs when working with one of your demos, the Carousel with Darth Vader, Yoda, etc. -- see screenshot.

    After I paused this slideshow when it is exactly in between changing slides (so busy sliding from Darth Vader to Yoda ;-)), I can not make the slideshow jump to the first slide.

    It can be reproduced on a page that includes this Carousel slideshow, like this..

    <?php layerslider( 1, '', array( 'autostart' => false, 'pauseLayers' => true ) ); ?>

    ..plus two buttons named Start and Stop that call the JavaScript functions below:

    function ls_start() {

     jQuery('#layerslider_1').layerSlider('startSlideshow').layerSlider(1).layerSlider('resetSlide').layerSlider('resumeSlider');

     return false;

    }

    function ls_stop() {

     jQuery('#layerslider_1').layerSlider('pauseSlider').layerSlider('stopSlideshow');

     return false;

    }

    What happens after clicking Stop when in between two slides, then clicking Start is that the slideshow just continues transitioning from Darth Vader to Yoda. I would have expected it to jump to the first slide (Darth Vader) and play the slideshow from the start. When I click Stop after the slideshow has changed slides from Darth Vader to Yoda, then Start, everything works as I would expect.

    So.. What I need is a way to pause a slideshow and its layers (freeze it directly and completely) -- this seems to work. And secondly I need a way to make the paused slideshow and its layers jump to its starting position (so the first slide) and start playing again.

    Is this possible?

    Bonus would be if the slideshow would start playing exactly the same way as when it started playing for the first time (so no transition from slide 2 to slide 1, but immediately start with slide 1 and its opening transition).

    Any suggestions?

    Thanks in advance!
    Menno

  • mennoluitjes replied

    PS. Using LayerSlider 6.8.1, WordPress 5.1.1, Google Chrome 72.

  • [deleted] replied

    Hello Menno,

    Thank you for getting in touch with us. My name is Attila and I'm happy to assist you today.

    I would like to confirm that we have received your message. Due to the nature of your query, I will have to contact and consult with the development team first. I will get back to you as soon as I can.

    We appreciate your patience while we're working towards your ticket.

  • [deleted] replied

    Thank you for your patience. 

    If we understood it correctly, the problem is that you are trying to change slide during another slide change. This is not allowed in the plugin due to certain timing settings and callbacks.

    But you could use the API to correct this. You will need to use the API functions to detect when there is an active slide change in the process, wait for it to end, and only call the rest of the commands then.

  • mennoluitjes replied

    Hi Attila,

    Thanks for coming back to me!

    You are correct, I would like the slideshow to change to another slide. Whenever I desire, using the API. For example..

    jQuery('#layerslider_1').layerSlider(1);

    So if I understand correctly this is not always possible? There are certain moments in the life of a slideshow when this will not work? This explains what I encountered :-)

    I have studied the API documentation, and used the API quite a lot, but don't see this -slider-is-busy-wait-for-it- documented. Could you point me in the right direction?

    What API slider property indicates a slide change is in progress? What API event should I then use to wait for the slide change to end, so API methods such as .layerslider(1) will work again? Alternatively, is there a way to just skip the slide change in progress, bringing it to its end point immediately, so API methods will work straight away?

    The full scope of what I'm trying to do with the API:

    - Situation A: Detect when the playing slideshow reached the last slide and all animations on the last slide finished, then stop slideshow and animations (so: no slide change or transition from last slide to first slide).

    - Situation B: Stop playing slideshow and animations at any desired moment.

    - At some random point in time: Restart the slideshow (from the end state of situation A or B) at the first slide as if the slideshow is playing for the first time (so: including the slideshow opening transition, excluding any transition from last to first slide).


    Hope you can point me to the right slider properties and events to achieve this!

    Thanks a lot,

    Menno

  • [deleted] replied

    The slideshow cannot be navigated for a brief moment when a slide change is in process. So you only have to avoid that short timeframe. The slideChangeDidComplete and other Slide Change Events should help with that.