實現(xiàn)類似于Photoshop控制面板輸入文本數(shù)字的效果,所以名稱叫做PsWheel。用于控制輸入數(shù)字類型文本框?qū)崿F(xiàn)鼠標(biāo)滾輪上下滑動改變值,支持正整數(shù)、小數(shù)類型輸入文本。 兼容IE/Firefox/Opera/Safari/Chrom 可定義滾動 " /> 88蜜桃人妻无码精品系列,极品少妇小泬50PTHEPON,一本之道高清www在线观看

天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

CutePsWheel javascript libary 控制輸入文本框為可使用滾輪控制的js庫

簡介

實現(xiàn)類似于Photoshop控制面板輸入文本數(shù)字的效果,所以名稱叫做PsWheel。用于控制輸入數(shù)字類型文本框?qū)崿F(xiàn)鼠標(biāo)滾輪上下滑動改變值,支持正整數(shù)、小數(shù)類型輸入文本。
兼容IE/Firefox/Opera/Safari/Chrom
可定義滾動變化間隔值,支持整數(shù)、浮點數(shù)
雙擊恢復(fù)初始值
僅3.92K,壓縮后2.67K
代碼
復(fù)制代碼 代碼如下:
/*
* cutePsWheel JS
* Description:A js liabary which control the text type of input box can plus or minus value like Photoshop
* Author:walkingp
* Site:http://www.51obj.cn/
* E-mail:walkingp@126.com
* Last Modified:2010-2-5
*/
//Initial the wheel scroll event
var _orientValue=[];//orient value
var _interval=[];
var _length=[];
function InitScrollFunc(){
var eles=GetObj();
for(var i=0;i<eles.length;i++){
if(document.addEventListener){
(function(i){eles[i].addEventListener('DOMMouseScroll',function(e){e.preventDefault();e.stopPropagation();var direct=e.detail<0?1:-1;ScrollText(eles[i],direct);},false);})(i);
eles[i].addEventListener('dblclick',RestoreOrientValue,false);
eles[i].addEventListener('blur',RemoveScrollFunc,false);
//eles[i].addEventListener('mouseover',SetFocus,false);
}//W3C/Mozila
(function(i){eles[i].onmousewheel=function(){ScrollFunc(event,eles[i]);}})(i);//IE/Opera/Chrome/Safari
(function(i){eles[i].ondblclick=function(){RestoreOrientValue(eles[i]);;}})(i);
(function(i){eles[i].onblur=function(){RemoveScrollFunc(eles[i]);;}})(i);//Remove the wheel scroll event
(function(i){eles[i].onmouseover=function(){SetFocus(eles[i]);}})(i);
/*Initial the value array*/
if(eles[i].value!=""){
_orientValue.push(eles[i].value);
}else{
_orientValue.push(0);
}
if(eles[i].getAttribute("interval")){
_interval.push(parseFloat(eles[i].getAttribute("interval")));
if(eles[i].getAttribute("interval").toString().indexOf(".")>0){
var __length=parseInt(eles[i].getAttribute("interval").toString().length) - parseInt(eles[i].getAttribute("interval").toString().indexOf("."))-1;
_length.push(__length);//get the length follow the decimal point
}else{
_length.push(0);
}
}else{
_interval.push(1);
_length.push(0);
}
}
}
/*set object focus*/
function SetFocus(obj){
obj.focus();
obj.select();
}
/*remove the wheel scroll event*/
function RemoveScrollFunc(obj){
if(document.removeEventListener){
obj.removeEventListener('DOMMouseScroll',ScrollFunc,false);
obj.removeEventListener('dblclick',RestoreOrientValue,false);
}else if(document.detachEvent){
obj.detachEvent('onmousewheel',ScrollFunc);
obj.detachEvent('ondblclick',RestoreOrientValue);
}
}
/*Restore the text box's orient value when double click event trigger*/
function RestoreOrientValue(obj){
var eles=GetObj();
for(var i=0;i<eles.length;i++){
if(obj==eles[i]){
obj.value=_orientValue[i];
obj.select();
}
}
}
//core function
function ScrollFunc(){//for HTML DOM
var direct=0;
var e=arguments[0]||window.event;
if(window.event){
window.event.returnValue=false;
window.event.cancelBubble=true;//Stop event bubble
}
if(e.wheelDelta){
direct=e.wheelDelta>0?1:-1;
}
ScrollText(arguments[1],direct);
}
//reference by ScrollFunc
function ScrollText(obj,direct){
obj.focus();
var _value=0;
if(obj.value!=""){
_value=parseFloat(obj.value);
}
var eles=GetObj();
for(var i=0;i<eles.length;i++){
if(obj==eles[i]){
if(direct>0){
_value+=_interval[i];
}else{
_value-=_interval[i];
}
obj.value=_value.toFixed(_length[i]);//calulcate the rounding result
obj.select();//set select status
}
}
}
//referenced function,only get the object which has the 'rel' attribute
function GetObj(){
var objs=document.getElementsByTagName('input');
var elements=[];
for(var i=0;i<objs.length;i++){
if(objs[i].type=='text' && objs[i].getAttribute('rel') == 'wheel'){
elements.push(objs[i]);
}
}
return elements;
}
//Add the WheelScroll function
(function AddLoadEvent(func){
var _oldonload=window.onload;
if(typeof window.onload!='function'){
window.onload=func;
}else{
window.onload=function(){
_oldonload();
func();
}
}
})(InitScrollFunc);

效果圖

資源
點擊預(yù)覽 http://demo.jb51.NET/js/cutePSWheel/demo.html
下載代碼

JavaScript技術(shù)CutePsWheel javascript libary 控制輸入文本框為可使用滾輪控制的js庫,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 国产亚洲精品首页在线播放 | 国产欧美一本道无码 | www色小姐 | 打开双腿狠狠蹂躏蜜桃臀 | 怡红院美国分院一区二区 | 无码不卡中文字幕在线观看 | 欧美亚洲日韩国产在线在线 | 妇少水多18P蜜泬17P亚洲乱 | xhameter中国 | 亚洲免费在线视频观看 | 97草碰在线视频免费 | 日本大尺码喷液过程视频 | 久久成人a毛片免费观看网站 | 伊人久久综合影院首页 | 日本理论片和搜子同居的日子2 | 亚洲视频黄| 成人动漫bt种子 | 久久WWW免费人成一看片 | 乱码中字在线观看一二区 | 曰曰夜夜在线影院视 | 影音先锋av333资源网 | MD传媒在线观看佳片 | 日本漫画之无彩翼漫画 | 亚洲精品123区在线观看 | 香蕉99久久久久成人麻豆 | 2017天天拍天天拍香蕉视频 | 天天槽任我槽免费 | 亚洲 欧美 综合 高清 在线 | 亚洲AV精品无码喷水直播间 | 国产人妻精品久久久久久很牛 | 国产精品视频免费视频 | 亚洲男人天堂2018av | 久久成人午夜电影mp4 | 久久国产欧美 | 无码人妻少妇色欲AV一区二区 | 国产精品久久久久一区二区三区 | 美女被强奷到抽搐的动态图 | 男生脱美女内裤内衣动态图 | GOGOGO高清在线播放韩国 | 在教室伦流澡到高潮HNP视频 | 甜性涩爱全集在线观看 |