What steps can be taken to achieve a smooth scrolling speed adjustment?

Upon discovering this website, I was impressed by its smooth scrolling features.

The seamless scroll on the site creates a peaceful and calming experience without any abrupt jumps. It responds effortlessly to my mouse wheel, arrow buttons, and spacebar, providing a consistent smooth scroll. The side menu on larger screens also offers a graceful scrolling inertia curve for anchor links, which adds to the overall user experience.

After delving into the code, it seems that this functionality is not solely based on a CSS property. While searching for "scroll" and "parallax" in the JS file yielded results, the abundance of references made it difficult to pinpoint the exact control mechanism for this scroll effect. It appears that Wordpress and Jquery are used in the source files, and likely a plugin plays a role in enabling this feature. Through some research on StackOverflow, I came across "Jquery Smooth Scroll" (https://github.com/nathco/jQuery.scrollSpeed). However, upon exploring their demo site (), I found it to be quite jerky and lacking the smoothness I admired. Another demo I stumbled upon was this one (http://jsfiddle.net/36dp03ur/)

if (window.addEventListener) window.addEventListener('DOMMouseScroll', wheel, false);
window.onmousewheel = document.onmousewheel = wheel;

function wheel(event) {
    var delta = 0;
    if (event.wheelDelta) delta = event.wheelDelta / 120;
    else if (event.detail) delta = -event.detail / 3;

    handle(delta);
    if (event.preventDefault) event.preventDefault();
    event.returnValue = false;
}

function handle(delta) {
    var time = 1000;
var distance = 300;
    
    $('html, body').stop().animate({
        scrollTop: $(window).scrollTop() - (distance * delta)
    }, time );
}
#myDiv {
    height:2000px;
    width:100px;
    background-color: #CCF;
    
    font-family: 'Trebuchet MS';
    font-size: 12px;
    line-height: 24px;
    padding: 5px;
    margin: 5px;
    overflow:hidden;
}
.boldit{font-weight:bold;}
<div id="myDiv">
    Use the mouse wheel (not the scroll bar) to scroll this DIV. You will see that the scroll eventually slows down, and then stops. <span class="boldit">Use the mouse wheel (not the scroll bar) to scroll this DIV. You will see that the scroll eventually slows down, and then stops. </span> Use the mouse wheel... 

However, these demos also exhibited jerky behavior and failed to respond to keystrokes such as arrows or spacebar, as observed in Chrome v83.0.4103.61 on Windows 10.

If anyone with more expertise could identify the specific code responsible for the smooth scrolling on the referenced website and provide guidance on replicating it in a personal project, I would greatly appreciate it.

Answer №1

It appears that the website is utilizing the SmoothScroll for websites JavaScript library with specific initialization parameters:

SmoothScroll({
    frameRate: 150,
    animationTime: 1000,
    stepSize: 100,
    pulseAlgorithm: 1,
    pulseScale: 4,
    pulseNormalize: 1,
    accelerationDelta: 50,
    accelerationMax: 3,
    keyboardSupport: 1,
    arrowScroll: 50,
    fixedBackground: 0
});

This particular library is not directly associated with WordPress, unless it is integrated into a WordPress plugin on this site. It can be implemented on any website irrespective of its backend system.

Answer №2

It seems like the website is utilizing a specific WordPress library to achieve its scrolling functionality. To locate the exact code in Chrome, you can navigate to the 'Sources' tab within the developer tools and inspect the wheel event under global listeners.https://i.sstatic.net/qJCMg.png

The screenshot on the right displays the list of events that the website is monitoring. By selecting the 'wheel' event, you can view the listener for the scroll wheel. Clicking on the source will display the corresponding JavaScript file. While the file may be minified, Chrome typically provides an option to pretty print it for easier readability. If this option is not available, look for the {} button located in the bottom right corner of the screen to enable pretty printing.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Having trouble getting my Jquery Ajax post request to work with JSON data

I am working on syncing data from my Phonegap app back to the server. I have a PHP script set up on the server to handle the incoming data and now I need to figure out how to post values from my App to this script. Currently, I store my data in a SQLite d ...

Using val() on a checkbox will give you an element, not a string literal

How can I retrieve only the literal values of all checked checkboxes without any additional data? My current approach is: $('input:checked').map(function() { return $(this).val(); }) The result that I am getting looks like this: e.fn.init[1]0 ...

Setting character limits when defining string variables in TypeScript

Upon reviewing the documentation, it appears that there is no straightforward method to perform type checking for the minimum and maximum length of a string data type. However, is there a possible way to define a string data type using custom types in ord ...

Transmit the Selected Options from the Checkbox Categories

Here's an intriguing situation for you. I've got a webpage that dynamically generates groups of checkboxes, and their names are unknown until they're created. These groups could be named anything from "type" to "profile", and there's a ...

Trigger an Ajax upload by clicking a different element than the upload button

Currently, I am using Ajax Upload to sequentially upload a maximum of 6 images. Each image has its own corresponding div in the layout, and I want the upload action to be initiated when I click on these divs. However, my attempt at achieving this functiona ...

Are certain browsers unable to play dynamically generated HTML5 audio files?

While working on my project, I encountered an issue with creating and controlling an audio element in JavaScript. The element works perfectly fine in Firefox, Chrome, and Opera; however, it fails to function properly in IE and Safari. In these browsers, ...

Issue (@websanova/vue-auth): http plugin has not been properly configured in drivers/http/axios.js

I've been working on integrating vue-auth into my laravel-vue application, but I'm encountering some console errors: Error (@websanova/vue-auth): drivers/http/axios.js: http plugin has not been set. Uncaught TypeError: this.plugins.http is u ...

Combining array values in Node.js/JavaScript by matching key values

Looking to merge two arrays by matching key values in JavaScript/Node.js. Check out the code snippet below: var userData=[{'email':'<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d8b998bfb5b9b1b4f6bbb7b5">[em ...

Audio waves visualization - silence is golden

I am attempting to create a volume meter, using the web audio API to create a pulsation effect with a sound file loaded in an <audio> element. The indicator effect is working well with this code; I am able to track volume changes from the playing aud ...

Aligning a series of images with individual captions in the center

I am currently working on centering a row made up of four images along with their respective captions underneath. The code I am using is as follows: <div class="clear" style="text-align: center;"> <div style="float: left; padding-right: 10px;"& ...

Importing Data from Wordpress JSON Feed to Create a Table

Struggling with organizing my data into a table, as each row is currently generating a new table. Utilizing the JSON Content Importer with the following code: ...

What is the reason for the .foo a:link, .foo a:visited {} selector taking precedence over the a:hover, a:active {} selector in CSS?

Sample code: http://jsfiddle.net/RuQNP/ <!DOCTYPE html> <html> <head> <title>Foo</title> <style type="text/css"> a:link, a:visited { color: blue; } a:hover, a:active { ...

Issue with Tweening in Three.js: Initial value does not change

Having trouble with tweening my camera position. I've set up a Codepen with minimal code to showcase the issue, complete with annotations and plenty of console.log() statements for debugging purposes. Check out the Codepen The starting point of my c ...

Ensure that you accurately maintain object ids following the creation of elements using ng-repeat

I have a set of items listed with unique objects within my controller $scope.itemsList = [ {"id": 0, "item": "sw", "category": 'A' }, {"id": 1, "item": "mlr", "category": 'B'}, {"id": 2, "item": "lvm", "category": 'C&a ...

What could be the reason why my sorting function is not functioning properly?

I am currently in a state of questioning everything I thought I knew. > [ 37, 4, 3, 1, 3, 10, 8, 29, 9, 13, 19, 12, 11, 14, 20, 22, 22, 27, 28, 33, 34 ].sort((a, b) => a > b) [19, 34, 3, 1, 3, 10, 8, 29, 9, 13, 4, 12, 11, 14, 20, 22, 22, 27, 28, ...

Passing data from an Express middleware to a Jade template

My KeystoneJS app is all set up, using Express and Jade. The default.jade file sets up a fullscreen background image along with various imports, the header, and footer of the site. I am attempting to rotate the image based on a selection of images stored ...

Enhancing nouislider jQuery slider with tick marks

I have integrated the noUIslider plugin () into one of my projects. I am seeking guidance on how to display tick marks below each value on the slider. This is the current initialization code for the slider: $slider.noUiSlider({ 'start': sta ...

Exploring the fundamentals of Django with a touch of creativity in CSS

As a newcomer to Django, I am currently working on setting up a basic Django application. I have progressed to chapter 5 in the Django online book: Before delving into databases, my goal is to incorporate some simple CSS and JS directly into the applicat ...

Tips for accessing a Wordpress site installed on a remote server from a local environment

I've been working on this issue for a few days now, and while it seems like a simple problem to fix, I'm struggling to find a solution. I have MAMP set up on my local machine with the document root path leading to a folder named websites. Within ...

Encountered an issue while building npm: "Error: Unable to locate module @restart/context

Lately, I've encountered an issue with npm build after upgrading to the latest version of react-bootstrap (1.0.0-beta.6). While creating an optimized production build... Failed to compile. Module not found: '@restart/context/forwardRef'. P ...