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

loading-sign

v1.0.1

Published

Loading animations that run on the front-end interface

Downloads

26

Readme

loading-sign

Loading animations that run on the front-end interface

在前端界面上运行的加载动画

🌰 Demo 示例

https://chenchengbi.github.io/loading-sign/

📦 Install 安装

$ npm i loading-sign

🔨 Usage 使用

import { Loading } from "loading-sign";

// Full screen display of Loading Sign
// 全屏显示加载状态
const unit = Loading.service({ body: true, fullscreen: true, lock: true });
setTimeout(() => { unit.close(); }, 2000);

🔠 Details 详细用法

// const spinner = document.createElement('div');
// spinner.style.backgroundColor = 'white';
// spinner.style.width = '32px';
// spinner.style.height = '32px';
// spinner.style.borderRadius = '20%';
// spinner.style.animation = 'spin 1s linear infinite';
// document.head.appendChild(document.createElement('style')).textContent = `
// @keyframes spin {
//     0% { transform: rotate(0deg); }
//     100% { transform: rotate(360deg); }
// }`;

/**
 * 创建一个“加载动画”实例
 * 以服务的方式调用的全屏 Loading 是单例的:若在前一个全屏 Loading 关闭前再次调用全屏 Loading,并不会创建一个新的 Loading 实例,而是返回现有全屏 Loading 的实例
 * 以服务的方式调用的非全屏 Loading 不是单例的:每次调用都会创建一个新的 Loading 实例;
 * 但是,若在同一个 DOM 节点上,前一个非全屏 Loading 关闭前再次调用非全屏 Loading,则会返回现有非全屏 Loading 的实例
 */
const unit = Loading.service({
    /**
     * 加载动画要覆盖的 DOM 节点或 DOM 选择器
     * DOM nodes or DOM selectors to be covered by the loading animations
     */
    target: '.specified-region',
    /**
     * 是否将加载动画添加到 body 上
     * Whether to add the loading animation to the body
     */
    body: false,
    /**
     * 是否全屏显示加载动画
     * Whether to display the loading animation in fullscreen
     */
    fullscreen: false,
    /**
     * 是否锁定背景滚动
     * Whether to lock the background scrolling
     */
    lock: false,
    /**
     * 加载中显示的文本
     * The text to be displayed during loading
     */
    text: '加载中...',
    /**
     * 自定义加载动画元素
     * Custom loading spinner element
     */
    // spinner: spinner,
    /**
     * 遮罩的背景颜色
     * Background color of the mask
     */
    background: 'rgba(0, 0, 0, 0.7)',
    /**
     * 自定义样式类名
     * Custom class name
     */
    customClass: 'my-loading',
    /**
     * 加载动画的尺寸
     * Size of the loading spinner
     */
    size: 42,
});

setTimeout(() => { unit.close(); }, 2000);