提交 c2cacf55 编写于 作者: F Frans

Merge branch 'v2'

## 2.0.4
`2019-3-12`
* :sparkles: 新增构建CommonJS包
* :sparkles: 新增倒计时`CountDown`组件
* :bug: 修复`Rate`组件样式兼容问题
* :bug: 修复两个组件测试用例问题
* :zap: 优化`Swiper`组件
* :zap: 文档增加目录功能
* :zap: 新增英文版README.md
## 2.0.3 ## 2.0.3
`2019-1-25` `2019-1-25`
......
{ {
"name": "@nutui/nutui", "name": "@nutui/nutui",
"version": "2.0.3", "version": "2.0.4",
"description": "一套轻量级移动端Vue组件库", "description": "一套轻量级移动端Vue组件库",
"typings": "dist/types/index.d.ts", "typings": "dist/types/index.d.ts",
"main": "dist/nutui.js", "main": "dist/nutui.js",
......
...@@ -201,9 +201,14 @@ export default { ...@@ -201,9 +201,14 @@ export default {
}, },
_onTouchMove(e){ _onTouchMove(e){
if(!this.dragging) return; if(!this.dragging) return;
this.delta = this._getTouchPos(e) - this.startPos; if(this.isHorizontal()){
let isQuickAction = (new Date().getTime() - this.startTime) < 200; this.delta = this._getTouchPos(e).x - this.startPos.x;
if(this.canDragging && !isQuickAction){ }else{
this.delta = this._getTouchPos(e).y - this.startPos.y;
}
//let isQuickAction = (new Date().getTime() - this.startTime) < 200;
if(this.canDragging && this._computePreventDefault(e)){
e.preventDefault();
this.lazyLoad && this._imgLazyLoad(); this.lazyLoad && this._imgLazyLoad();
this._setTranslate(this.startTranslate + this.delta); this._setTranslate(this.startTranslate + this.delta);
this.$emit('slideMove',this._getTranslate(),this.$el); this.$emit('slideMove',this._getTranslate(),this.$el);
...@@ -228,10 +233,23 @@ export default { ...@@ -228,10 +233,23 @@ export default {
}, },
_revert(){ _revert(){
this.setPage(this.currentPage,true); this.setPage(this.currentPage,true);
},
_computePreventDefault(e){
let pos = this._getTouchPos(e);
let xDis = Math.abs(this.startPos.x - pos.x);
let yDis = Math.abs(this.startPos.y - pos.y);
if ( xDis <= 5 && xDis >=0){
return false;
}else if( yDis > 5 && yDis/xDis > 0.5 ){
return false;
}else{
return true;
}
}, },
_getTouchPos(e){ _getTouchPos(e){
let key = this.isHorizontal() ?'pageX':'pageY'; let x = e.changedTouches ? e.changedTouches[0]['pageX'] :e['pageX'];
return e.changedTouches ? e.changedTouches[0][key] :e[key]; let y = e.changedTouches ? e.changedTouches[0]['pageY'] :e['pageY'];
return {x,y}
}, },
_onTransitionStart(type){ _onTransitionStart(type){
this.transitionDuration = this.speed; this.transitionDuration = this.speed;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册