Giter Site home page Giter Site logo

drag-scroller's Introduction

Drag Scroller

Allows a container to be scrolled horizontally by mouse, equivalent to dragging a touch screen.

Example

https://woollymittens.github.io/drag-scroller/

Instructions

import { DragScroller } from "./drag-scroller.js";

Snap Scroll

const snapScroller = new DragScroller({
    container: document.querySelector('.drag-scroller.snap'),
    increments: document.querySelectorAll('.drag-scroller.snap article'),
    snap: { behavior: "smooth", block: "nearest", inline: "start" },
    scrollHandler: () => {},
    interactionHandler: () => {}
});

container : {DOM element} - The overflow container within which the content scrolls.

increments : {DOM elements} - The individual content elements to which the scrolling should be rounded off to.

snap : {Object} - Configuration formatted accordion to the scrollIntoView method.

scrollHandler : {Event handler} - An event handler that triggers whenever the container scrolls.

scrollHandler : {Event handler} - An event handler that triggers only when the container is directly operated by mouse or touch.

Inertia Scroll

const inertiaScoller = new DragScroller({
    container: document.querySelector('.drag-scroller.inertia'),
    decay: 0.9,
    scrollHandler: () => {}
});

decay : {Fraction} - A factor between 0 (instant) and 1 (forever) that controls the inertia after dragging.

License

© Maurice van Creij. Licensed under The MIT License.

drag-scroller's People

Watchers

Maurice van Creij avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.