PHPackages                             flesler/jquery.scrollto - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. flesler/jquery.scrollto

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

flesler/jquery.scrollto
=======================

Lightweight, cross-browser and highly customizable animated scrolling with jQuery

v2.1.3(5y ago)3.7k40.8k↓39.7%997JavaScript

Since Apr 2Pushed 5y ago151 watchersCompare

[ Source](https://github.com/flesler/jquery.scrollTo)[ Packagist](https://packagist.org/packages/flesler/jquery.scrollto)[ Docs](https://github.com/flesler/jquery.scrollTo)[ RSS](/packages/flesler-jqueryscrollto/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (1)Versions (12)Used By (0)

jQuery.scrollTo
===============

[](#jqueryscrollto)

Lightweight, cross-browser and highly customizable animated scrolling with jQuery

[![](https://camo.githubusercontent.com/7e3f46a36526479d701ef7f90a0f8c3ac2fbab3087446e2a9fceed75cd1ab802/687474703a2f2f6170692e666c617474722e636f6d2f627574746f6e2f666c617474722d62616467652d6c617267652e706e67)](http://flattr.com/thing/2081384/fleslerjquery-scrollTo-on-GitHub)[![GitHub version](https://camo.githubusercontent.com/dffb20d67a152965037dcada1734eeaae00f783294ffc58a514b86b42514c909/68747470733a2f2f62616467652e667572792e696f2f67682f666c65736c65722532466a71756572792e7363726f6c6c546f2e737667)](http://badge.fury.io/gh/flesler%2Fjquery.scrollTo)

Installation
------------

[](#installation)

The plugin requires jQuery 1.8 or higher.

Via [bower](https://github.com/flesler/jquery.scrollTo/blob/master/bower.json):

```
bower install jquery.scrollTo
```

Via [npm](https://www.npmjs.com/package/jquery.scrollto):

```
npm install jquery.scrollto
```

Via [packagist](https://packagist.org/packages/flesler/jquery.scrollTo):

```
php composer.phar require --prefer-dist flesler/jquery.scrollto "*"
```

### Using a public CDN

[](#using-a-public-cdn)

CDN provided by [jsdelivr](http://www.jsdelivr.com/#!jquery.scrollto)

```

```

CDN provided by [cdnjs](https://cdnjs.com/libraries/jquery-scrollTo)

```

```

### Downloading Manually

[](#downloading-manually)

If you want the latest stable version, get the latest release from the [releases page](https://github.com/flesler/jquery.scrollTo/releases).

2.0
---

[](#20)

Version 2.0 has been recently released. It is mostly backwards compatible, if you have any issue first check [this link](https://github.com/flesler/jquery.scrollTo/wiki/Migrating-to-2.0). If your problem is not solved then go ahead and [report the issue](https://github.com/flesler/jquery.scrollTo/issues/new).

Usage
-----

[](#usage)

jQuery.scrollTo's signature is designed to resemble [$().animate()](http://api.jquery.com/animate/).

```
$(element).scrollTo(target[,duration][,settings]);
```

### *element*

[](#element)

This must be a scrollable element, to scroll the whole window use `$(window)`.

### *target*

[](#target)

This defines the position to where `element` must be scrolled. The plugin supports all these formats:

- A number with a fixed position: `250`
- A string with a fixed position with px: `"250px"`
- A string with a percentage (of container's size): `"50%"`
- A string with a relative step: `"+=50px"`
- An object with `left` and `top` containining any of the aforementioned: `{left:250, top:"50px"}`
- The string `"max"` to scroll to the end.
- A string selector that will be relative to the element to scroll: `".section:eq(2)"`
- A DOM element, probably a child of the element to scroll: `document.getElementById("top")`
- A jQuery object with a DOM element: `$("#top")`

### *settings*

[](#settings)

The `duration` parameter is a shortcut to the setting with the same name. These are the supported settings:

- **axis**: The axes to animate: `xy` (default), `x`, `y`, `yx`
- **interrupt**: If `true` will cancel the animation if the user scrolls. Default is `false`
- **limit**: If `true` the plugin will not scroll beyond the container's size. Default is `true`
- **margin**: If `true`, subtracts the margin and border of the `target` element. Default is `false`
- **offset**: Added to the final position, can be a number or an object with `left` and `top`
- **over**: Adds a % of the `target` dimensions: `{left:0.5, top:0.5}`
- **queue**: If `true` will scroll one `axis` and then the other. Default is `false`
- **onAfter(target, settings)**: A callback triggered when the animation ends (jQuery's `complete()`)
- **onAfterFirst(target, settings)**: A callback triggered after the first axis scrolls when queueing

You can add any setting supported by [$().animate()](http://api.jquery.com/animate/#animate-properties-options) as well:

- **duration**: Duration of the animation, default is `0` which makes it instantaneous
- **easing**: Name of an easing equation, you must register the easing function: `swing`
- **fail()**: A callback triggered when the animation is stopped (f.e via `interrupt`)
- **step()**: A callback triggered for every animated property on every frame
- **progress()**: A callback triggered on every frame
- And more, check jQuery's [documentation](http://api.jquery.com/animate/#animate-properties-options)

### window shorthand

[](#window-shorthand)

You can use `$.scrollTo(...)` as a shorthand for `$(window).scrollTo(...)`.

### Changing the default settings

[](#changing-the-default-settings)

As with most plugins, the default settings are exposed so they can be changed.

```
$.extend($.scrollTo.defaults, {
  axis: 'y',
  duration: 800
});
```

### Stopping the animation

[](#stopping-the-animation)

jQuery.scrollTo ends up creating ordinary animations which can be stopped by calling [$().stop()](http://api.jquery.com/stop/) or [$().finish()](http://api.jquery.com/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.

### onAfter and requestAnimationFrame

[](#onafter-and-requestanimationframe)

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](http://caniuse.com/#feat=requestanimationframe) to do work on the next tick. It is available in many browsers, but you may want to [polyfill](https://github.com/chrisdickinson/raf) for the few it does not support.

```
$.scrollTo(100, {
  onAfter: function() {
    requestAnimationFrame(function() {
        $(".result").addClass("selected");
    });
  }
});
```

Demo
----

[](#demo)

Check the [demo](http://demos.flesler.com/jquery/scrollTo/) to see every option in action.

Complementary plugins
---------------------

[](#complementary-plugins)

There are two plugins, also created by me that depend on jQuery.scrollTo and aim to simplify certain use cases.

### [jQuery.localScroll](https://github.com/flesler/jquery.localScroll)

[](#jquerylocalscroll)

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](https://gist.github.com/flesler/3f3e1166690108abf747).

### [jQuery.serialScroll](https://github.com/flesler/jquery.serialScroll)

[](#jqueryserialscroll)

This plugin simplifies the creation of scrolling slideshows.

Troubleshooting
---------------

[](#troubleshooting)

- `Cannot read property 'propHooks' of undefined`: You are most likely using the slim version jQuery, which doesn't include the effects module. The plugin cannot function without it and you'll need the full version.
- **The element doesn't scroll**: A good approach to debug is to set `overflow: auto` temporarily to the scrollable element, to make sure it would be manually scrollable. If you don't see any scrollbar, the problem is likely in the HTML/CSS.

License
-------

[](#license)

(The MIT License)

Copyright (c) 2007 Ariel Flesler

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.

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity59

Moderate usage in the ecosystem

Community36

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 74.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~314 days

Recently: every ~541 days

Total

9

Last Release

1964d ago

Major Versions

1.4.14 → 2.0.02015-03-18

### Community

Maintainers

![](https://www.gravatar.com/avatar/6d01d01e6454aa876f8a065f46e82c794da29fc5d8fe860350e392cd4dc7cf3a?d=identicon)[iGusev](/maintainers/iGusev)

---

Top Contributors

[![flesler](https://avatars.githubusercontent.com/u/38258?v=4)](https://github.com/flesler "flesler (92 commits)")[![durango](https://avatars.githubusercontent.com/u/677683?v=4)](https://github.com/durango "durango (11 commits)")[![iGusev](https://avatars.githubusercontent.com/u/1555767?v=4)](https://github.com/iGusev "iGusev (5 commits)")[![buzzedword](https://avatars.githubusercontent.com/u/334485?v=4)](https://github.com/buzzedword "buzzedword (3 commits)")[![JeffreyATW](https://avatars.githubusercontent.com/u/266170?v=4)](https://github.com/JeffreyATW "JeffreyATW (2 commits)")[![LukasDrgon](https://avatars.githubusercontent.com/u/15611832?v=4)](https://github.com/LukasDrgon "LukasDrgon (1 commits)")[![Rabadash8820](https://avatars.githubusercontent.com/u/8388785?v=4)](https://github.com/Rabadash8820 "Rabadash8820 (1 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (1 commits)")[![tmm1](https://avatars.githubusercontent.com/u/2567?v=4)](https://github.com/tmm1 "tmm1 (1 commits)")[![adjohn](https://avatars.githubusercontent.com/u/168944?v=4)](https://github.com/adjohn "adjohn (1 commits)")[![vinnymac](https://avatars.githubusercontent.com/u/1832781?v=4)](https://github.com/vinnymac "vinnymac (1 commits)")[![jdufresne](https://avatars.githubusercontent.com/u/347634?v=4)](https://github.com/jdufresne "jdufresne (1 commits)")[![jeromev](https://avatars.githubusercontent.com/u/1205478?v=4)](https://github.com/jeromev "jeromev (1 commits)")[![joscha](https://avatars.githubusercontent.com/u/188038?v=4)](https://github.com/joscha "joscha (1 commits)")[![kkirsche](https://avatars.githubusercontent.com/u/947110?v=4)](https://github.com/kkirsche "kkirsche (1 commits)")

---

Tags

anchorsanimatedanimationbrowserdemofleslerjquerylinksscrollscrolltobrowserjqueryanimationscrollanimatedscrollinglinksanchors

### Embed Badge

![Health badge](/badges/flesler-jqueryscrollto/health.svg)

```
[![Health](https://phpackages.com/badges/flesler-jqueryscrollto/health.svg)](https://phpackages.com/packages/flesler-jqueryscrollto)
```

###  Alternatives

[webcreate/jquery-ias

Infinite Ajax Scroll: A jQuery plugin that turns your server-side pagination into an infinite scrolling one using AJAX

903736.3k3](/packages/webcreate-jquery-ias)[nicolaskruchten/pivottable

Javascript Pivot Table (aka Pivot Grid, Pivot Chart, Cross-Tab) implementation with drag'n'drop.

4.4k219.4k1](/packages/nicolaskruchten-pivottable)[kop/yii2-scroll-pager

Infinite AJAX scrolling for Yii2 ListView widget

181732.8k10](/packages/kop-yii2-scroll-pager)[datatables.net/datatables.net

DataTables is a plug-in for the jQuery Javascript library. It is a highly flexible tool, based upon the foundations of progressive enhancement, which will add advanced interaction controls to any HTML table. This is jQuery DataTables

58170.0k33](/packages/datatablesnet-datatablesnet)[raoul2000/yii2-scrollup-widget

Wrapper around the Scrollup JQuery plugin

133.4k](/packages/raoul2000-yii2-scrollup-widget)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
