Coder Social home page Coder Social logo

ponychoker / smoothscroll Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iamdustan/smoothscroll

0.0 0.0 0.0 295 KB

Scroll Behavior polyfill

Home Page: http://iamdustan.com/smoothscroll/

License: MIT License

JavaScript 51.75% HTML 48.25%

smoothscroll's Introduction

Smooth Scroll behavior polyfill

The Scroll Behavior specification has been introduced as an extension of the Window interface to allow for the developer to opt in to native smooth scrolling. To date this has only been implemented in Chrome, Firefox and Opera.

Check out all the methods covered here: https://iamdustan.github.io/smoothscroll

Installation and use

Download the production ready file here and include it in your project, or install it as a package.

# npm
npm install smoothscroll-polyfill --save

# yarn
yarn add smoothscroll-polyfill

When including the polyfill in a script tag, it will run immediately after loaded.

If you are importing it as a dependency, make sure to call the polyfill method:

import smoothscroll from 'smoothscroll-polyfill';

// kick off the polyfill!
smoothscroll.polyfill();

In both cases, the script will detect if the spec is natively supported and take action only when necessary.

The code requires requestAnimationFrame polyfill for browsers which don't support it.

Force polyfill implementation

If you prefer to always override the native scrolling methods, place this global variable before requiring the module or including the polyfill file.

window.__forceSmoothScrollPolyfill__ = true;

We strongly recommend not to do this unless your project strongly needs it.

Contribute

The requirements to contribute are yarn and the latest LTS Node.js version.

First, fork the repository and do yarn install in the root folder to get all the dependencies to work with. Create a feature branch, write your stuff and run yarn test to check code style and prevent bugs.

In this project we use Prettier to format the final published code, you can run yarn format before committing. If you don't, a precommit hook will prevent you from pushing code that hasn't been formatted properly.

Are you done? Awesome, submit a pull request explaining your changes.

This is a polyfill, not library, so make sure the behavior you are introducing is in the spec.

On tests files we are using ES2015, but the polyfill is written in ES5 for browser compatibility.

Watch tests

If you want to watch tests as you write your code run yarn test --watch.

Browser Support

Successfully working in:

  • natively supported in Chrome
  • natively supported in Firefox
  • Safari 6+
  • Internet Explorer 9+
  • Microsoft Edge 12+
  • Opera Next

Standards documentation

smoothscroll's People

Contributors

jeremenichelli avatar iamdustan avatar asos-robertmorgan avatar ffuubarbuzz avatar dougroyal avatar dylanpiercey avatar giosensation avatar jbernardyoobic avatar jossmac avatar limonte avatar mmvas avatar staabm avatar phloe avatar tronsha avatar timgluz avatar tjgrathwell avatar trezy avatar tvler avatar vsn4ik avatar ghybs avatar strarsis 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.