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

svelte-scroll-nav

v1.0.9

Published

## Introduction

Downloads

8

Readme

Svelte Scroll Nav

Introduction

Svelte Scroll Nav is a Svelte component and utility library designed to simplify the implementation of scroll-driven navigation within Svelte applications. It provides two-way binding between navigation menus and scrollable sections, enhancing the user experience in single-page applications.

Features

  • Smooth scrolling to page sections from navigation links.
  • Dynamic active section highlighting based on scroll position.
  • Customizable behavior through simple API.

Installation

npm install svelte-scroll-nav

Usage

ScrollWatcher Component

Import and use the ScrollWatcher component to monitor scroll events and manage active sections.

<script>
	import { ScrollWatcher } from 'svelte-scroll-nav';
</script>

<ScrollWatcher />

scrollTo Function

Use the scrollTo function to handle navigation link clicks, enabling smooth scrolling to targeted sections.

<script>
	import { scrollTo } from 'svelte-scroll-nav';
</script>

<a href="#section" use:scrollTo={{ section: 'sectionId' }}>Go to Section</a>

scrollRef Function

Utilize the scrollRef action to register sections of the page for scroll navigation.

<script>
	import { scrollRef } from 'svelte-scroll-nav';
</script>

<div use:scrollRef={'sectionId'}>Section Content</div>

section Store

To dynamically highlight active links using the section store, bind your navigation links to a Svelte reactive statement that updates their class based on the current value of the section store. Here's a simplified example:

<script>
	import { section } from 'svelte-scroll-nav';
</script>

<nav>
	<a href="#home" class:active={$section === 'home'}>Home</a>
	<a href="#about" class:active={$section === 'about'}>About</a>
	<a href="#contact" class:active={$section === 'contact'}>Contact</a>
</nav>

<style>
	.active {
		color: red; /* Highlight color */
	}
</style>

Contributing

Guidelines for contributing to the project, including coding standards, pull request, and issue reporting instructions.

License

Copyright (c) 2023-present, Ryan Prescott. API partially based on svelte-scrolling, also licensed under the MIT License, Copyright (c) 2021-present, Valmisson Grizorte.