Soldato
I've been working on my new site and I thought I'd managed to get the jquery script(s) working how I wanted them but I had an issue pointed out that I hadn't spotted.
On my site I've got a jquery waypoint that fades in a 'back to top button' when you scroll down the page. It works as intended but if you scroll up and down a lot really fast the 'back to top button' flickers while it catches up with itself.
I've got a live version online but it's on my business site so technically not allowed to add a link....
I understand the issue is called animation build up so off I trundled to google to try and fix the issue.... results usually mentioned using .stop() or even using .dequeue() but when I've tried adding these they do kind of work but once I've stopped the 'fast scrolling' the script no longer loads up the button or menu again and requires a full page refresh for it to work again, reintroducing the 'flicker bug'.
Can anyone either point me in the direction of more reading or show what I need to change on my original script (back to top button) which works but has the flickering.
Thanks in advance
Here's the script I'm using.
On my site I've got a jquery waypoint that fades in a 'back to top button' when you scroll down the page. It works as intended but if you scroll up and down a lot really fast the 'back to top button' flickers while it catches up with itself.
I've got a live version online but it's on my business site so technically not allowed to add a link....
I understand the issue is called animation build up so off I trundled to google to try and fix the issue.... results usually mentioned using .stop() or even using .dequeue() but when I've tried adding these they do kind of work but once I've stopped the 'fast scrolling' the script no longer loads up the button or menu again and requires a full page refresh for it to work again, reintroducing the 'flicker bug'.
Can anyone either point me in the direction of more reading or show what I need to change on my original script (back to top button) which works but has the flickering.
Thanks in advance
Here's the script I'm using.
Code:
[LIST=1]
[*]jQuery(document).ready(function() {
[*] var offset = 500;
[*] var duration = 500;
[*] jQuery(window).scroll(function() {
[*] if (jQuery(this).scrollTop() > offset) {
[*] jQuery('.back-to-top').fadeIn(duration);
[*] } else {
[*] jQuery('.back-to-top').fadeOut(duration);
[*] }
[*] });
[*] jQuery('.back-to-top').click(function(event) {
[*] event.preventDefault();
[*] jQuery('html, body').animate({scrollTop: 0}, duration);
[*] return false;
[*] })
[*]});
[/LIST]