npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dual-side-scroll

v1.2.3

Published

It's a tiny freeware library on TypeScript to sinhronize page scrolling and navigation meny-bar.

Downloads

30

Readme

Scroll progress (dual-side-scroll) v1.2.3

npm npm npm bundle size GitHub license

Assignment

This tiny plugin is designed to show the progress of the page scrolling interactively. There are two types of actions: onScrolled and onChanged. They can be used together or separately.

  • onScrolled - returns to the progress for each scroll event. It is convenient to use when you need to display progress in real time.
  • onChanged - works only when one paragraph is replaced to another. This is useful for switching the active menu item in the navigation block.

LiveDemo

How does it work?

All you need is a navigation menu with links to the relevant paragraphs in the text. When initializing an object, you need to specify cursor and menu selectors, as well as a callback function.

When the onScrolled event is used, an object will be sent to the processing unit:

    Progress {
        // id of current paragraph
        Id: string;
        // % of paragraph being reviewed
        Percent: number;
    }

When the onChanged event is used, the id of the current paragraph will be sent to the processing unit.

When the window is changed in size, the script automatically will be adjuscted to the proportional value. This is sometimes needed in the mobile version. When the device screen is rotated, the scrolling will continue to work correctly.

Installation

npm i dual-side-scroll

Take the minified version of the script from dist and place it in your application directory. Make sure the plugin connection string is located above the connection string of your scripts.

<script src="./<your_js_directory>/scroll-progress.min.js"></script>

For debugging purposes, there is an unminified version with sourcemap.

Example

The source code of the page LiveDemo script.

document.addEventListener("DOMContentLoaded", function (event) {
    let currentParagraphName = document.getElementById('current-paragraph-name');
    let currentParagraphPercent = document.getElementById('current-paragraph-percent');

    new ScrollProgress.Init(
        "#cursor",
        "menu",
        progress => {
            currentParagraphName.innerText = document.getElementById(progress.Id).innerText;
            currentParagraphPercent.innerText = progress.Percent + '%';
        },
        id => {
            document.querySelectorAll('a[href*="link"]')
                .forEach(element => 
                    element.classList.remove('active-meny-item')
                );
            document.querySelector(`[href="#${id}"]`).classList
                .add('active-meny-item');
        }
    );
});

Planned updates

  • Interactive cursor to scroll the page
  • Bookmarks in paragraphs