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

sky-count

v0.1.0

Published

Vue component for intelligently animating counting of numbers

Downloads

5

Readme

sky-count

Count to infinity and beyond (well, close enough at least)

Description

SkyCount is a simple component that takes any string containing numbers, such as "1.234.000" or "23.5%", and animates a counter from 0 to the given value while retaining all non-digit characters. This enables you to easily append or prepend text and symbols to the counted number or control the way numbers are chunked (English style "000,000.00" vs German etc. "000.000,00").

Installation

npm install sky-count

or

yarn add sky-count

Usage

Begin by importing and installing the SkyCount Vue plugin:

import Vue from 'vue';
import SkyCount from 'sky-count';

Vue.use(SkyCount);

The <sky-count> component registers globally and can now be used. It's primary interface is the trigger prop, which it watches. When it is true, it counts upwards towards the value of the to prop (retaining its non-digit characters while animating).

Basic example:

<sky-count
    :trigger="myBooleanValue" // triggers the animation when true
    :to="'1,234,000 users'" // this is our target
/>

The number kan also be padded with zeros, so the string length is kept the same throughout the animation. This will make the animation look less "jittery" but might not always be what you're going for.

<sky-count
    :trigger="myBooleanValue"
    :to="'1,234,000 users'"
    :pad="true" // pad with zeros
/>

If you want to pad the number with something else than zeros you can do so like this:

<sky-count
    :trigger="myBooleanValue"
    :to="'1,234,000 users'"
    :pad="'-'" // we now pad with dashes instead
/>

If you want to start the animation from another value than zero this is also possible:

<sky-count
    :trigger="myBooleanValue"
    :to="'1,234,000 users'"
    :start="1000" // the animation starts at "1,000"
/>

The animation can also be customized:

<sky-count
    :trigger="myBooleanValue"
    :to="'1,234,000 users'"
    :delay="200" // 200ms
    :duration="500" // 500ms
    :ease="'easeInOutCubic'" // 'easeInOutSine', 'easeOutExpo', 'easeInQuad', 'linear' etc.
/>

Lastly, you can make the number continue slowly incrementing after the animation is done (A simple setInterval under the hood for now).

<sky-count
    :trigger="myBooleanValue"
    :to="'1,234,000 users'"
    :keepCounting="{ delay: 2000, add: 10 }" // when the animation is done the number is incremented by 10 every 2000ms
/>

Credits

This module is made by the Frontenders at skybrud.dk. Feel free to use it in any way you want. Feedback, questions and bugreports should be posted as issues. Pull-requests appreciated!