• Stars
    star
    3,849
  • Rank 11,409 (Top 0.3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 11 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Scroll Behavior polyfill

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

More Repositories

1

react-hardware

A React renderer for Hardware.
JavaScript
793
star
2

tiny-react-renderer

Learn you a React Renderer for Great Good
JavaScript
774
star
3

yellowbox-react

YellowBox renders warnings at the bottom of the app being developed.
JavaScript
67
star
4

arbiter

A lightweight html5 history library for ender.js
JavaScript
17
star
5

component-playground-responsive-iframe

A responsive iframe renderer for the React component playground.
JavaScript
11
star
6

blessed-standup

Blessed UI for team standups, recorded in a google spreadsheet
JavaScript
7
star
7

queryless

Create a mediaquery free stylesheet for archaic browsers
CSS
7
star
8

iamdustan.github.io

HTML
6
star
9

PUI

A lightweight prototype UI library.
JavaScript
5
star
10

bonsai-demos

Article and demos concerning bonsai for node knockout 2012.
JavaScript
5
star
11

slack-imposter

Pretend to be your colleagues!
Rust
4
star
12

esprima-loader

webpack loader to pipe a fileโ€™s AST through arbitrary transforms
JavaScript
4
star
13

react-testing-stateless-components

Failing test case of `React.findDOMNode` with stateless function components.
JavaScript
4
star
14

cypress-react-test

JavaScript
3
star
15

redux-devtools-ui

Experimental UI fun for the redux devtools
JavaScript
2
star
16

d8-fun

JavaScript
2
star
17

all-things-open-2016

JavaScript
2
star
18

dotfiles

Lua
2
star
19

parse-vs-ast-startup-time

Kicked off from https://twitter.com/TheLarkInn/status/852252004277682176
JavaScript
2
star
20

babel-plugin-react-isomorphic

Babel plugin to transform react imports to react/lib/ReactIsomorphic
JavaScript
2
star
21

simplegit

A simple, stripped-down git library for nodejs.
JavaScript
2
star
22

reasonexamples_of_ocapic

OCaPIC tutorial examples on ReasonML
OCaml
2
star
23

jadeplate

A jade+stylus standalone template.
JavaScript
2
star
24

cltjs-welcome-to-the-responsive-web

Responsive slide-deck for the October 2011 CltJS meetup.
JavaScript
2
star
25

bs-audio-context

Experimental bucklescript bindings for the WebAudio API
OCaml
1
star
26

postcss-rs

WIP PostCSS compatible parser written in Rust.
Rust
1
star
27

react-ascii

maybe a new toy
1
star
28

slidenator

JavaScript
1
star
29

granger

A modern, lightweight range UI component with an aim towards integration simplicity and accessibility across all input methods.
CoffeeScript
1
star
30

reworkcss_ast_explorer

Rework CSSโ€™s AST Explorer
JavaScript
1
star
31

lendly

Never forget who you borrow your things to again! Part of The Mentorship Project.
JavaScript
1
star