nprogress 转
转载:http://www.xuanfengge.com/front-end-nprogress-and-lightweight-web-progress-bar-nanobar.html
前言
进度条库是前端中常见的库之一,bootstrap中提供了多种进度条样式。NProgress.js和nanobar.js是两款轻量级的进度条组件,使用简便。轩枫阁用过Nprogress,用于页面刚打开时的页面加载进度显示。
官网
NProgress.js:http://ricostacruz.com/nprogress/
nanobar.js:http://nanobar.micronube.com/
1. NProgress

简介
轻量级的ajax进度条应用,灵感来自Google, YouTube, and Medium。
纳米级的进度条。 具有逼真的动画涓涓细流来说服你的用户,something is happen!
安装
引入nprogress.js和nprogress.css到项目中。
基本用法
只需要调用start() 和 done()来控制进度条
|
1
2
|
NProgress.start();
NProgress.done();
|
高级用法
百分比:通过设置progress的百分比,调用 .set(n)来控制进度,其中n的取值范围为0-1。
|
1
2
3
|
NProgress.set(0.0); // Sorta same as .start()
NProgress.set(0.4);
NProgress.set(1.0); // Sorta same as .done()
|
递增:要让进度条增加,只要调用 .inc()。这会产生一个随机增量,但不会让进度条达到100%。此函数适用于图片加载或其他类似的文件加载。
|
1
|
NProgress.inc();
|
强制完成:通过传递 true 参数给done(),使进度条满格,即使它没有被显示。
|
1
|
NProgress.done(true);
|
配置
minimum:设置最低百分比
|
1
|
NProgress.configure({minimum:0.1});
|
template:改变进度条的HTML结构。为保证进度条能正常工作,需要元素拥有role=’bar’属性。
|
1
2
3
|
NProgress.configure({
template:"<div class='....'>...</div>"
});
|
ease:调整动画设置,ease可传递CSS3缓冲动画字符串(如ease、linear、ease-in、ease-out、ease-in-out、cubic-bezier)。speed为动画速度(单位ms)。
|
1
|
NProgress.configure({ease:'ease',speed:500});
|
更多用法
https://github.com/rstacruz/nprogress
2. nanobar

简介
非常非常轻量级的进度条,压缩过后仅有730字节。不需要引入jQuery。
兼容性:IE8和the rest of the world
安装
下载最新版本:https://github.com/jacoborus/nanobar/archive/master.zip
通过安装包管理器安装:
|
1
|
$bower install nanobar
|
npm:
|
1
|
$npm install nanobar
|
使用
在项目中引入nanobar.js即可。
|
1
|
<script src="path/to/nanobar.js"></script>
|
进度创建
|
1
|
varnanobar=newNanobar(options);
|
参数
bg <String>:(可选)CSS背景颜色属性,默认为”#000″即黑色。
id <String>:(可选)nanobar的div的id
target <DOM Element>:设置防止进度条HTML代码的位置,若target为空则会固定到document的顶部位置。
进度运动
nanobar.go(percentage):调整进度
percentage <Number>:nonabar的百分比,取值为0-100
例子
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
varoptions={
bg:'#acf',
// leave target blank for global nanobar
target:document.getElementById('myDivId'),
// id for new nanobar
id:'mynano'
};
varnanobar=newNanobar(options);
//move bar
nanobar.go(30);// size bar 30%
// Finish progress bar
nanobar.go(100);
|
Bootstrap进度条组件
CSS样式:http://v3.bootcss.com/components/#progress-animated
nprogress 转的更多相关文章
- NProgress.js template
NProgress.js:加载进度条:http://ricostacruz.com/nprogress/ 基础的这几个方法 这个网站上都有 我在一个地方看到这个代码 NProgress.configu ...
- pace.js和NProgress.js两个加载进度插件的一点小总结
这两个插件都是关于加载进度动画的,应该说各有特点吧,最起码对我来说是各有优势的.今天一天就捣鼓了加载进度动画,也研究了大量的(也就这两个)加载进度动画,也算对加载进度动画有了一个初步的了解了吧. NP ...
- 前端轻量级web进度条 – Nprogress & nanobar
转载:http://www.xuanfengge.com/front-end-nprogress-and-lightweight-web-progress-bar-nanobar.html 前言 进度 ...
- 插件使用一进度条---nprogress
nprogress 是像youtube一样在顶部出现进度条,用在一些加载比较缓慢的场景中. 官方网站是 http://ricostacruz.com/nprogress/ 源码在 https://gi ...
- vue使用nprogress页面加载进度条
vue使用nprogress页面加载进度条 NProgress是页面跳转是出现在浏览器顶部的进度条 官网:http://ricostacruz.com/nprogress/ github:https: ...
- NProgress.js加载进度插件的简单实用方法
NProgress.js 说明: NProgress是基于jquery的,且版本要 >1.8 下载地址: https://github.com/rstacruz/nprogress API: N ...
- nprogress进度条和ajax全局事件
nprogress和ajax全局事件 nprogress 官方网站:http://ricostacruz.com/nprogress/ 下载地址:https://github.com/rstacruz ...
- 在vue中使用nprogress
NProgress的官网:http://ricostacruz.com/nprogress/ 源码地址:https://github.com/rstacruz/nprogress 1.安 ...
- nprogress.js 头部进度条使用方法
nprogress.js 头部进度条 引入CSS\JS <link rel="stylesheet" type="text/css" href=" ...
- element admin中使用nprogress实现页面加载进度条
主要是知道是nprogress这个组件实现的就可以了,组件的使用方法可参考:https://blog.csdn.net/ltr15036900300/article/details/47321217 ...
随机推荐
- 006-Java的break和continue
break 和 continue关键字的使用 break: 结束当前循环 continue:结束当次循环 示例如下 class JavaTest{ public static void main(St ...
- [转载]Spring AOP 深入剖析
转载自 http://www.cnblogs.com/digdeep/p/4528353.html 多谢@digdeep AOP是Spring提供的关键特性之一.AOP即面向切面编程,是OOP编程的有 ...
- Flutter BottomNavigationBar切换会刷新当前页面解决方
问题描述 BottomNavigationBar 是flutter 中最常用的UI组建,刚接触时发现在切换tab 的时候,会刷新当前的所有状态,每个页面都会重新刷新.于是乎,在这里先记录下解决方案. ...
- centos7.3更换ssh默认登陆端口
说明:本方法目前通用于7.1-7.3 vim /etc/ssh/sshd_config 找到Port 22下面添加一行:Port 12345保存退出. systemctl restart sshd.s ...
- JS事件 编程练习-自制计算器 使用JS完成一个简单的计算器功能。实现2个输入框中输入整数后,点击第三个输入框能给出2个整数的加减乘除。
编程练习 使用JS完成一个简单的计算器功能.实现2个输入框中输入整数后,点击第三个输入框能给出2个整数的加减乘除. 提示:获取元素的值设置和获取方法为:例:赋值:document.getElement ...
- C/C++ 公有函数无法返回私有的类对象解决方案
{ 能出这种错的说明还需要提升C++,增强对类的理解 解决方案:把你的私有的对象的私有的拷贝构造或者同类赋值改为公开的 }
- C/C++ Microsoft Visual Studio c++ DOC Home
{ // https://docs.microsoft.com/zh-cn/cpp/overview/visual-cpp-in-visual-studio?view=vs-2017 // https ...
- xml 单例类
MD5JSON.h #pragma once #include "include/json/json.h" #include "include/md5/md5.h&quo ...
- php开发面试题---面试常用英语(你能介绍你自己吗?)
php开发面试题---面试常用英语(你能介绍你自己吗?) 一.总结 一句话总结: Could you please describe yourself? 1.为什么觉得自己适合这份工作? Why do ...
- .NETFramework:template
ylbtech-.NETFramework: 1.返回顶部 2.返回顶部 3.返回顶部 4.返回顶部 5.返回顶部 6.返回顶部 作者:ylbtech出处:http://y ...