Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
jquery.scrollto
Advanced tools
Lightweight, cross-browser and highly customizable animated scrolling with jQuery
Lightweight, cross-browser and highly customizable animated scrolling with jQuery
The plugin requires jQuery 1.8 or higher.
Via bower:
bower install jquery.scrollTo
Via npm:
npm install jquery.scrollto
Via packagist:
php composer.phar require --prefer-dist flesler/jquery.scrollto "*"
CDN provided by jsdelivr
<script src="//cdn.jsdelivr.net/npm/jquery.scrollto@2.1.3/jquery.scrollTo.min.js"></script>
CDN provided by cdnjs
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-scrollTo/2.1.3/jquery.scrollTo.min.js"></script>
If you want the latest stable version, get the latest release from the releases page.
Version 2.0 has been recently released. It is mostly backwards compatible, if you have any issue first check this link. If your problem is not solved then go ahead and report the issue.
jQuery.scrollTo's signature is designed to resemble $().animate().
$(element).scrollTo(target[,duration][,settings]);
This must be a scrollable element, to scroll the whole window use $(window)
.
This defines the position to where element
must be scrolled. The plugin supports all these formats:
250
"250px"
"50%"
"+=50px"
left
and top
containining any of the aforementioned: {left:250, top:"50px"}
"max"
to scroll to the end.".section:eq(2)"
document.getElementById("top")
$("#top")
The duration
parameter is a shortcut to the setting with the same name.
These are the supported settings:
xy
(default), x
, y
, yx
true
will cancel the animation if the user scrolls. Default is false
true
the plugin will not scroll beyond the container's size. Default is true
true
, subtracts the margin and border of the target
element. Default is false
left
and top
target
dimensions: {left:0.5, top:0.5}
true
will scroll one axis
and then the other. Default is false
complete()
)You can add any setting supported by $().animate() as well:
0
which makes it instantaneousswing
interrupt
)You can use $.scrollTo(...)
as a shorthand for $(window).scrollTo(...)
.
As with most plugins, the default settings are exposed so they can be changed.
$.extend($.scrollTo.defaults, {
axis: 'y',
duration: 800
});
jQuery.scrollTo ends up creating ordinary animations which can be stopped by calling $().stop() or $().finish() on the same element you called $().scrollTo()
, including the window
.
Remember you can pass a fail()
callback to be called when the animation is stopped.
jQuery.scrollTo has a onAfter
callback for work that runs after the animation finishes. It will be called before the scroll
event fires. To combat this you can use requestAnimationFrame to do work on the next tick. It is available in many browsers, but you may want to polyfill for the few it does not support.
$.scrollTo(100, {
onAfter: function() {
requestAnimationFrame(function() {
$(".result").addClass("selected");
});
}
});
Check the demo to see every option in action.
There are two plugins, also created by me that depend on jQuery.scrollTo and aim to simplify certain use cases.
This plugin makes it very easy to implement anchor navigation. If you don't want to include another plugin, you can try using something like this minimalistic gist.
This plugin simplifies the creation of scrolling slideshows.
(The MIT License)
Copyright (c) 2007 Ariel Flesler aflesler@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2.1.3
FAQs
Lightweight, cross-browser and highly customizable animated scrolling with jQuery
The npm package jquery.scrollto receives a total of 12,126 weekly downloads. As such, jquery.scrollto popularity was classified as popular.
We found that jquery.scrollto demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.