GithubHelp home page GithubHelp logo

haykokoryun / retargetmousescroll Goto Github PK

View Code? Open in Web Editor NEW

This project forked from eligrey/retargetmousescroll

0.0 2.0 0.0 14 KB

A JavaScript library for retargetting mouse scroll events.

Home Page: http://eligrey.com/blog/post/retargetmousescroll

License: Other

JavaScript 19.46% HTML 80.54%

retargetmousescroll's Introduction

Version 0.0.2

RetargetMouseScroll implements a simple API to retarget mouse scroll events.

Usage

RetargetMouseScroll(
    element         :Node,        // default: document
    target          :Node/Window, // default: window
    preventDefault  :Boolean,     // default: true
    scrollMultiplier:Number       // default: 1.0
)

RetargetMouseScroll returns an object containing a restore method. Calling the method restores the default scrolling.

Examples

  • RetargetMouseScroll(myElement, myFrame) - Per-element mouse scroll retargetting to a frame
  • RetargetMouseScroll(document, window, true, 0.5) - Slow down scrolling
  • RetargetMouseScroll(document, window, true, -1) - Invert scrolling
  • RetargetMouseScroll(document, window, true, 2) - Speed up scrolling

More advanced example using a popup:

var win = window.open("/", "example", "w=" + (screen.availWidth / 3.5)
                                      + ",h=" + (screen.availHeight / 3.5)
                                      + ",scrollbars=yes,resize=yes");
win.addEventListener("DOMContentLoaded", function() {
    var retargetting = RetargetMouseScroll(document, win);
    win.onunload = function () {
	    retargetting.restore();
    };
}, false);

In the previous example, all mouse scrolling on the main document is retargetted to the popup until it is closed.

Known Supported Browsers

  • Firefox
    • 1.5? *
    • 2 *
    • 3
    • 3.5
  • Opera *
    • 9
    • 10
  • Internet Explorer *
    • 7?
    • 8
  • Google Chrome
    • 1?
    • 2
    • 3
  • Safari *
    • 3?
    • 4

* Does not support horizontal scroll capturing and retargetting

If the version number is followed by a "?", I'm assuming it works but I haven't tested it yet.

Testers Needed

I need testers to contact me if RetargetMouseScroll works (or doesn't work) in their browsers. Please make sure to mention if it also works with horizontal scrolling.

Tracking image

retargetmousescroll's People

Contributors

eligrey avatar haykokoryun avatar jamesryanbell avatar

Watchers

 avatar  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.