adapt_framework icon indicating copy to clipboard operation
adapt_framework copied to clipboard

Add an optional callback to the scrollTo and navigateTo

Open nilssanderson opened this issue 9 years ago • 5 comments

It would be useful if we had a callback from the scrollTo and navigateTo, as we could, for example, flash an element once it had been scrolled to or update an extension once the element is in view.

This would stop the need in using a delay function to accommodate the navigation time, which can be very unreliable.

nilssanderson avatar Oct 25 '17 08:10 nilssanderson

~~Have you tried using the below?~~

Adapt.once("page:scrollTo", callback);

~~I use this in one of my extensions to flash an element.~~

EDIT: Sorry, I realise now I don't use the scroll duration.

tomgreenfield avatar Oct 25 '17 08:10 tomgreenfield

Thanks @tomgreenfield will give that a go!

nilssanderson avatar Oct 25 '17 10:10 nilssanderson

Adapt.scrollTo has a onAfter callback for work that runs after the animation finishes.

// Syntax: Adapt.scrollTo(element, options);
Adapt.scrollTo('.a-05', {
    onAfter: function() {
        console.log('trigger this after page has scrolled');
    }
}) 

NayanKhedkar avatar Oct 26 '17 13:10 NayanKhedkar

@nilssanderson can this be closed?

moloko avatar Jul 18 '18 15:07 moloko

Yes, thank you to all replies!

nilslp avatar Jul 18 '18 15:07 nilslp