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

next-scroll

v1.3.3

Published

Scroll postion gives you ability the manipulate scroll

Downloads

80

Readme

Next-Scroll

Scroll postion gives you ability the manipulate scroll

Features

  • Lightweight
  • smooth scroll
  • component in view
  • Vertical and horizontal scroll position

Installation

With yarn

yarn add next-scroll

With npm

npm install next-scroll

Getting Started

smooth scroll any section

import the Link tag from next-scroll and wrapp it to your content it will act like a scroll trigger, Link will take 3 parameters first "to" which will take the id of the section, then "offset" which will take numbers of pixels by default its 0. And last duration which will take numbers in milliseconds by default its 500ms.

import { Link } from "next-scroll";

export default function nextScroll() {
	return (
		<div>
			<Link to="section" offset={100} duration={700}>
				Scroll to section
			</Link>

			<section id="section">Section</section>
		</div>
	);
}

smooth scroll to top, bottom or anywhere in window

scrollTo is funtion it will take 2 parameters first target which you can set top bottom or anywhere pixels in the window and second duration it will take numbers in milliseconds by default its 500ms.

import { scrollTo } from "next-scroll";

export default function Home() {
	// set target to "top" to scroll to top
	function handleScrollToTop() {
		scrollTo({ target: "top", duration: 600 });
	}

	// set target to "bottom" to scroll to bottom
	function handleScrollToBottom() {
		scrollTo({ target: "bottom", duration: 600 });
	}

	// set target to any where in the window in pixels
	function handleScrollToAnyWhere() {
		scrollTo({ target: 1000, duration: 600 });
	}

	return (
		<div>
			{/* scroll to bottom button */}
			<button onClick={handleScrollToBottom}>Scroll to Botton</button>

			{/* scroll to 1000px button */}
			<button onClick={handleScrollToAnyWhere}>Scroll to anywhere</button>

			{/* scroll to top button */}
			<button onClick={handleScrollToTop}>Scroll to Top</button>
		</div>
	);
}

check if section is in view

componentInView is a funtion it will take 2 parameters id and offset. "id" will take the id of section you want to apply on and last, "offset" will take numbers in pixels it will determine how much offset you want when triggering inView function. This function will reture True, False or null, null means there is not id found.

import { componentInView } from "next-scroll";

export default function nextScroll() {
	// id will take any section id and offset will take numbers in pixels
	const inView = componentInView({ id: "section", offset: 0 });

	console.log(inView); // true / false or null
	// null means no id found

	return (
		<div>
			<section id="section">Section</section>
		</div>
	);
}

position of scrollX and scrollY

scrollPostion will give your scrollY and scrollX of window

import { scrollPosition } from "next-scroll";

export default function nextScroll() {
	console.log(scrollPosition().scrollX); // 120px return how many pixels a user scrolled
	console.log(scrollPosition().scrollY); // 1500px return how many pixels a user scrolled

	return (
		<div>
			<h1>ScrollY : {scrollPosition().scrollX}</h1>
			<h1>ScrollY : {scrollPosition().scrollY}</h1>
		</div>
	);
}