1
This commit is contained in:
@@ -450,7 +450,12 @@ layui.define('layer', function(exports){
|
||||
hideDown(true);
|
||||
return false;
|
||||
});
|
||||
|
||||
dds.on('mousedown',(events)=>{
|
||||
events.stopPropagation()
|
||||
});
|
||||
dds.on('mouseup',(events)=>{
|
||||
events.stopPropagation()
|
||||
});
|
||||
reElem.find('dl>dt').on('click', function(e){
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -30,9 +30,9 @@ layui.define('jquery', function(exports){
|
||||
,options = that.config;
|
||||
|
||||
return {
|
||||
setValue: function(value, index){ //设置值
|
||||
setValue: function(value, index,s){ //设置值
|
||||
options.value = value;
|
||||
return that.slide('set', value, index || 0);
|
||||
return that.slide('set', value, index || 0,s);
|
||||
}
|
||||
,config: options
|
||||
}
|
||||
@@ -47,6 +47,7 @@ layui.define('jquery', function(exports){
|
||||
that.index = ++slider.index;
|
||||
that.config = $.extend({}, that.config, slider.config, options);
|
||||
that.render();
|
||||
that.anxia = false;
|
||||
};
|
||||
|
||||
//默认配置
|
||||
@@ -206,7 +207,7 @@ layui.define('jquery', function(exports){
|
||||
};
|
||||
|
||||
//滑块滑动
|
||||
Class.prototype.slide = function(setValue, value, i){
|
||||
Class.prototype.slide = function(setValue, value, i,s){
|
||||
var that = this
|
||||
,options = that.config
|
||||
,sliderAct = that.elemTemp
|
||||
@@ -217,7 +218,7 @@ layui.define('jquery', function(exports){
|
||||
,sliderTxt = sliderAct.next('.' + SLIDER_INPUT)
|
||||
,inputValue = sliderTxt.children('.' + SLIDER_INPUT_TXT).children('input').val()
|
||||
,step = 100 / ((options.max - options.min) / Math.ceil(options.step))
|
||||
,change = function(offsetValue, index){
|
||||
,change = function(offsetValue, index,s){
|
||||
if(Math.ceil(offsetValue) * step > 100){
|
||||
offsetValue = Math.ceil(offsetValue) * step
|
||||
}else{
|
||||
@@ -259,7 +260,7 @@ layui.define('jquery', function(exports){
|
||||
}
|
||||
|
||||
//回调
|
||||
options.change && options.change(options.range ? arrValue : selfValue);
|
||||
options.change && options.change(options.range ? arrValue : selfValue,selfValue,s);
|
||||
}
|
||||
,valueTo = function(value){
|
||||
var oldLeft = value / sliderWidth() * 100 / step
|
||||
@@ -283,7 +284,7 @@ layui.define('jquery', function(exports){
|
||||
};
|
||||
|
||||
//动态赋值
|
||||
if(setValue === 'set') return change(value, i);
|
||||
if(setValue === 'set') return change(value, i,s);
|
||||
|
||||
//滑块滑动
|
||||
sliderAct.find('.' + SLIDER_WRAP_BTN).each(function(index){
|
||||
@@ -304,7 +305,7 @@ layui.define('jquery', function(exports){
|
||||
if(left < 0)left = 0;
|
||||
if(left > sliderWidth())left = sliderWidth();
|
||||
var reaLeft = left / sliderWidth() * 100 / step;
|
||||
change(reaLeft, index);
|
||||
change(reaLeft, index,2);
|
||||
othis.addClass(ELEM_HOVER);
|
||||
sliderAct.find('.' + SLIDER_TIPS).show();
|
||||
e.preventDefault();
|
||||
@@ -336,11 +337,46 @@ layui.define('jquery', function(exports){
|
||||
}else{
|
||||
index = 0;
|
||||
};
|
||||
change(reaLeft, index);
|
||||
// console.log(reaLeft,left,step)
|
||||
change(reaLeft, index,true);
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
// 拖动滑块
|
||||
sliderAct.find('.' + SLIDER_BAR).on("mousemove",function (e){
|
||||
if(!that.anxia){
|
||||
return
|
||||
}
|
||||
return
|
||||
var main = $('.' + SLIDER_WRAP_BTN);
|
||||
if(!main.is(event.target) && main.has(event.target).length === 0 && main.length){
|
||||
var left = options.type === 'vertical' ? (sliderWidth() - e.clientY + $(this).offset().top):(e.clientX - $(this).offset().left), index;
|
||||
if(left < 0)left = 0;
|
||||
if(left > sliderWidth())left = sliderWidth();
|
||||
var reaLeft = left / sliderWidth() * 100 / step;
|
||||
if(options.range){
|
||||
if(options.type === 'vertical'){
|
||||
index = Math.abs(left - parseInt($(sliderWrap[0]).css('bottom'))) > Math.abs(left - parseInt($(sliderWrap[1]).css('bottom'))) ? 1 : 0;
|
||||
}else{
|
||||
index = Math.abs(left - sliderWrap[0].offsetLeft) > Math.abs(left - sliderWrap[1].offsetLeft) ? 1 : 0;
|
||||
}
|
||||
}else{
|
||||
index = 0;
|
||||
};
|
||||
console.log(reaLeft,left,step)
|
||||
change(reaLeft, index);
|
||||
e.preventDefault();
|
||||
}
|
||||
})
|
||||
sliderAct.find('.' + SLIDER_BAR).on("mousedown",function (){
|
||||
that.anxia = true
|
||||
})
|
||||
sliderAct.find('.' + SLIDER_BAR).on("mouseup",function (){
|
||||
that.anxia = false
|
||||
})
|
||||
sliderAct.find('.' + SLIDER_BAR).on("click",function (e){
|
||||
e.preventDefault();
|
||||
})
|
||||
//点击加减输入框
|
||||
sliderTxt.children('.' + SLIDER_INPUT_BTN).children('i').each(function(index){
|
||||
$(this).on('click', function(){
|
||||
|
||||
Reference in New Issue
Block a user