1. seamless-scroll-polyfill
Smooth Scroll behavior polyfill
seamless-scroll-polyfill
Package: seamless-scroll-polyfill
Created by: magic-akari
Last modified: Tue, 21 Mar 2023 14:05:34 GMT
Version: 2.3.4
License: MIT
Downloads: 202,706
Repository: https://github.com/magic-akari/seamless-scroll-polyfill

Install

npm install seamless-scroll-polyfill
yarn add seamless-scroll-polyfill

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

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code