kirkas/Ascensor.js

Event "scrollend" with delay

Opened this issue · 1 comments

xmon commented

Hi @kirkas

The "scrollend" event is delayed in a certain circumstance.

To play it, if you set "queued" to "y" and we are on one floor and we want to go to another floor that is on the same "y" axis. The "scrollend" event is launched with a delay of 1 or 2 seconds.

With the same configuration "queued" in "y", if we are on one floor and we want to go to another floor that is not in the same axis "y" and therefore has to move by 2 axes, the event "scrollend" Is launched without delay, at the same time that the animation ends.

Any idea to solve it?

thanks a lot

xmon commented

This is my workaround in my own code

        $(".links-to-floor li").click(function (event, index) {
        
            // here your check if need redefine "queued"
            if(...){
                    ascensorInstance.options.queued = "y";
            } else {
                    ascensorInstance.options.queued = "x";
            }
            ascensorInstance.scrollToFloor($(this).index());
        });

I have checked the source and the destination, to know which configuration for "queued" is needed, here a very basic example:

         var current = ascensor.data("current-floor");
         var destination = $(this).index();
         // for example
         if(current === 0 && destination === 6){
                    ascensorInstance.options.queued = "y";
         }

I hope it helps, as long as this BUG is not solved in the plugin.