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 🙏

© 2025 – Pkg Stats / Ryan Hefner

gfs-loadingbar

v1.0.1

Published

trade f2e project

Downloads

7

Readme

gfs-loadingbar

状态加载

安装


	npm instsall gfs-loadingbar --save

使用

组件提供了多种loadingbar呈现方式,包括

  • MaskBar 类似蒙层在页面中剧中展示加载状态效果,加载状态内容可自定义文字、图片均可

  • LoadingBar 仿YouTube页面加载状态效果

	//引入loadingbar
	import {LoadingBar,MaskBar} from 'gfs-loadingbar'

	//初次使用需实例化loadingbar
	let loadingbar = new LoadingBar()

	//显示和隐藏loadingbar状态
	loadingbar.run()
	loadingbar.end()

React调用方式

与原生方式不同的是,此方式提供了redux middleware中间件、store状态机;并且能够与gfs-fetch、gfs-redux-bind-react配合使用;具体请参考例子:react-redux的使用方式

例子

  • react+redux的使用方式

	//redux-react
	
	import React, { Component } from 'react'
	import ReactDom from 'react-dom'

	import LoadingBarComponent,{LoadingBar} from 'gfs-loadingbar/lib/react/LoadingBar'
	import {fetching} from 'gfs-loadingbar/lib/react/fetching'
	import {Connect} from 'gfs-loadingbar/lib/react/Connect'
	import FetchMiddleware from 'gfs-loadingbar/lib/react/FetchMiddleware'

	//或者这样

	//import {LoadingBarComponent,fetching,FetchMiddleware,LoadingBar,Connect} from 'gfs-loadingbar/lib/index.react';

	import { Provider,connect } from 'react-redux'
	import { createStore,applyMiddleware,combineReducers } from 'redux'


	//loadingbar实例,且页面中只能有一个
	let loadingbar = new LoadingBar()

	//action
	function fetchingAction(){
		
		//开始获取数据时显示loadingbar
		loadingbar.run()
		setTimeout( ()=>{
			//数据请求完成关闭loadingbar
			loadingbar.end()
		},2000)
	}

	//将组建内部写好的store合并到redux store中,并将提供的中间件注册好
	let store = createStore(combineReducers({fetching:fetching}),applyMiddleware(FetchMiddleware) )

	class Page extends Component {
		constructor(props) {
			super(props)
			
			fetchingAction()
		}

		render() {
			
			return (
				<Provider store={store}>
					<div>
						<Connect>
							<LoadingBarComponent />
						</Connect>
					</div>
				</Provider>
			
			)
		}
	}

	export default function append(){
		window.onload = function(){
			let root = document.getElementById('root')
			if(root){
				ReactDom.render( <Page /> ,root)
			}
			
		}
	}
	
  • 普通调用方式

	import {MaskBar,LoadingBar} from 'gfs-loadingbar'

	let $ = function() {
		return document.querySelectorAll(arguments[0])
	}

	let loadingBar = new LoadingBar()

	let maskBar = new MaskBar({
		text: '拼命加载中'
	})

	let timeout = null
	let masktimeout = null

	if ($('#j-loadingbar').length > 0) {
		$('#j-loadingbar')[0].onclick = function() {

			clearTimeout(timeout)
			//渲染loadingbar
			loadingBar.run()
			timeout = setTimeout(() => {
				//结束
				loadingBar.end()
			}, 4000)
		}
		$('#j-maskbar')[0].onclick = function() {
			clearTimeout(masktimeout)
			//渲染loadingbar
			maskBar.run()
			masktimeout = setTimeout(() => {
				//结束
				maskBar.end()
			}, 4000)
		}

	}

通用方法

  • show()

  • hide()

  • run()

  • end()

属性

text?:string;
fetching?:number;

Command

	#测试	
	npm run test	
	#打包	
	npm run build	
	#例子演示	
	npm start