Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

seamless-scroll-polyfill

magic-akari174.5kMIT2.3.4TypeScript support: included

Smooth Scroll behavior polyfill

smooth, scroll, scrollIntoView, CSSOM, polyfill

readme

Build Status

This repo is forked from iamdustan/smoothscroll and rewritten with TypeScript.

Installation and use

# npm
npm install seamless-scroll-polyfill --save

# yarn
yarn add seamless-scroll-polyfill

Use polyfill to patch all methods

import { polyfill } from "seamless-scroll-polyfill";

polyfill();

Use specific polyfill

import { elementScrollIntoViewPolyfill } from "seamless-scroll-polyfill";

elementScrollIntoViewPolyfill();

Use methods directly without patching

import { scrollIntoView } from "seamless-scroll-polyfill";

scrollIntoView(document.querySelector("#target"), { behavior: "smooth", block: "center", inline: "center" });

Import via script

<!-- please replace the `latest` with specific version -->
<script src="https://cdn.jsdelivr.net/npm/seamless-scroll-polyfill@latest"></script>
<script>
    // patch all methods
    seamless.polyfill();
    // or use specific methods
    seamless.scrollBy(window, { behavior: "smooth", top: 200, left: 0 });

    seamless.scrollIntoView(document.querySelector("#target"), {
        behavior: "smooth",
        block: "center",
        inline: "center",
    });
</script>

Changelog

Detailed changes for each release are documented in CHANGELOG.md.

Thanks

changelog

2.3.4 (2023-03-21)

Bug Fixes

  • remove browser from package.json (e5c0748)

2.3.3 (2023-03-08)

Bug Fixes

  • types for nodenext in cjs (6e20245)

2.3.2 (2023-03-08)

Bug Fixes

  • modifyWindow should not be public (a98f724)
  • exclude config from npm pack (2612851)

2.3.1 (2023-03-02)

Bug Fixes

2.3.0 (2023-01-26)

Features

  • support scrollend event (5072b41)

2.2.1 (2023-01-26)

Bug Fixes

2.2.0 (2022-06-24)

Features

  • add configuration to force polyfill's use (#136) (93d1818)

2.1.8 (2022-02-19)

Bug Fixes

  • downlevel to es2015 target (d1d7e01)

2.1.7 (2022-02-17)

Bug Fixes

  • use .cjs as bundle extension (be50916)

2.1.6 (2021-12-05)

Bug Fixes

  • allow tree-shake if necessary (aae469f)

2.1.5 (2021-10-25)

Bug Fixes

  • change the output target to es2020 for more compatibility (c0f5a08)

2.1.4 (2021-09-23)

Bug Fixes

  • correct nearest position (f194982)

2.1.3 (2021-09-20)

Bug Fixes

  • make sure Element#scroll === HTMLElement#scroll === SVGElement#scroll (0eae3a4)

2.1.2 (2021-09-13)

Bug Fixes

  • call scroll directly to avoid loop deps (c61cf19)

2.1.1 (2021-09-11)

Bug Fixes

  • workaround isConnected for IE (fc88062)

2.1.0 (2021-09-11)

Features

  • export universe scroll, scrollTo and scrollBy functions (89a631a)

2.0.2 (2021-09-07)

Bug Fixes

  • add noUncheckedIndexedAccess (de61125)

2.0.1 (2021-08-31)

Bug Fixes

  • element.scrollIntoView in iframe (a7409a3)

2.0.0 (2021-08-22)

Bug Fixes

  • prettier: update prettier config (1578df9)

Code Refactoring

  • for consistency, windowScroll series function parameters changed (f7b76d0)
  • reorganize scroll and polyfill functions (f82af52)
  • the ScrollConfig is separated from the ScrollOptions as the third parameter (c29b463)
  • rollup: remove auto-polyfill (7ea74f7)

BREAKING CHANGES

  • The output format is only esm(es2021 syntax + es5 lib) and umd. The output file is changed from dist to lib location. You can import functions directly from the package name instead of nested paths.
  • The ScrollConfig is separated from the ScrollOptions as the third parameter.
  • windowScroll, windowScrollTo and windowScrollBy now accept window as the first parameter.
  • rollup: There is no more auto-polyfill. This package is no sideEffects now.