A Simple jQuery Plugin for Animating Scroll

Overview

AnimateScroll

A Simple jQuery Plugin for Animating the Scroll

Demo can be seen at http://plugins.compzets.com/animatescroll

What is it exactly?

AnimateScroll is a jQuery plugin which enables you to scroll to any part of the page in style by just calling the animatescroll() function with the id or classname of the element where you want to scroll to.

It gives power to the user with its various options to customize the style of scrolling, scroll speed and many more. Supports more than 30 unique Scrolling Styles.

Usage

You need two things for this plugin to work, one is "jQuery library" and the other animatescroll.js file.

Just include the animatescroll.js file after the "jQuery library" as shown in the code snippet below and you're done.

NOTE: The only dependency for this plugin to work is jQuery library.

<html>
    <head>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
        <script src="animatescroll.js">
    </head>
    <body>
        <div id="section-1">This is the element where you want to scroll to<div>
        
        /*
         * You may call the function like this
         * (but better attach an event listener)
         */
        <a onclick="$('[jquery selector]').animatescroll([options]);">Go to Element</a>
    </body>
</html>

You can either download the files or install from Bower (package manager):

bower install animatescroll

NOTE: There are two js files, if you do not want the various easing effects, you can use the animatescroll.noeasing.js

Options

AnimateScroll has 6 options:

  1. easing
  2. scrollSpeed
  3. padding
  4. element
  5. onScrollStart
  6. onScrollEnd

easing (default: easing)

This option defines the scrolling style. The various easing effects supported can be seen at www.easings.net (Accepts string only)

scrollSpeed (default: 400)

Controls the scrolling speed, higher is the number slower is the scroll speed (Accepts only number)

padding (default: 0)

Adjusts little ups and downs in scrolling. Suppose a small amount of padding is applied to a particular element due to which the scroll didn't end at the right position, so this option helps you to rectify (Accepts numbers only, can be negative)

element (default: html, body)

Added in v1.0.5. The element in which you want this plugin to work. Default is "body". (Accepts any jQuery/CSS selector)

onScrollStart

Added in v1.0.7. A function to be called before scrolling starts

onScrollEnd

Added in v1.0.7. A function to be called after the scrolling ends completely with animations

To add an option:

$('[jquery selector]').animatescroll({
  <optionName> : <optionValue>
});

Easing Effects

This plugin supports more than 30 different styles of scrolling. The easing option lets you choose a particular style of scrolling according to your choice.

The different easing effects are:

swing, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic, easeInQuart,
easeOutQuart, easeInOutQuart, easeInQuint, easeOutQuint, easeInOutQuint, easeInSine, easeOutSine, easeInOutSine,
easeInExpo, easeOutExpo, easeInOutExpo, easeInCirc, easeOutCirc, easeInOutCirc, easeInElastic, easeOutElastic,
easeInOutElastic, easeInBack, easeOutBack, easeInOutBack, easeInBounce, easeOutBounce, easeInOutBounce

About

My name is Ram Patra. I am an app developer and a tech aficionado from India. I make apps/plugins for mobile, web, and computer. Have a look at some of them at rampatra.com.

This is my first jQuery Plugin and I hope you all like it. You are free to make more improvements to the code by sending a pull-request.

If my plugin helped you or unlikely for any issues tweet me @ram__patra, will be happy to hear from you.

Backers

Thank you to all our backers! 🙏 [Become a backer]

Sponsors

Proudly sponsored by Presentify and BrowserStack. Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]


P.S. For any queries or concerns, you can reach out to me on Twitter. I'll try my best to help 🙏 .

Comments
  • How to make it work with wordpress

    How to make it work with wordpress

    Hello!

    I love your plugin! My question is how do you make the onclick even work with wordpress?

    I actually found this http://designm.ag/tutorials/single-page-dynamic-website-using-animatescrolljs/

    but cant get it to work

    Thanks

    opened by cliftonc0613 2
  • Script stop working when i have async attribute in jquery and animatescroll

    Script stop working when i have async attribute in jquery and animatescroll

    When i have async attributes in js and jquery won't load before animatescrol, it throws an Uncaught ReferenceError error: jQuery is not defined at js / animatescroll.min.js: 2 and the script stops working. When the user tries to use the navigation later only errors pops up: Uncaught TypeError: $ ( ...). animatescroll is not a function at HTMLAnchorElement.onclick.

    opened by gawron7 1
  • Padding option

    Padding option

    Hi! Great plugin, especially for its simplicity!

    I have a small problem or am I doing something wrong. I have a script to keep the DIV where I have the navigation, always at the top of the window, when I scroll, I need to always leave space for that div. Then I thought using the padding option, however it only works on the second click. The first click it scroll to the exact position of the element, and only when I give another click is that it sets the padding. I try to invoke the function that keeps my navigation on top with the option "onScrollEnd", but it didn't work either.

    It is normal behavior, or should be something else? Thank you very much! Jose

    question 
    opened by JoseJoaoMata 1
  • Update on usage (data-animate-scroll)

    Update on usage (data-animate-scroll)

    Instead of

    <a onclick="$('[jquery selector]').animatescroll([options]);">Go to Element</a>
    

    We might as well make use of data-animate-scroll in which the library listen for on-click events on elements having the data attribute? For example,

    <a href="#" data-animate-scroll-target=".that-element" data-animate-scroll-ease="swing"></a>
    
    opened by srph 1
  • Allow href for fallback, or main use with class=

    Allow href for fallback, or main use with class="animatescroll"

    return false; on line 158 allows to add href for fallback for those with js disabled without the default behaviour overriding animatescroll. Lines 172 to 177 allow that instead of adding the onclick method to the <a> tag you can add class="animatescroll" and animate scroll will be launched with the href contents as the target.


    This change is Reviewable

    opened by neil-h 1
  • Calculation from top

    Calculation from top

    Hello, I am using the plugin for a dynamic search list with a dropdown block. I wanted to bring the dropdown block to the user view perfectly. So I used your plugin and it works fine. But each time it goes to the top and then returns to the block. Is there a way to overcome this.

    opened by winnyboy5 1
  • Target multiple classes or id with 1 anchor link

    Target multiple classes or id with 1 anchor link

    Hello, Is it possible to do this? Basically, as you click, it scrolls to the ids or classes specified. $('#SECTION1, #SECTION2, #SECTION3').animatescroll({scrollSpeed:1000,easing:'easeInOutBack'});">Scroll to Multiple Elements

    opened by silvermanners 1
  • Added callbacks & object return

    Added callbacks & object return

    Added two callbacks to the plugin, one to be executed before the animation, that is onScrollStart and the other one that is executed once per call as a callback to animation, that is onScrollEnd.

    The plugins also returns the object now, to allow chaining.

    Review on Reviewable

    opened by gsimone 1
  • Add a Gitter chat badge to README.md

    Add a Gitter chat badge to README.md

    ramswaroop/animatescroll.js now has a Chat Room on Gitter

    @ramswaroop has just created a chat room. You can visit it here: https://gitter.im/ramswaroop/animatescroll.js.

    This pull-request adds this badge to your README.md:

    Gitter

    Happy chatting.

    PS: Click here if you would prefer not to receive automatic pull-requests from Gitter in future.

    opened by gitter-badger 0
  • Firefox & IE Not Scrolling

    Firefox & IE Not Scrolling

    When I try to run the Animatescroll function I get this error message: $($str).animatescroll is not a function @ http://localhost/:17

    the function in js that im calling is : $($str).animatescroll({scrollSpeed:300});

    It works perfectly in webkit browsers like safari. Thanks for your help.

    opened by atomikpanda 0
  • Fixing #19 and a minification issue on concat scripts

    Fixing #19 and a minification issue on concat scripts

    Fixing #19 Fixing issue when using concat/uglify/minify tools reporting missing ";" because of wrong () placement.

    (function($){})(jQuery);
    

    This change is Reviewable

    opened by HugoPoi 0
  • Element option not working when target id isn't a direct child of element

    Element option not working when target id isn't a direct child of element

    When using element option and the target id isn't a direct child of element.

    <div class="container-with-scroll">
      <h2 id="working-target"></h2>
      <a><img id="target"></a>
    </div>
    
      // This working great :
      $('#working-target').animatescroll({ element: '.container-with-scroll', padding: 20 });
      // This not working :
      $('#target').animatescroll({ element: '.container-with-scroll', padding: 20 });
    

    Problem is here https://github.com/ramswaroop/animatescroll.js/blob/master/animatescroll.js#L162 The use of this.parent() causing the issue because the parent of target is <a> not the .container-with-scroll.

    The fix:

      $(opts.element).stop().animate({ scrollTop: this.offset().top - $(opts.element).offset().top + $(opts.element).scrollTop() - opts.padding}, opts.scrollSpeed, opts.easing);
    
    

    I can do a PR if needed.

    opened by HugoPoi 0
  • [enhancement] Add missing bower.json.

    [enhancement] Add missing bower.json.

    Hey, maintainer(s) of ramswaroop/animatescroll.js!

    We at VersionEye are working hard to keep up the quality of the bower's registry.

    We just finished our initial analysis of the quality of the Bower.io registry:

    7530 - registered packages, 224 of them doesnt exists anymore;

    We analysed 7306 existing packages and 1070 of them don't have bower.json on the master branch ( that's where a Bower client pulls a data ).

    Sadly, your library ramswaroop/animatescroll.js is one of them.

    Can you spare 15 minutes to help us to make Bower better?

    Just add a new file bower.json and change attributes.

    {
      "name": "ramswaroop/animatescroll.js",
      "version": "1.0.0",
      "main": "path/to/main.css",
      "description": "please add it",
      "license": "Eclipse",
      "ignore": [
        ".jshintrc",
        "**/*.txt"
      ],
      "dependencies": {
        "<dependency_name>": "<semantic_version>",
        "<dependency_name>": "<Local_folder>",
        "<dependency_name>": "<package>"
      },
      "devDependencies": {
        "<test-framework-name>": "<version>"
      }
    }
    
    

    Read more about bower.json on the official spefication and nodejs semver library has great examples of proper versioning.

    NB! Please validate your bower.json with jsonlint before commiting your updates.

    Thank you!

    Timo, twitter: @versioneye email: [email protected] VersionEye - no more legacy software!

    opened by timgluz 3
Releases(1.0)
Owner
Ram
Love making teeny tiny apps solving tiny problems in life.
Ram
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
JustGage is a handy JavaScript plugin for generating and animating nice & clean dashboard gauges. It is based on Raphaël library for vector drawing.

JustGage JustGage is a handy JavaScript plugin for generating and animating nice & clean dashboard gauges. It is based on Raphaël library for vector d

Bojan Djuricic 1.8k Jan 3, 2023
infiniteScrollWithTemplate - JQuery plugin for ajax-enabled infinite page scroll / auto paging with template

jQuery Infinite With Template Plugin JQuery plugin for ajax-enabled infinite page scroll with template. If you like jQuery until now, this little libr

이삼구 2 Mar 19, 2021
A small jQuery plugin for rendering scroll-based HTML animations

Storyline Build beautiful landing pages that change as the user scrolls up or down. Project created in 2013 and ported to GitHub in 2021. Demo Just vi

Mark Jivko 3 May 30, 2022
A jQuery plugin allowing you to scroll an image within a container element

jQuery Scroll Image Inside v0.1 A jQuery plugin allowing you to scroll an image within a container element Usage <div id="window"> <img src="reall

Derek Ashauer 1 Apr 11, 2021
A simple jQuery extension to make any HTML element sticky on scroll.

jquery.sticky.js A simple jQuery extension to make any HTML element sticky on scroll. Installation Just download the script and include it in your HTM

Achal Jain 2 Aug 22, 2022
Javascript library for switching fixed elements on scroll through sections. Like Midnight.js, but without jQuery

Library for Switching Fixed Elements on Scroll Sometimes designers create complex logic and fix parts of the interface. Also they colour page sections

Vladimir Lysov 38 Sep 19, 2022
This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way, this plugin works after page load.

Jquery-SingleImagePopup This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way

Rajan Karmaker 1 Aug 22, 2022
A fullscreen scroll-based slideshow with a content view powered by GreenSock's Observer plugin.

Fullscreen Scrolling Slideshow A fullscreen scroll-based slideshow with a content view powered by GreenSock's Observer plugin. Article on Codrops Demo

Codrops 84 Jan 3, 2023
Simple scroll based text reveal animation library.

Simple scroll based text reveal animation library. ⛰️ DEMO Getting Started Using packge manager NPM Install textify using npm: npm install textify.js

Jeet 27 Dec 5, 2022
Animate on scroll library

âť— âť— âť— This is README for aos@next âť— âť— âť— For last stable release (v2) go here ?? Demo ?? Codepen Examples Different built-in animations With anchor set

Michał Sajnóg 22.3k Jan 2, 2023
Conveyer adds Drag gestures to your Native Scroll.

Conveyer Demo / Documentation / Other components Conveyer adds Drag gestures to your Native Scroll. ?? ?? ?? ✨ Features You can use Native Scroll-like

NAVER 70 Dec 15, 2022
CSS3 list scroll effects

stroll.js – because it scrolls, and trolls. A collection of CSS list scroll effects. Works in browsers with support for CSS 3D transforms including a

Hakim El Hattab 4.3k Jan 3, 2023
Animate elements as they scroll into view.

Animate elements as they scroll into view. Introduction ScrollReveal is a JavaScript library for easily animating elements as they enter/leave the vie

null 21.2k Jan 4, 2023
Reveal CSS animation as you scroll down a page

WOW.js Reveal CSS animation as you scroll down a page. By default, you can use it to trigger animate.css animations. But you can easily change the set

Matt Delac 9.7k Jan 8, 2023
Automatically make same-page links scroll smoothly

Smooth Scroll Plugin Allows for easy implementation of smooth scrolling for same-page links. Note: Version 2.0+ of this plugin requires jQuery version

Karl Swedberg 2k Dec 25, 2022
Smooth scroll animation - vanilla JavaScript

Smooth Scroll Animation Using Vanilla JavaScript Provides smooth scroll functionality on clicking buttons with different eeasing properties. The "smoo

Bhagabati Prasad 4 Aug 14, 2022
A javascript library to animate elements on scroll page events

ScrollJS by Sam Sirianni ScrollJS is a library written in Javascript. With ScrollJS you can animate elements on scroll events. Visit the ScrollJS webs

Sam Sirianni 1 Mar 21, 2021