idiotWu / smooth-scrollbar

Customizable, Extendable, and High-Performance JavaScript-Based Scrollbar Solution.
https://idiotwu.github.io/smooth-scrollbar/
MIT License
3.31k stars 384 forks source link

jquery.animate Scroll to Top not working with Smooth-Scrollbar #309

Closed hassanjaved110 closed 3 years ago

hassanjaved110 commented 3 years ago

i am using smooth-scrollbar and this code: var scrollTop = $("#return-to-top"); //Click event to scroll to top $(scrollTop).click(function() { $('html, body').animate({ scrollTop: 0 }, 800); return false; });

on click "return-to-top" not going to top of the window/page.

and

also not working my counter code and also not giving any error in console.! hope you will have another solution for me thanks.

var counted = 0; $(window).on('scroll', function() { var oTop = $('#counter').offset().top - window.innerHeight; if (counted == 0 && $(window).scrollTop() > oTop) { alert(); $('.count').each(function() { var $this = $(this), countTo = $this.attr('data-count'); $({ countNum: $this.text() }).animate({ countNum: countTo }, { duration: 2000, easing: 'swing', step: function() { $this.text(Math.floor(this.countNum)); }, complete: function() { $this.text(this.countNum); } }); }); counted = 1; } });

I am used This cod: But it still not working.

$(function(){ $("#return-to-top").on("click", function(){ TweenMax.to($(window), 1, { scrollTo:{ y: $("body").offset().top, autoKill: true }, ease:Power3.easeOut }); return false; }); });

sadeghbarati commented 3 years ago
  1. for return-to-top https://github.com/idiotWu/smooth-scrollbar/blob/develop/docs/api.md#scrollbarscrollto

  2. for inview scroll animation if you using gsap upgrade it to latest version and use ScrollTrigger API or go to SmoothScrollbar API https://github.com/idiotWu/smooth-scrollbar/blob/develop/docs/api.md#scrollbarscrolltop