Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Smooth Scroll on website

Explorer ,
Mar 11, 2025 Mar 11, 2025

On the template for my new website, it has a smooth scroll function which when clicked on, for example 'view my protfolio' at the top moves down the page to the relevant section clicked on.

 

However, I am finding this way too slow but can't find in the code where to amend the delay so it scrolls quicker? It seems to sit in 'animate.min.css' but I don't see any timings there.

 

url: https://kylehawkinscreative.com/

TOPICS
Code
135
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 11, 2025 Mar 11, 2025

Have a look in /js/theme.js

 

/*------------------------
   Scroll to top
-------------------------- */
$(function () {
		$(window).on('scroll', function(){
			if ($(this).scrollTop() > 400) {
				$('#back-to-top').fadeIn();
			} else {
				$('#back-to-top').fadeOut();
			}
		});
		});
$('#back-to-top').on("click", function() {
	$('html, body').animate({scrollTop:0}, 'slow');
	return false;
});

 

This is written using  jQuery, a framwork that has gone out of fashion.

 

I converted a similar temp

...
Translate
Community Expert ,
Mar 11, 2025 Mar 11, 2025

Have a look in /js/theme.js

 

/*------------------------
   Scroll to top
-------------------------- */
$(function () {
		$(window).on('scroll', function(){
			if ($(this).scrollTop() > 400) {
				$('#back-to-top').fadeIn();
			} else {
				$('#back-to-top').fadeOut();
			}
		});
		});
$('#back-to-top').on("click", function() {
	$('html, body').animate({scrollTop:0}, 'slow');
	return false;
});

 

This is written using  jQuery, a framwork that has gone out of fashion.

 

I converted a similar template to using NodeJS and created a very simple script for the Floating back-to-top button:

<!-- =====Floating back-to-top button===== -->
<button type="button" class="btn btn-primary position-fixed bottom-0 end-0 m-4 rounded-circle" onclick="window.scrollTo({top: 0, behavior: 'smooth'})" style="width: 50px; height: 50px; z-index: 1000; display: none;" id="backToTop">
    <i class="fas fa-arrow-up"></i>
</button>
<script>
    window.onscroll = function() {
    if (document.body.scrollTop > 400 || document.documentElement.scrollTop > 400) {
        document.getElementById("backToTop").style.display = "block";
    } else {
        document.getElementById("backToTop").style.display = "none";
    }
};
</script>
Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 11, 2025 Mar 11, 2025
LATEST

Brilliant, found it and managed to alter the speed. Thank you.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines