javascript - How to adjust speed of smoothScroll - Stack Overflow
I am currently using the smoothScroll
function on a horizontally scrolling website. The current jQuery I have running is both for a previous/next section button and a regular navigation for all sections. The regular navigation is that with the .scroll-test class. This is the jQuery code:
$(document).ready(function() {
var url = 1;
$('a.forward').click(function () {
url = url + 1;
$(this).attr({ href: '#section' + url });
$(this).parent().attr({ class: 'section' + url });
});
$('a.backward').click(function () {
url = url - 1;
$(this).attr({ href: '#section' + url });
$(this).parent().attr({ class: 'section' + url });
});
$('a.forward, a.backward').smoothScroll();
$('a.scroll-test').smoothScroll();
});
What I want is to change the speed of the scroll animation. Right now it's going really fast when jumping over more than one page.
Thanks in advance!
I am currently using the smoothScroll
function on a horizontally scrolling website. The current jQuery I have running is both for a previous/next section button and a regular navigation for all sections. The regular navigation is that with the .scroll-test class. This is the jQuery code:
$(document).ready(function() {
var url = 1;
$('a.forward').click(function () {
url = url + 1;
$(this).attr({ href: '#section' + url });
$(this).parent().attr({ class: 'section' + url });
});
$('a.backward').click(function () {
url = url - 1;
$(this).attr({ href: '#section' + url });
$(this).parent().attr({ class: 'section' + url });
});
$('a.forward, a.backward').smoothScroll();
$('a.scroll-test').smoothScroll();
});
What I want is to change the speed of the scroll animation. Right now it's going really fast when jumping over more than one page.
Thanks in advance!
Share Improve this question edited Dec 8, 2015 at 11:41 Rory McCrossan 338k41 gold badges320 silver badges351 bronze badges asked Dec 8, 2015 at 11:39 Emil ØstervigEmil Østervig 4606 silver badges21 bronze badges1 Answer
Reset to default 5Can't you set the speed by passing it a param (object) to the function like so
.smoothScroll({speed:2000})
The speed value is the animation time in milliseconds
- Intel兵屯深圳,意欲何为?
- 谷歌加入硬件战场:正面对抗亚马逊和苹果
- 谷歌收购移动软件商Quickoffice 整合Apps
- Youtube APi Fetching Gender Percentage of my channel - Stack Overflow
- Is it possible to solve this vagrant ruby gems error? - Stack Overflow
- ios - CocoaPods could not find compatible versions for pod "FirebaseCore": - Stack Overflow
- python - Plotting a list of integer 3d values into Axes3d.voxels - Stack Overflow
- How do you use partitions in Music Player Daemon (MPD) - Stack Overflow
- javascript - Mapping through these JSON elements - Stack Overflow
- flash - Movie clip loading display problem in ActionScript 2 - Stack Overflow
- rust - Remove struct from vector while mutably iterating through it - Stack Overflow
- python 3.x - unable to dynamically access ".variable" attribute of a ttk.RadioButton (python3) - Stack Overflo
- asp.net - Delete Button does not delete in C# Webforms - Stack Overflow
- Why Axios send cookies without withCredential parameter? - Stack Overflow
- Swift Predicate: Fatal Error Keypaths With Multiple Components - Stack Overflow
- c++ - Pointer of an object which has static storage as template non-type parameter, Clang and GCC agrees, MSVC doesn't -
- amazon web services - Nuxt build fails on AWS Amplify: Failed to find the deploy-manifest.json file in the build output - Stack