jq 进度条插件
/**
*进度条
*/
var ProgressScrollBar = function (model) {
this.defaults = {
isCanMove: true,//是否启用拖动
container: "",//最外容器ID
Mainselector: "", //主要div的ID jq选择器字符串#id
Textselector: false, //文字显示查找选择器inputobj
value: 0, //初始值
maxValue: 200, //最大值
currentX: 0,//当前位置px单位
scroll_Track: false, //主干线对象
scroll_Thumb: false //图标对象
};
var opt = $.extend(this.defaults, model);
var mainDivWidth = 0;
var mSelector;
var $Textselector;
var offetWidth;
//初始化
this.Initialize = function () {
if (opt.value > opt.maxValue) {
alert("给定当前值大于了最大值");
return;
}
mSelector = $(opt.Mainselector);
$Textselector = opt.Textselector;
if (!opt.scroll_Track) {
mSelector.append('<div class="scroll_Track"></div>');
opt.scroll_Track = mSelector.find(".scroll_Track");
}
if (!opt.scroll_Thumb) {
mSelector.append('<div class="scroll_Thumb"></div>');
opt.scroll_Thumb = mSelector.find(".scroll_Thumb");
}
mainDivWidth = mSelector.width(); //当前idv宽度
offetWidth = opt.scroll_Thumb.width();
this.GetValue();
opt.scroll_Track.css("width", opt.currentX + 2 + "px");
opt.scroll_Thumb.css("margin-left", opt.currentX + "px");
if (opt.isCanMove) {
this.Value();
}
if ($Textselector && opt.value >= 0)
$Textselector.val(opt.value);
},
this.Value = function () {
var valite = false;
var currentValue;
opt.scroll_Thumb.mousedown(function () {
valite = true;
mSelector.parent().mousemove(function (event) {
console.log(event.offsetX + ", cleint:" + event.clientX + ", parent: " + mSelector.parent().offset().left);
if (valite == false) return;
var changeX = event.clientX - opt.currentX;
currentValue = changeX - opt.currentX - mSelector.offset().left - (offetWidth / 2);
opt.scroll_Thumb.css("margin-left", currentValue + "px");
opt.scroll_Track.css("width", currentValue + 2 + "px");
if ((currentValue + offetWidth) >= mainDivWidth) {
opt.scroll_Thumb.css("margin-left", mainDivWidth - offetWidth + "px");
opt.scroll_Track.css("width", mainDivWidth + 2 + "px");
opt.value = opt.maxValue;
} else if (currentValue <= 0) {
opt.scroll_Thumb.css("margin-left", "0px");
opt.scroll_Track.css("width", "0px");
} else {
opt.value = parseInt(opt.maxValue * (currentValue / mainDivWidth));
}
if ($Textselector && opt.value >= 0)
$Textselector.val(opt.value);
});
});
opt.scroll_Thumb.mouseup(function () {
opt.value = parseInt(opt.maxValue * (currentValue / mainDivWidth));
valite = false;
if (opt.value >= opt.maxValue) opt.value = opt.maxValue;
if (opt.value <= 0) opt.value = 0;
if ($Textselector && opt.value >= 0)
$Textselector.val(opt.value);
});
},
this.GetValue = function () {
opt.currentX = mainDivWidth * (opt.value / opt.maxValue);
},
//按值自动滚动
this.SetValue = function (aValue) {
opt.value = aValue;
if (opt.value >= opt.maxValue) opt.value = opt.maxValue;
if (opt.value <= 0) opt.value = 0;
var mWidth = opt.value / opt.maxValue * mainDivWidth;
opt.scroll_Thumb.animate({ "margin-left": mWidth + "px" });
opt.scroll_Track.animate({ "width": mWidth + 2 + "px" });
if ((mWidth + offetWidth) >= mainDivWidth) {
opt.scroll_Thumb.animate({ "margin-left": mainDivWidth - offetWidth + "px" });
opt.scroll_Track.animate({ "width": mainDivWidth + 2 + "px" });
} else if (mWidth <= 0) {
opt.scroll_Thumb.animate({ "margin-left": "0px" });
opt.scroll_Track.animate({ "width": "0px" });
} else {
opt.value = Math.round(opt.maxValue * (mWidth / mainDivWidth));
}
if ($Textselector && opt.value >= 0)
$Textselector.val(opt.value);
},
//按像素自动滚动
this.SetPixelValue = function (pixelValue) {
opt.scroll_Thumb.animate({ "margin-left": pixelValue + "px" });
opt.scroll_Track.animate({ "width": pixelValue + "px" });
if ((pixelValue + offetWidth) >= mainDivWidth) {
opt.scroll_Thumb.animate({ "margin-left": mainDivWidth - offetWidth + "px" });
opt.scroll_Track.animate({ "width": mainDivWidth + "px" });
} else if (pixelValue <= 0) {
opt.scroll_Thumb.animate({ "margin-left": "0px" });
opt.scroll_Track.animate({ "width": "0px" });
} else {
opt.value = Math.round(opt.maxValue * (pixelValue / mainDivWidth));
}
}
}
jq 进度条插件的更多相关文章
- YprogressBar,html5进度条样式,js进度条插件
简介 YprogressBar是一款基于HTML5的进度条插件. YprogressBar是一款轻量级进度条插件,使用方便,资源占用少,模仿好压的解压界面,带有数字显示,同时支持在描述中增加参数,以动 ...
- 简单实用的纯CSS百分比圆形进度条插件
percircle是一款简单实用的纯CSS百分比圆形进度条插件.你不需要做任何设置,只需要按该圆形进度条插件提供的标准HTML结构来编写代码,就可以生成一个漂亮的百分比圆形进度条. 首先要做的就是引入 ...
- 一个Notification 进度条插件(android,NJS实现,直接就可使用)
参考文章:http://ask.dcloud.net.cn/article/503 源码地址下载 如题,分享一个Notification 进度条插件(android,用js调用原生api实现,直接就可 ...
- 30款基于 jQuery & CSS3 的加载动画和进度条插件
我们所生活每一天看到的新技术或新设计潮流的兴起,Web 开发正处在上升的时代.HTML5 & CSS3 技术的发展让 Web 端可以实现的功能越来越强大. 加载动画和进度条使网站更具吸引力.该 ...
- JQuery中简约的进度条插件推荐
JQuery Progress Bar是基于JQuery开发的进度条插件,秉承了JQuery的简约哲学.不仅容易使用,而且可以轻松定制外观.对于使用了JQuery框架的项目来说,需要使用进度条控件时这 ...
- 基于Jquery的进度条插件(实用)
Spin.js 最喜欢这款插件了,动画图片的长度.粗细.速度和角度都可以灵活控制,想要做成什么样都可以. 源码下载 在线演示 Percentage Loader 一款轻量的 jQuery 进 ...
- 简单的jquery进度条插件LineProgressbar.js,myProgress.js
参考 http://www.lanrenzhijia.com/jquery/4121.html demo下载 <script src="js/jquery.lineProgress ...
- HTML5圆形百分比进度条插件circleChart
在页面中引入jquery和circleChart.min.js文件. <script src="path/to/jquery.min.js"></script&g ...
- ajax页面加载进度条插件
下面两个都是youtube视频的加载进度条效果的ajax插件 一.官网:http://ricostacruz.com/nprogress/官网 github:https://github.com/rs ...
随机推荐
- BZOJ 1303 【CQOI2009】中位数图
baidu了一下bzoj水题列表...找到这道题. 题目大意:给定一个数t,在给定的一段包含1-n的序列中找出多少个长度为奇数子序列的中位数为t. 第一眼没看数据范围,于是开心的打了一个O(n^3 ...
- jQuery中操作Ajax方法小结
有时候,越深入去了解一个点,越发觉得自己无知,而之前当自己晓得一两个片面的点还洋洋自得,殊不知,这是多么讽刺 jQery对Ajax操作进行了封装,常见的 ajax()属于最底层的方法,使用频率很高的 ...
- phpDocumentor2安装配置和使用
今天弄了下 phpDocumentor2生成项目文档,感觉效果还是不错的 不过因为已经安装过了,之前没有截图,现在没法办重新截图了,下次补上 官网地址 http://phpdoc.org 一.安装: ...
- hdu 5207 BestCoder Round #38 ($) Greatest Greatest Common Divisor
#include<stdio.h> #include<string.h> #include<math.h> ]; ]; int main() { int sb; s ...
- Chapter 2 Open Book——35
Mr. Banner called the class to order then, and I turned with relief to listen. Banner先生让大家安静听他说,然后我静 ...
- html-----vedio标签(HTML5新标签VIDEO在IOS上默认全屏播放)
今天做一个app时发现一个问题,应用html5中的video标签加载视频,在Android手机上默认播放大小,但是换成iPhone手机上出问题了,默认弹出全屏播放,查找了好多论坛,都没有谈论这个的.然 ...
- Python学习笔记——进阶篇【第九周】———协程
协程 协程,又称微线程,纤程.英文名Coroutine.一句话说明什么是协程:协程是一种用户态的轻量级线程. 协程拥有自己的寄存器上下文和栈.协程调度切换时,将寄存器上下文和栈保存到其他地方,在切回来 ...
- GNU/Linux超级本ZaReason Ultralap 440体验
老早就在网上看到有关ZaReason公司推出了业界首款Linux超级本Ultralap 430的新闻.通过网上搜索,我了解到ZaReason是一家专门制作与销售预装Linux台式机.笔记本.超级本.平 ...
- 洛谷-拼数-NOIP1998提高组复赛
题目描述 Description 设有n个正整数(n≤20),将它们联接成一排,组成一个最大的多位整数. 例如:n=3时,3个整数13,312,343联接成的最大整数为:34331213 又如:n=4 ...
- js的兼容技巧
javascript原生代码中经常会遇到各式各样浏览器不兼容的问题,浏览器真是倔强,解决浏览器的兼容是前端猿们的一大难题 为了避免在工作中遇到这些简单的问题.节约开发时间,在这里总结一些常用的浏览器兼 ...