🛤 Detection of elements in viewport & smooth scrolling with parallax.

Overview

Locomotive Scroll

Detection of elements in viewport & smooth scrolling with parallax effects.

Installation

⚠️ Scroll-hijacking is a controversial practice that can cause usability, accessibility, and performance issues. Please use responsibly.

npm install locomotive-scroll

Usage

Basic

With simple detection.

HTML

<h1 data-scroll>Hey</h1>
<p data-scroll>👋</p>

CSS

Add the base styles to your CSS file.

locomotive-scroll.css

JS

With a bundler
import LocomotiveScroll from 'locomotive-scroll';

const scroll = new LocomotiveScroll();
Or without
<script src="locomotive-scroll.min.js"></script>
<script>
    (function () {
        var scroll = new LocomotiveScroll();
    })();
</script>

Get the JS file.

Smooth

With smooth scrolling and parallax.

<div data-scroll-container>
    <div data-scroll-section>
        <h1 data-scroll>Hey</h1>
        <p data-scroll>👋</p>
    </div>
    <div data-scroll-section>
        <h2 data-scroll data-scroll-speed="1">What's up?</h2>
        <p data-scroll data-scroll-speed="2">😬</p>
    </div>
</div>
import LocomotiveScroll from 'locomotive-scroll';

const scroll = new LocomotiveScroll({
    el: document.querySelector('[data-scroll-container]'),
    smooth: true
});

Note: scroll-sections are optional but recommended to improve performance, particularly in long pages.

Advanced

Make it do what you want.

With methods

<section id="js-target">Come here please.</section>
import LocomotiveScroll from 'locomotive-scroll';

const scroll = new LocomotiveScroll();
const target = document.querySelector('#js-target');

scroll.scrollTo(target);

With events

<!-- Using modularJS -->
<div data-scroll data-scroll-call="function, module">Trigger</div>
<!-- Using jQuery events -->
<div data-scroll data-scroll-call="EVENT_NAME">Trigger</div>
<!-- Or do it your own way 😎 -->
<div data-scroll data-scroll-call="{y,o,l,o}">Trigger</div>
import LocomotiveScroll from 'locomotive-scroll';

const scroll = new LocomotiveScroll();

scroll.on('call', func => {
    // Using modularJS
    this.call(...func);
    // Using jQuery events
    $(document).trigger(func);
    // Or do it your own way 😎
});

Instance options

Option Type Default Description
el object document Scroll container element.
name string 'scroll' Data attribute prefix (data-scroll-xxxx).
offset array(2) [0,0] Global in-view trigger offset : [bottom,top]
Use a string with % to use a percentage of the viewport height.
Use a numeric value for absolute pixels unit.
E.g. ["30%",0], [100,0], ["30%", 100]
repeat boolean false Repeat in-view detection.
smooth boolean false Smooth scrolling.
initPosition object { x: 0, y: 0 } Smooth only
An object defining the initial scroll coordinates on a smooth instance. For example: { x: 0, y: 1000 }
direction string vertical Smooth only
Scroll direction: vertical or horizontal
lerp number 0.1 Smooth only
Linear interpolation (lerp) intensity. Float between 0 and 1.
This defines the "smoothness" intensity. The closer to 0, the smoother.
getDirection boolean false Add direction to scroll event.
getSpeed boolean false Add speed to scroll event.
class string is-inview Element in-view class.
initClass string has-scroll-init Initialize class.
scrollingClass string has-scroll-scrolling Is scrolling class.
draggingClass string has-scroll-dragging Is dragging class.
smoothClass string has-scroll-smooth Has smooth scrolling class.
scrollbarContainer object false Smooth only
Specifies the container element for the scrollbar to be appended in. If false, scrollbar will be appended to the body.
scrollbarClass string c-scrollbar Smooth only
Scrollbar element class.
multiplier number 1 Smooth only
Factor applied to the scroll delta, allowing to boost/reduce scrolling speed (regardless of the platform).
firefoxMultiplier number 50 Smooth only
Boost scrolling speed of Firefox on Windows.
touchMultiplier number 2 Smooth only
Multiply touch action to scroll faster than finger movement.
scrollFromAnywhere boolean false Smooth only
By default locomotive-scroll listens for scroll events only on the scroll container (el option). With this option set to true, it listens on the whole document instead.
gestureDirection string vertical Smooth only
Defines which gesture direction(s) scrolls in your instance. You can use :
  • vertical
  • horizontal
  • both
tablet & smartphone object Object allowing to override some options for a particular context. You can specify:
  • smooth
  • direction
  • horizontalGesture
For tablet context you can also define breakpoint (integer, defaults to 1024) to set the max-width breakpoint for tablets.
reloadOnContextChange boolean false Allows to reload the page when switching between desktop, tablet and smartphone contexts. It can be useful if your page changes a lot between contexts and you want to reset everything.
resetNativeScroll boolean true Sets history.scrollRestoration = 'manual' and calls window.scrollTo(0, 0) on locomotive-scroll init in Native Class. Useful if you use transitions with native scrolling, otherwise we advise to set it to false if you don't want to break History API's scroll restoration feature.

Element attributes

Attribute Values Description
data-scroll Detect if in-view.
data-scroll-id string (Optional) Useful if you want to scope your element and get the progress of your element in the viewport for example.
data-scroll-container Defines the scroll container. Required for basic styling.
data-scroll-section Defines a scrollable section. Splitting your page into sections may improve performance.
data-scroll-class string Element in-view class.
data-scroll-offset string Element in-view trigger offset : bottom,top
First value is bottom offset, second (optional) is top offset.
Percent is relative to viewport height, otherwise it's absolute pixels.
E.g. "10", "100,50%", "25%, 15%"
data-scroll-repeat boolean Element in-view detection repeat.
data-scroll-call string Element in-view trigger call event.
data-scroll-position string top, bottom, left or right
Window position of in-view trigger.
data-scroll-speed number Smooth only
Element parallax speed. A negative value will reverse the direction.
data-scroll-delay number Smooth only
Element's parallax lerp delay.
data-scroll-direction string Smooth only
Element's parallax direction. vertical or horizontal
data-scroll-sticky Smooth only
Sticky element. Starts and stops at data-scroll-target position.
data-scroll-target string Smooth only
Target element's in-view position.

Instance methods

Method Description Arguments
init() Reinitializes the scroll.
on(eventName, function) Listen instance events .
update() Updates all element positions.
destroy() Destroys the scroll events.
start() Restarts the scroll events.
stop() Stops the scroll events.
scrollTo(target, options) Scroll to a target.
target: Defines where you want to scroll. Available values types are :
  • node : a dom element
  • string : you can type your own selector, or use values "top" and "bottom" to reach scroll boundaries
  • int : An absolute scroll coordinate in pixels
options (optional, object) : Settings object. Available values are:
  • offset (integer) : Defines an offset from your target. E.g. -100 if you want to scroll 100 pixels above your target
  • callback (function) : Called when scrollTo completes (note that it won't wait for lerp to stabilize)
  • duration (integer) : Defines the duration of the scroll animation in milliseconds. Defaults to 1000
    Smooth only
  • easing (array) : An array of 4 floats between 0 and 1 defining the bezier curve for the animation's easing.
    Defaults to [0.25, 0.00, 0.35, 1.00]
    See https://greweb.me/2012/02/bezier-curve-based-easing-functions-from-concept-to-implementation
    Keep in mind this will also be affected by the lerp unless you set disableLerp to true.
    Smooth only
  • disableLerp (boolean) : Lerp effect won't be applied if set to true
    Smooth only

Instance events

Event Arguments Description
scroll obj Returns scroll instance (position, limit, speed, direction and current in-view elements).
call func Trigger if in-view. Returns your string or array if contains ,.

Progressive playing animations example (like gsap)

All data-scroll elements have a progress value. In the on scroll event you can get all current in-view elements.

HTML

<h1 data-scroll data-scroll-id="hey">Hey</h1>

JS

scroll.on('scroll', (args) => {
    // Get all current elements : args.currentElements
    if(typeof args.currentElements['hey'] === 'object') {
        let progress = args.currentElements['hey'].progress;
        console.log(progress);
        // ouput log example: 0.34
        // gsap example : myGsapAnimation.progress(progress);
    }
});

Dependencies

Name Description
Virtual Scroll Custom scroll event with inertia/momentum.
modularScroll Elements in viewport detection. Forked from it, not a dependency.
bezier-easing Allows to define an easing to scrollTo movement

Browser support

Works on most modern browsers. Chrome, Firefox, Safari, Edge...

To get IE 11 support, you need polyfills. You can use your own or include these before our script.

<script nomodule src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.6.0/polyfill.min.js" crossorigin="anonymous"></script>
<script nomodule src="https://polyfill.io/v3/polyfill.min.js?features=Object.assign%2CElement.prototype.append%2CNodeList.prototype.forEach%2CCustomEvent%2Csmoothscroll" crossorigin="anonymous"></script>

Who's using Locomotive Scroll?

Related

Comments
  • Body not resizing properly when smooth:true

    Body not resizing properly when smooth:true

    Hello 👋

    Describe the bug

    On last version 3.2.5.

    When smooth="true" , depending on the resize : bigger or smaller body will not adapt to the js-scroll container creating a white space under the page or cropping the footer.

    We've tried to force the resize to update the container with scroll.update(). We also copied the style from your demo (html, body & scroll container) without any good result.

    To Reproduce

    You can see our issue here

    Expected behavior

    Basically the same behavior as when smooth = "false";

    Desktop:

    • Tested in Windows and OS
    • Chrome, Mozilla & Safari latest version.

    We love LS thanks in advance for your help 👊

    opened by Avisseau 24
  • How to use it with

    How to use it with "Barba.js"

    Hello. How to use this plugin with barba.js? Is it correct way?

    const scroll = new LocomotiveScroll({
    	el: document.querySelector('[data-scroll-container]'),
    	smooth: true,
    	getSpeed: true,
    	getDirection: true
    });
    // tell Barba to use the prefetch module
    //barba.use(barbaPrefetch);
    barba.hooks.afterEnter((data) => {
    	scroll.init();
    });
    barba.hooks.afterLeave((data) => {
    	scroll.destroy();
    }); 
    
    opened by ulziibat-n 20
  • [SOLVED] LocoMotive Scroll isn't working on mobile view

    [SOLVED] LocoMotive Scroll isn't working on mobile view

    Hello 👋

    Describe the bug Features aren't working on mobile. :'(

    To Reproduce Steps to reproduce the behavior:

    1. Go to 'fix-me'
    2. Open it in Mobile
    3. Scroll down to
    4. See error

    Expected behavior The features I've used aren't working like data-scroll data-scroll-direction data-scroll-speed. the strange things is that everything is stopped.

    Screenshots

    https://user-images.githubusercontent.com/54703305/128642272-09c6e4f9-b8cd-444f-88fa-49919bdf8f26.mp4

    have to work like this

    https://user-images.githubusercontent.com/54703305/128642377-426c7925-3787-4925-a887-70c6992cca56.mov

    Desktop (please complete the following information):

    • OS: MacOs Big sur
    • Browser: chrome
    • Version: latest

    Smartphone (please complete the following information):

    • Device: Realme C3
    • OS: Android
    • Browser: Chrome
    • Version: Latest

    Thank you 👊

    opened by whizzbbig 19
  • Updating Scroll height on page change

    Updating Scroll height on page change

    We are using Locomotive Scroll (LS) on a site that utilizes a page transition plugin. When we transition to a new page sometime LS doesn't allow the user to scroll all the way down. I'm guessing this has something to do with the page not fully loaded when LS is initialized. From what I can tell, the Locomotive site is similar. How do you all get around this obstacle. Any insights would be highly appreciated!

    opened by carlfmichel 19
  • On refresh does not scroll up to top

    On refresh does not scroll up to top

    Hello 👋

    Describe the bug When I refresh the page most of the time the current position is calculated as top of the page. To make it clear. If I scrolled down to half of the page and refresh it then the top of the page will be at the half of the page. I cannot scroll up but I can scroll down having blank section.

    To Reproduce Here is my very basic structure

    <div id="loco-scroll"> <div class="one vertical red" data-scroll data-scroll-speed="0" data-scroll-direction="vertical" ></div> <div class="two horizontal green" data-scroll data-scroll-speed="4" data-scroll-direction="horizontal" ></div> <div class="three horizontal blue" data-scroll data-scroll-speed="2" data-scroll-direction="horizontal" ></div> <div class="four horizontal yellow" data-scroll data-scroll-speed="2" data-scroll-direction="horizontal" ></div> <div class="five vertical orange" data-scroll data-scroll-speed="2" data-scroll-direction="vertical" ></div> </div> <script src="js/locomotive-scroll.js"></script> <script> const scroll = new LocomotiveScroll({ el: document.querySelector('#loco-scroll'), smooth: true, }); </script>

    stylesheet `#loco-scroll div { width: 100vw; height: 100vh; }

    .red { background-color: red; } .green { background-color: green; } .blue { background-color: blue; } .yellow { background-color: yellow; } .orange { background-color: orange; }`

    Expected behavior Jump to top of the page

    Screenshots If applicable, add screenshots to help explain your problem.

    Desktop (please complete the following information):

    • OS: macOS Catalin v10.15.2
    • Browser same thing happens in Safari, Firefox, Chrome
    • Version latest

    Thank you 👊

    Laszlo

    opened by Lacika1981 18
  • Update c-scrollbar_thumb height on resize

    Update c-scrollbar_thumb height on resize

    Hi, awesome plugin. One of the issues I've found is that the thumb height of '.c-scrollbar_thumb' is not updated on window resizes. It happens on the test site as well. I don't know if it's related, but the positions of the elements are not updated as well when resizing the window, only after you do a manual scroll. I tried calling scroll.update(), on a window resize listener, but it didn't work.

    How do I get everything updated after resizing the window? Thanks!

    opened by jmartinezuk 18
  • You can't scroll when your mouse is over an iframe

    You can't scroll when your mouse is over an iframe

    Hello 👋

    Describe the bug You can't scroll when your mouse is over an iframe

    To Reproduce Steps to reproduce the behavior:

    1. Embed a youtube iframe
    2. Try to scroll when your mouse is over it

    Expected behavior You should be able to scroll even if your mouse is over an iframe

    Desktop (please complete the following information): MacOS 10.15.7 with Chrome Version 87.0.4280.88 (Build officiel) (x86_64)

    Thank you 👊

    opened by nickchartier11 13
  • Sticky elements don't stay inside parent after resizing the browser

    Sticky elements don't stay inside parent after resizing the browser

    Hi there,

    First of all, awesome stuff, I love it. I just found a little bug that is pretty annoying. When an element is set to sticky, if you scroll past it's wrapper and then you resize your browser, it's positioning gets all funky and it starts to stay sticked beyond it's wrapper dimensions. The bug is present on your demo page too. Scroll past the 04 Fixed elements section then open the console (or just resize your browser) and you'll see what I mean.

    image

    Thank you!

    bug 
    opened by patchampoux 13
  • Horizontal Scroll

    Horizontal Scroll

    Hi,

    I need the horizontal scroll for a specific page and I tried to change the direction option to "horizontal" without any effect.

    Could you give me some hints to have the horizontal scroll, like you did for this website?

    https://homesociete.ca/

    Thanks!

    enhancement work-in-progress 
    opened by fedeweb 13
  • Incorrect scroll limit height on Gatsby

    Incorrect scroll limit height on Gatsby

    Describe the bug Page height is incorrectly measured by LS and so the scroll ends too early or a bit after the content ends. On deeper inspection, it seems that the limit on the scroll instance gets an incorrect value on initializing. I've tried fixing this by adding an update() call after a timeout to no avail.

    To Reproduce Steps to reproduce the behavior:

    1. Setup locomotive scroll on Gatsby
    2. Add content to page and scroll

    I'll attempt to provide a demo reproducing the error later, but if anyone has a CodeSandbox to show the issue that'd be great (cc @flowen)

    Expected behavior The scroll should happen till page end not before or after: technically the right value set to limit

    Desktop (please complete the following information):

    • OS: MacOS Catalina
    • Browser: Chrome
    • Version 80
    opened by ajayns 12
  • Incorrect height, but after resize viewport it work.

    Incorrect height, but after resize viewport it work.

    Hello! I have problem with height of scroll container. I used also scrollTrigger and BarbaJS, but I think is a Smoothscroll problem.

    barba.hooks.after(() => {
        scroll.update();
      });
    

    Do not solve my problem, because also without BarbaJs the footer and other content will cutted off.

    For an old project I used this:

    function locomotiveHeightBug(){
      scroll.update();
    }
    setInterval(locomotiveHeightBug, 5000);
    

    It solve the problem but after 5 seconds, but sometimes the scroll jump. That's so bad. Without that bad trick, when I refresh the page for the first time, and than resize the viewport, magically the scroll container give me the exact height.

    Someone have the same problem? How to fix it? Thanks.

    opened by francescocortese 11
  • Locomotive Scroll / GSAP (Horizontal Scroll)

    Locomotive Scroll / GSAP (Horizontal Scroll)

    Hello 👋

    We have two horizontal scroll in the same page. The probleme is that when we scroll in a mobile the second scroll crash (the first one come over the second).

    ` const scroller = document.querySelector('#scroller');

          const locoScroll = new LocomotiveScroll({
            el: scroller,
            smooth: true,
            mobile: {
              smooth: true,
            },
            tablet: { 
              smooth: true,
            }
          });
    
          ScrollTrigger.scrollerProxy(scroller, {
            scrollTop(value) {
              return arguments.length ? locoScroll.scrollTo(value, 0, 0) : locoScroll.scroll.instance.scroll.y;
            }, 
            getBoundingClientRect() {
              return {top: 0, left: 0, width: window.innerWidth, height: window.innerHeight};
            },
            // LocomotiveScroll handles things completely differently on mobile devices - it doesn't even transform the container at all! So to get the correct behavior and avoid jitters, we should pin things with position: fixed on mobile. We sense it by checking to see if there's a transform applied to the container (the LocomotiveScroll-controlled element).
            pinType: scroller.style.transform ? "transform" : "fixed"
          });
          
          ScrollTrigger.defaults({
            scroller: scroller
          })
          const horizontalSections = gsap.utils.toArray('section.horizontal')`
    

    `horizontalSections.forEach(function (sec, i) {

    var thisPinWrap = sec.querySelector('.pin-wrap'); var thisAnimWrap = thisPinWrap.querySelector('.animation-wrap');

    var getToValue = () => -(thisAnimWrap.scrollWidth - window.innerWidth);

    gsap.fromTo(thisAnimWrap, { x: () => thisAnimWrap.classList.contains('to-right') ? 0 : getToValue() }, { x: () => thisAnimWrap.classList.contains('to-right') ? getToValue() : 0, ease: "none", scrollTrigger: {
    trigger: sec,
    scroller: scroller, start: "top top", end: () => "+=" + (thisAnimWrap.scrollWidth - window.innerWidth), pin: thisPinWrap, invalidateOnRefresh: true, anticipatePin: 1, scrub: true, //markers: true } });

    }); ScrollTrigger.addEventListener("refresh", () => locoScroll.update()); ScrollTrigger.refresh(); `

    Thank you 👊

    opened by Justine4s 0
  • Empty space at the bottom of the page

    Empty space at the bottom of the page

    Hello 👋

    After scrolling the pages to the bottom, there is an empty space. When I restart the site, the bottom always changes, then there is an empty space, then the footer disappears

    I need that there is no empty space at the bottom of the site. Style file included locally

    • OS: Windows 10
    • Browser e.g
    • Version [e.g. 108.0.1462.54]

    Thank you 👊

    opened by filonenkoweb 2
  • Horizonal Scroll + GSAP - Mobile Resets to Top

    Horizonal Scroll + GSAP - Mobile Resets to Top

    Hello 👋

    I am having a very weird issue and was wondering if anyone has come across something similar. I know a lot of people use horizonal scroll sections with Locomotive + GSAP so I am asking here.

    Issue: I have a horizontal scroll section that works amazing on desktop, but when I try on mobile or tablet devices the moment the scroll finishes, it gets pulled back to the top. It basically resets the scroll to 0 (The top).

    Here is the code pen with the exact code: (The issue wont happen on mobile inside the codepen, youll have to visit my website) https://codepen.io/cassie-codes/pen/ZEeeyOX/7663b55b05f5d473c0e61732fb9174b4

    Here is the issue on my live server so you can see the behavior: https://shanefry.com/test

    https://user-images.githubusercontent.com/118708070/209584653-a1829480-e54e-4783-993e-f5954fae5190.mp4

    opened by ShaneFry 0
  • Lerp causing choppy mousewheel scroll

    Lerp causing choppy mousewheel scroll

    Hello 👋

    Describe the bug

    I am using locomotivescroll on a couple of websites and I really like the smooth scroll effect. However, I have noticed that, when setting the lerp instance option to anything above the default 0.1, scrolling with the mouse wheel feels choppy. Effectively, the root cause of this issue is that the transform: matrix3d() b4 value stops as soon as the mousewheel does. This is particularly visible when setting lerp: 0.8 and using the mousewheel to scroll up and down, on both Windows and MacOS.

    To Reproduce

    A simple, reproducible example of the issue can be found here https://github.com/developedbygeo/locomotive-issue . Feel free to fork the repository to try it out.

    Expected behavior For the scroll to be relatively smooth, based on the lerp, and not choppy. The issue disappears when reverting to the default lerp value or when using a trackpad with the same lerp value.

    Desktop (please complete the following information):

    • OS: MacOS Monterey 12.5, Win10
    • Browser: Chrome, Firefox

    Thank you in advance!

    opened by developedbygeo 0
  • Elements above the fold not delaying - Fades in immediately

    Elements above the fold not delaying - Fades in immediately

    Hi guys,

    Describe the bug One page load, the very first section that is seen, above the fold, does not seem to respect the delay attribute. Elements fade in immediately instead of being delayed. I notice that the 'in-view' class is added immediately. Is there a way to delay this?

    I hope this is clear enough.

    opened by awinante 0
  • Bump decode-uri-component from 0.2.0 to 0.2.2

    Bump decode-uri-component from 0.2.0 to 0.2.2

    Bumps decode-uri-component from 0.2.0 to 0.2.2.

    Release notes

    Sourced from decode-uri-component's releases.

    v0.2.2

    • Prevent overwriting previously decoded tokens 980e0bf

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.1...v0.2.2

    v0.2.1

    • Switch to GitHub workflows 76abc93
    • Fix issue where decode throws - fixes #6 746ca5d
    • Update license (#1) 486d7e2
    • Tidelift tasks a650457
    • Meta tweaks 66e1c28

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.1

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
Releases(4.1.4)
  • 4.1.4(May 3, 2022)

  • 4.0.0(Nov 16, 2020)

    Changelog

    New features

    • Add horizontal scrolling (usage example: horizontal.html).
    • Update export to only import the native Class.
    • Update scrollTo parameters with the options object (offset, duration, easing...).
    • Add context system to set specific options for desktop , tablet and mobile separately.
    • Rewrite the instance options. Learn more
    • Add data-scroll-id="" attribute to select elements.
    • Add currents "in view" elements as object in the on scroll event.
    • Add a progress value from 0 to 1, while the element is in the viewport. Useful to play an animation for example. Learn more

    Export updates It's now possible to only import the Native Class, if you don't want the smooth scrolling.

    As usual, you can do like this:

    import LocomotiveScroll from 'locomotive-scroll';
    

    Or just import the Native Class:

    import { Native } from 'locomotive-scroll';
    

    And create your instance like before

    // const scroll = new LocomotiveScroll(options);
    const scroll = new Native(options);
    
    Source code(tar.gz)
    Source code(zip)
  • 3.5.0(May 27, 2020)

    Changelog

    New features

    • Add scrollFromAnywhere option
    • Add multiplier option
    • Rename inertia option to lerp

    Issues fixed

    #128, #131, #110, #104

    Source code(tar.gz)
    Source code(zip)
Stellar.js - Parallax scrolling made easy

Stellar.js PLEASE NOTE: This project is no longer maintained. If parallax scrolling is something you care about, please apply to become a contributor

Mark Dalgleish 4.6k Dec 10, 2022
Smooth scrolling for the web

iScroll, smooth scrolling for the web iScroll is a high performance, small footprint, dependency free, multi-platform javascript scroller. It works on

Matteo Spinelli 12.9k Jan 4, 2023
Parallax Engine that reacts to the orientation of a smart device

Parallax Engine that reacts to the orientation of a smart device. Where no gyroscope or motion detection hardware is available, the position of the cu

Matthew Wagerfield 16k Jan 8, 2023
jQuery plugin for creating interactive parallax effect

jquery.parallax What does jquery.parallax do? jquery.parallax turns nodes into absolutely positioned layers that move in response to the mouse. Depend

stephband 1.1k Nov 25, 2022
Simple and tiny JavaScript library that adds parallax animations on any images

simpleParallax.js simpleParallax.js is a very simple and tiny Vanilla JS library that adds parallax animations on any images. Where it may be laboriou

Geoffrey 1.5k Jan 3, 2023
Lightweight, vanilla javascript parallax library

RELLAX Rellax is a buttery smooth, super lightweight, vanilla javascript parallax library. Update: Rellax now works on mobile (v1.0.0). Demo Website G

Dixon & Moe 6.7k Dec 30, 2022
Smooth WebGL Shader Transformations on Scroll

Rock the Stage with a Smooth WebGL Shader Transformation on Scroll A handy setup to create a smooth scroll based GLSL animation using Three.js and GSA

Faboolea 97 Dec 25, 2022
Simple & lightweight (<4kb gzipped) vanilla JavaScript library to create smooth & beautiful animations when you scroll.

lax.js Simple & lightweight (<4kb gzipped) vanilla JavaScript library to create smooth & beautiful animations when you scroll. >> DEMO << What's new w

Alex Fox 9.4k Dec 29, 2022
Dragscroll is a micro library for drag-n-drop scrolling style

Dragscroll is a micro JavaScript library (910 bytes minified) which enables scrolling via holding the mouse button ("drag and drop" or "click and hold" style, online demo). It has no dependencies and is written in vanilla JavaScript (which means it works anywhere).

Dmitry Prokashev 1.1k Dec 21, 2022
BetterScroll is a plugin which is aimed at solving scrolling circumstances on the mobile side (PC supported already).

BetterScroll is a plugin which is aimed at solving scrolling circumstances on the mobile side (PC supported already).

HuangYi 15.9k Dec 30, 2022
A simple and fast API to monitor elements as you scroll

scrollMonitor The scroll monitor allows you to receive events when elements enter or exit a viewport. It does this using watcher objects, which watch

Stu Kabakoff 3.3k Jan 4, 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

Julian Lloyd 21.2k Jan 4, 2023
Stand-alone parallax scrolling library for mobile (Android + iOS) and desktop. No jQuery. Just plain JavaScript (and some love).

Please note: skrollr hasn't been under active development since about September 2014 (check out the contributions graphs on https://github.com/Prinzho

Alexander Prinzhorn 18.6k Jan 3, 2023
Stellar.js - Parallax scrolling made easy

Stellar.js PLEASE NOTE: This project is no longer maintained. If parallax scrolling is something you care about, please apply to become a contributor

Mark Dalgleish 4.6k Dec 10, 2022
Simple parallax scrolling effect inspired by Spotify.com implemented as a jQuery plugin

Parallax.js Simple parallax scrolling implemented as a jQuery plugin. http://pixelcog.com/parallax.js/ Please also check our v2.0.0-alpha! We'd be hap

PixelCog Inc. 3.5k Dec 21, 2022
Slickscroll - A Lightweight JavaScript library for quick and painless momentum & parallax scrolling effects.

Slickscroll is a JavaScript library that makes momentum & parallax scrolling quick and painless View Demo: slickscroll.musabhassan.com Momentum Scroll

Musab Hassan 33 Dec 28, 2022
Seamless and lightweight parallax scrolling library implemented in pure JavaScript utilizing Hardware acceleration for extra performance.

parallax-vanilla.js Seamless and lightweight parallax scrolling library implemented in pure JavaScript utilizing Hardware acceleration for extra perfo

Erik Engervall 91 Dec 16, 2022
Parallax scrolling jQuery plugin

paroller.js A lightweight jQuery plugin that enables parallax scrolling effect You can use it on elements with background property or on any other ele

null 579 Dec 26, 2022
A ScrollSpy library for detecting enter/exit of elements in the viewport when the user scrolls

jquery-scrollspy A jQuery plugin for detecting enter/exit of elements in the viewport when the user scrolls. New Features Added a couple new features:

John Smart 276 Jul 1, 2022
Smooth scrolling for the web

iScroll, smooth scrolling for the web iScroll is a high performance, small footprint, dependency free, multi-platform javascript scroller. It works on

Matteo Spinelli 12.9k Jan 4, 2023