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

@teamthunderfoot/back-to-top

v0.0.11

Published

Back To Top package

Downloads

21

Readme

Back-to-top

The back-to-top package provides a "Back to Top" button functionality that allows for smooth scrolling to the top of the page. It enables customization of the active CSS class and the distance trigger, which determines when the button becomes visible or hidden based on scrolling.

Here's an example

Installation

npm install @teamthunderfoot/back-to-top

Usage

import BackToTop from '@teamthunderfoot/back-to-top';

class Index {
  constructor() {
    this.init();
  }
  init() {
    const backToTop = new BackToTop({
        element: document.querySelector(".js--back-top"),
        activeClass: "g--back-top-01--is-active",
        distanceTrigger: "tf-data-distance",
    })


    document.querySelectorAll(".js--back-top").forEach((element) => {
        const backToTop = new BackToTop({
            element: element,
            activeClass: "g--back-top-01--is-active",
            distanceTrigger: "tf-data-distance",
        })
    })
  }
}

export default Index;
new Index();

In your HTML file, include a button element with the class js--back-top that will trigger the back-to-top functionality. Additionally, add the tf-data-distance attribute to specify the distance from the top of the page at which the button should appear.

<button class="js--back-top" tf-data-distance="200">Back to Top</button>

The back-to-top button will automatically appear when the user scrolls beyond the specified distance from the top of the page. When clicked, it will scroll smoothly to the top of the page.

Options

element: The back-to-top button element.

activeClass: The CSS class applied to the back-to-top button when it is active (visible).

distanceTrigger: The data attribute that specifies the distance from the top of the page at which the back-to-top button should appear.

Destroy

To remove the back-to-top functionality, you can use the destroy method. Call the destroy method on the instance of BackToTop:

const destroy = this.backToTop.destroy();