halfmoonui / halfmoon

Halfmoon is a highly customizable, drop-in Bootstrap replacement. It comes with three built-in core themes, with dark mode support for all themes and components.
https://www.gethalfmoon.com
MIT License
3.01k stars 118 forks source link

scrollTop function is not working #107

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hey, I am sure why this is happening. I was trying to create a scroll to top button and tried a lot of solutions from StackOverflow but nothing seems to work.

$("html, body").animate({ scrollTop: 0 }, "slow");

Any help on this is appreciated. Thanks

abdeljail commented 3 years ago

Hey guys $('html, body').animate({scrollTop: 0},'slow'); : is perfectly valid code for an animated scroll
try this code:
qj

Toby222 commented 3 years ago

Which doesn't help in explaining why it doesn't work for @abhijeet-cn, sadly. Is the problem related to halfmoon? Or can you re-create it without the css?

Looky1173 commented 3 years ago

Hello,

I was having the same issue. I found that you must scroll not on the body but on .content-wrapper, like so:

$('.content-wrapper').animate({scrollTop: '0px'}, 1000);

This occurs thanks to how Halfmoon structures your page where the body will always take up exactly the full visible screen area and the page contents are themselves wrapped in .page-wrapper > .content-wrapper.

ghost commented 3 years ago

Thanks this worked for me, I am closing the issue.