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

vanilla-smoothie

v2.2.5

Published

A minimal smooth scroll library based on vanilla JavaScript.

Downloads

8

Readme

vanilla-smoothie.js

npm version Build Status License MIT

Feature

  • Simple - It an intuitive and simple API, you can write as you like.
  • Minimal - It doesn't depend on other packages, so it has only the minimum necessary functions.
  • Universal - It can be used in various environments such as TypeScript and Front-end frameworks, Vanilla.js.

Installation

Node.js

You can install using npm or yarn and this method is recommended.

npm install --save vanilla-smoothie

CDN

You can also use CDN. Suitable for creating small websites and samples.

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vanilla-smoothie.min.js"></script>

Use

You can achieve smooth scroll with a simple and intuitive way of writing.

In addition, you can write any way you like, such as Callback or Promise.

const vanillaSmoothie = require('vanilla-smoothie')

// Use callback
vanillaSmoothie.scrollTo('#anchor-01', {
  duration: 800
}, () => {
  console.log('Scrolled!!')
})

// Use Promise
vanillaSmoothie.scrollTo('#anchor-02', {
  duration: 800
}).then(() => {
  console.log('Scrolled!!')
})

// Use async/await
(async () => {
  await vanillaSmoothie.scrollTo('#anchor-03', {
    duration: 800
  })
  console.log('Scrolled!!')
})()

Example

Sample code to easily implement the anchor link.

document.querySelectorAll('a[href^="#"]').forEach((anchor) => {
  anchor.addEventListener('click', (event) => {
    vanillaSmoothie.scrollTo(event.target.getAttribute('href'), {
      duration: 500
    })
  })
})

Methods

scrollTo(target[, option, callback])

Scroll to a specified destination.

For target, selector or offset is entered. When the selector is specified for the target, the target element is focused after scroll.

Refer to Option for option parameter.

// Selector
vanillaSmoothie.scrollTo('#id-name')

// Offset Top
vanillaSmoothie.scrollTo(300)

// with option and callback
vanillaSmoothie.scrollTo('#id-name', {
  duration: 1000
}, () => {
  console.log('Callback')
})

scrollTop([option, callback])

Scroll to the top of the page.

Refer to Option for option parameter.

vanillaSmoothie.scrollTop(1000, () => {
  console.log('Callback')
})

scrollBottom([duration, callback])

Scroll to the bottom of the page.

Refer to Option for option parameter.

vanillaSmoothie.scrollBottom(1000, () => {
  console.log('Callback')
})

Option

| Option | Type | Description | default | | -------- | ------ | ---------------------------------------------------------- | -------- | | element | object | Target scroll element. | window | | duration | number | Default number of milliseconds to scroll. | 500 | | adjust | number | Enter a value when you want to adjust the scroll position. | 0 | | easing | string | Easing name. | linear |

Easing

  • linear
  • easeInQuad
  • easeOutQuad
  • easeInOutQuad
  • easeInCubic
  • easeOutCubic
  • easeInOutCubic
  • easeInQuart
  • easeOutQuart
  • easeInOutQuart
  • easeInQuint
  • easeOutQuint
  • easeInOutQuint

Browsers support

| Edge | Firefox | Chrome | Safari | iOS Safari | | --------- | --------- | --------- | --------- | --------- | | Edge| last 2 versions| last 2 versions| last 2 versions| last 2 versions|

Contributing

Please create an Issue or Pull requests if you have any improvements!

Development

Use yarn to download packages and run scripts.

Before creating a Pull requests, execute yarn test and check the operation of the library.

# Install packages
yarn

# TypeScript compile and launch local server to http://localhost:3000
yarn dev

# Build TypeScript and Document
yarn build

# Check TypeScript syntax
yarn lint

# Run E2E test
yarn test

Other commands look to package.json.

License

MIT License.