mobile-select
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -150,2 +150,6 @@ /*! | ||
} | ||
if(!isNaN(config.maskOpacity)){ | ||
_this.grayMask = _this.mobileSelect.querySelector('.grayLayer'); | ||
_this.grayMask.style.background = 'rgba(0, 0, 0, '+ config.maskOpacity +')'; | ||
} | ||
}, | ||
@@ -238,3 +242,2 @@ | ||
_this.addListenerWheel(_this.wheel[i], i); | ||
_this.addListenerLi(i); | ||
})(i); | ||
@@ -270,14 +273,2 @@ } | ||
addListenerLi:function(sliderIndex){ | ||
var _this = this; | ||
var curWheelLi = _this.slider[sliderIndex].getElementsByTagName('li'); | ||
for(var j=0; j<curWheelLi.length;j++){ | ||
(function (j) { | ||
curWheelLi[j].addEventListener('click',function(){ | ||
_this.singleClick(this, j, sliderIndex); | ||
},false); | ||
})(j); | ||
} | ||
}, | ||
checkDataType: function(){ | ||
@@ -435,3 +426,3 @@ var _this = this; | ||
} | ||
_this.addListenerLi(i); | ||
//_this.·(i); | ||
})(i); | ||
@@ -477,3 +468,2 @@ } | ||
_this.slider[sliderIndex].innerHTML = tempHTML; | ||
_this.addListenerLi(sliderIndex); | ||
}, | ||
@@ -587,2 +577,3 @@ | ||
_this.startY = event.touches[0].clientY; | ||
_this.startY = parseInt(_this.startY); | ||
_this.oldMoveY = _this.startY; | ||
@@ -593,29 +584,41 @@ break; | ||
_this.moveEndY = event.changedTouches[0].clientY; | ||
_this.moveEndY = parseInt(event.changedTouches[0].clientY); | ||
_this.offsetSum = _this.moveEndY - _this.startY; | ||
_this.oversizeBorder = -(theSlider.getElementsByTagName('li').length-3)*_this.liHeight; | ||
//修正位置 | ||
_this.updateCurDistance(theSlider, index); | ||
_this.curDistance[index] = _this.fixPosition(_this.curDistance[index]); | ||
_this.movePosition(theSlider, _this.curDistance[index]); | ||
_this.oversizeBorder = -(theSlider.getElementsByTagName('li').length-3)*_this.liHeight; | ||
if(_this.offsetSum == 0){ | ||
//offsetSum为0,相当于点击事件 | ||
// 0 1 [2] 3 4 | ||
var clickOffetNum = parseInt((document.documentElement.clientHeight - _this.moveEndY)/40); | ||
if(clickOffetNum!=2){ | ||
var offset = clickOffetNum - 2; | ||
var newDistance = _this.curDistance[index] + (offset*_this.liHeight); | ||
if((newDistance <= 2*_this.liHeight) && (newDistance >= _this.oversizeBorder) ){ | ||
_this.curDistance[index] = newDistance; | ||
_this.movePosition(theSlider, _this.curDistance[index]); | ||
_this.transitionEnd(_this.getIndexArr(),_this.getCurValue()); | ||
} | ||
} | ||
}else{ | ||
//修正位置 | ||
_this.updateCurDistance(theSlider, index); | ||
_this.curDistance[index] = _this.fixPosition(_this.curDistance[index]); | ||
_this.movePosition(theSlider, _this.curDistance[index]); | ||
//反弹 | ||
if(_this.curDistance[index] + _this.offsetSum > 2*_this.liHeight){ | ||
_this.curDistance[index] = 2*_this.liHeight; | ||
setTimeout(function(){ | ||
_this.movePosition(theSlider, _this.curDistance[index]); | ||
}, 100); | ||
//反弹 | ||
if(_this.curDistance[index] + _this.offsetSum > 2*_this.liHeight){ | ||
_this.curDistance[index] = 2*_this.liHeight; | ||
setTimeout(function(){ | ||
_this.movePosition(theSlider, _this.curDistance[index]); | ||
}, 100); | ||
}else if(_this.curDistance[index] + _this.offsetSum < _this.oversizeBorder){ | ||
_this.curDistance[index] = _this.oversizeBorder; | ||
setTimeout(function(){ | ||
_this.movePosition(theSlider, _this.curDistance[index]); | ||
}, 100); | ||
} | ||
_this.transitionEnd(_this.getIndexArr(),_this.getCurValue()); | ||
} | ||
}else if(_this.curDistance[index] + _this.offsetSum < _this.oversizeBorder){ | ||
_this.curDistance[index] = _this.oversizeBorder; | ||
setTimeout(function(){ | ||
_this.movePosition(theSlider, _this.curDistance[index]); | ||
}, 100); | ||
} | ||
_this.transitionEnd(_this.getIndexArr(),_this.getCurValue()); | ||
if(_this.cascade){ | ||
@@ -654,26 +657,39 @@ _this.checkRange(index, _this.getIndexArr()); | ||
_this.offsetSum = _this.moveEndY - _this.startY; | ||
_this.oversizeBorder = -(theSlider.getElementsByTagName('li').length-3)*_this.liHeight; | ||
//修正位置 | ||
_this.updateCurDistance(theSlider, index); | ||
_this.curDistance[index] = _this.fixPosition(_this.curDistance[index]); | ||
_this.movePosition(theSlider, _this.curDistance[index]); | ||
_this.oversizeBorder = -(theSlider.getElementsByTagName('li').length-3)*_this.liHeight; | ||
if(_this.offsetSum == 0){ | ||
var clickOffetNum = parseInt((document.documentElement.clientHeight - _this.moveEndY)/40); | ||
if(clickOffetNum!=2){ | ||
var offset = clickOffetNum - 2; | ||
var newDistance = _this.curDistance[index] + (offset*_this.liHeight); | ||
if((newDistance <= 2*_this.liHeight) && (newDistance >= _this.oversizeBorder) ){ | ||
_this.curDistance[index] = newDistance; | ||
_this.movePosition(theSlider, _this.curDistance[index]); | ||
_this.transitionEnd(_this.getIndexArr(),_this.getCurValue()); | ||
} | ||
} | ||
}else{ | ||
//修正位置 | ||
_this.updateCurDistance(theSlider, index); | ||
_this.curDistance[index] = _this.fixPosition(_this.curDistance[index]); | ||
_this.movePosition(theSlider, _this.curDistance[index]); | ||
//反弹 | ||
if(_this.curDistance[index] + _this.offsetSum > 2*_this.liHeight){ | ||
_this.curDistance[index] = 2*_this.liHeight; | ||
setTimeout(function(){ | ||
_this.movePosition(theSlider, _this.curDistance[index]); | ||
}, 100); | ||
//反弹 | ||
if(_this.curDistance[index] + _this.offsetSum > 2*_this.liHeight){ | ||
_this.curDistance[index] = 2*_this.liHeight; | ||
setTimeout(function(){ | ||
_this.movePosition(theSlider, _this.curDistance[index]); | ||
}, 100); | ||
}else if(_this.curDistance[index] + _this.offsetSum < _this.oversizeBorder){ | ||
_this.curDistance[index] = _this.oversizeBorder; | ||
setTimeout(function(){ | ||
_this.movePosition(theSlider, _this.curDistance[index]); | ||
}, 100); | ||
} | ||
_this.transitionEnd(_this.getIndexArr(),_this.getCurValue()); | ||
}else if(_this.curDistance[index] + _this.offsetSum < _this.oversizeBorder){ | ||
_this.curDistance[index] = _this.oversizeBorder; | ||
setTimeout(function(){ | ||
_this.movePosition(theSlider, _this.curDistance[index]); | ||
}, 100); | ||
} | ||
} | ||
_this.clickStatus = false; | ||
_this.transitionEnd(_this.getIndexArr(),_this.getCurValue()); | ||
if(_this.cascade){ | ||
@@ -696,16 +712,2 @@ _this.checkRange(index, _this.getIndexArr()); | ||
} | ||
}, | ||
singleClick: function(theLi, index, sliderIndex){ | ||
var _this = this; | ||
if(_this.cascade){ | ||
var tempPosArr = _this.getIndexArr(); | ||
tempPosArr[sliderIndex] = index; | ||
_this.checkRange(sliderIndex, tempPosArr); | ||
}else{ | ||
_this.curDistance[sliderIndex] = (2-index)*_this.liHeight; | ||
_this.movePosition(theLi.parentNode, _this.curDistance[sliderIndex]); | ||
} | ||
_this.transitionEnd(_this.getIndexArr(),_this.getCurValue()); | ||
} | ||
@@ -712,0 +714,0 @@ |
{ | ||
"name": "mobile-select", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "A multi-function mobile phone scrolling selector, support single to multi-select, support multi-level cascade, provide custom callback function, provide update function redraw, relocation function, compatible pc drag and so on.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
44144
801