GithubHelp home page GithubHelp logo

solertis / scrolltobyspeed Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ryanburnette/scroll-to-by-speed

0.0 2.0 0.0 307 KB

Scroll by speed instead of duration.

Home Page: http://ryanburnette.github.io/scrollToBySpeed/

License: Other

JavaScript 100.00%

scrolltobyspeed's Introduction

scrollToBySpeed

It seems whack to choose a duration when animating window scrolling to the position of an element. That element might be close by causing a super slow scroll. It also might be far away causing the window to scroll at warp speed.

This plugin let's you scroll the window by speed rather than by duration.

Usage

Include the plugin on your page or compile it into your libraries.

<script src="scrolltobyspeed.jquery.js"></script>

Now when we want the window to scroll we give it a speed rather than a duration.

$('#element').scrollToBySpeed({
  speed: 1000
});

We can also add an offset to the destination scroll position.

$('#element').scrollToBySpeed({
  speed: 1000,
  offset: -100
});

Set the easing if desired.

$('#element').scrollToBySpeed({
  easing: 'linear'
});

The default scrolling context is the entire window. To scroll within another scrollable element specify the context as either a selector string or a jQuery object.

$('#element').scrollToBySpeed({
  context: '.foo'
});

If custom easing or callbacks are desired, use the plugin to get the duration and animate manually.

function () {
  var $element = $('#element'),
      duration = $element.scrollToBySpeed({mode:'duration'});

  ...
}

Bower

This plugin is available via Bower.

bower install scrollToBySpeed

Contributing

Everyone is welcome to open issues or make pull requests.

Versions

  • v0.3.0 2014-07-18

    • Thanks to @cdCorey for adding scrolling context
  • v0.2.1 2014-04-07

    • Add easing option
  • v0.2.0 2014-04-07

    • Don't handle event binding, just the scrolling
    • Allow return of duration
  • v0.1.0 2014-04-01

    • Initial

License

Apache2

scrolltobyspeed's People

Contributors

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