@kengic/uni 0.5.1 → 0.5.2-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/dist/uni/uni-ui/uni-badge/uni-badge.vue +222 -219
  2. package/dist/uni/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +29 -29
  3. package/dist/uni/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +88 -88
  4. package/dist/uni/uni-ui/uni-calendar/calendar.js +936 -532
  5. package/dist/uni/uni-ui/uni-calendar/i18n/en.json +10 -10
  6. package/dist/uni/uni-ui/uni-calendar/i18n/index.js +8 -7
  7. package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hans.json +10 -10
  8. package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hant.json +10 -10
  9. package/dist/uni/uni-ui/uni-calendar/uni-calendar-item.vue +190 -168
  10. package/dist/uni/uni-ui/uni-calendar/uni-calendar.vue +459 -459
  11. package/dist/uni/uni-ui/uni-calendar/util.js +324 -340
  12. package/dist/uni/uni-ui/uni-card/uni-card.vue +8 -1
  13. package/dist/uni/uni-ui/uni-col/uni-col.vue +294 -287
  14. package/dist/uni/uni-ui/uni-collapse/uni-collapse.vue +139 -140
  15. package/dist/uni/uni-ui/uni-collapse-item/uni-collapse-item.vue +381 -378
  16. package/dist/uni/uni-ui/uni-combox/uni-combox.vue +280 -272
  17. package/dist/uni/uni-ui/uni-countdown/i18n/en.json +4 -4
  18. package/dist/uni/uni-ui/uni-countdown/i18n/index.js +8 -7
  19. package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hans.json +4 -4
  20. package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hant.json +4 -4
  21. package/dist/uni/uni-ui/uni-countdown/uni-countdown.vue +249 -257
  22. package/dist/uni/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +832 -813
  23. package/dist/uni/uni-ui/uni-data-picker/keypress.js +42 -42
  24. package/dist/uni/uni-ui/uni-data-picker/uni-data-picker.vue +535 -516
  25. package/dist/uni/uni-ui/uni-data-pickerview/uni-data-picker.js +623 -618
  26. package/dist/uni/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +293 -288
  27. package/dist/uni/uni-ui/uni-data-select/uni-data-select.vue +495 -509
  28. package/dist/uni/uni-ui/uni-dateformat/date-format.js +181 -184
  29. package/dist/uni/uni-ui/uni-dateformat/uni-dateformat.vue +81 -82
  30. package/dist/uni/uni-ui/uni-datetime-picker/calendar-item.vue +176 -170
  31. package/dist/uni/uni-ui/uni-datetime-picker/calendar.vue +926 -920
  32. package/dist/uni/uni-ui/uni-datetime-picker/i18n/en.json +20 -20
  33. package/dist/uni/uni-ui/uni-datetime-picker/i18n/index.js +8 -7
  34. package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +21 -21
  35. package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +21 -21
  36. package/dist/uni/uni-ui/uni-datetime-picker/time-picker.vue +921 -926
  37. package/dist/uni/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1059 -1012
  38. package/dist/uni/uni-ui/uni-datetime-picker/util.js +366 -377
  39. package/dist/uni/uni-ui/uni-drawer/keypress.js +42 -42
  40. package/dist/uni/uni-ui/uni-drawer/uni-drawer.vue +176 -167
  41. package/dist/uni/uni-ui/uni-easyinput/common.js +40 -42
  42. package/dist/uni/uni-ui/uni-easyinput/uni-easyinput.vue +628 -547
  43. package/dist/uni/uni-ui/uni-fab/uni-fab.vue +507 -483
  44. package/dist/uni/uni-ui/uni-fav/i18n/en.json +2 -2
  45. package/dist/uni/uni-ui/uni-fav/i18n/index.js +8 -7
  46. package/dist/uni/uni-ui/uni-fav/i18n/zh-Hans.json +2 -2
  47. package/dist/uni/uni-ui/uni-fav/i18n/zh-Hant.json +2 -2
  48. package/dist/uni/uni-ui/uni-fav/uni-fav.vue +155 -147
  49. package/dist/uni/uni-ui/uni-file-picker/choose-and-upload-file.js +172 -198
  50. package/dist/uni/uni-ui/uni-file-picker/uni-file-picker.vue +636 -634
  51. package/dist/uni/uni-ui/uni-file-picker/upload-file.vue +294 -293
  52. package/dist/uni/uni-ui/uni-file-picker/upload-image.vue +267 -270
  53. package/dist/uni/uni-ui/uni-file-picker/utils.js +81 -82
  54. package/dist/uni/uni-ui/uni-forms/uni-forms.vue +360 -372
  55. package/dist/uni/uni-ui/uni-forms/utils.js +170 -174
  56. package/dist/uni/uni-ui/uni-forms/validate.js +447 -456
  57. package/dist/uni/uni-ui/uni-forms-item/uni-forms-item.vue +497 -497
  58. package/dist/uni/uni-ui/uni-goods-nav/i18n/en.json +4 -4
  59. package/dist/uni/uni-ui/uni-goods-nav/i18n/index.js +8 -7
  60. package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hans.json +4 -4
  61. package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hant.json +4 -4
  62. package/dist/uni/uni-ui/uni-goods-nav/uni-goods-nav.vue +238 -222
  63. package/dist/uni/uni-ui/uni-grid/uni-grid.vue +134 -134
  64. package/dist/uni/uni-ui/uni-grid-item/uni-grid-item.vue +121 -119
  65. package/dist/uni/uni-ui/uni-group/uni-group.vue +121 -121
  66. package/dist/uni/uni-ui/uni-icons/icons.js +1170 -1168
  67. package/dist/uni/uni-ui/uni-icons/uni-icons.vue +91 -86
  68. package/dist/uni/uni-ui/uni-icons/uniicons.css +166 -166
  69. package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +129 -129
  70. package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list.vue +352 -347
  71. package/dist/uni/uni-ui/uni-link/uni-link.vue +134 -119
  72. package/dist/uni/uni-ui/uni-list/uni-list.vue +119 -110
  73. package/dist/uni/uni-ui/uni-list/uni-refresh.vue +14 -14
  74. package/dist/uni/uni-ui/uni-list/uni-refresh.wxs +14 -14
  75. package/dist/uni/uni-ui/uni-list-ad/uni-list-ad.vue +101 -95
  76. package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.scss +18 -18
  77. package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.vue +602 -586
  78. package/dist/uni/uni-ui/uni-list-item/uni-list-item.vue +507 -503
  79. package/dist/uni/uni-ui/uni-load-more/i18n/en.json +3 -3
  80. package/dist/uni/uni-ui/uni-load-more/i18n/index.js +8 -7
  81. package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hans.json +3 -3
  82. package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hant.json +3 -3
  83. package/dist/uni/uni-ui/uni-load-more/uni-load-more.vue +402 -392
  84. package/dist/uni/uni-ui/uni-nav-bar/uni-nav-bar.vue +328 -330
  85. package/dist/uni/uni-ui/uni-nav-bar/uni-status-bar.vue +17 -17
  86. package/dist/uni/uni-ui/uni-notice-bar/uni-notice-bar.vue +422 -401
  87. package/dist/uni/uni-ui/uni-number-box/uni-number-box.vue +211 -205
  88. package/dist/uni/uni-ui/uni-pagination/i18n/en.json +3 -3
  89. package/dist/uni/uni-ui/uni-pagination/i18n/es.json +3 -3
  90. package/dist/uni/uni-ui/uni-pagination/i18n/fr.json +3 -3
  91. package/dist/uni/uni-ui/uni-pagination/i18n/index.js +12 -11
  92. package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hans.json +3 -3
  93. package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hant.json +3 -3
  94. package/dist/uni/uni-ui/uni-pagination/uni-pagination.vue +450 -433
  95. package/dist/uni/uni-ui/uni-popup/uni-popup.vue +404 -404
  96. package/dist/uni/uni-ui/uni-popup-dialog/keypress.js +42 -42
  97. package/dist/uni/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +1 -0
  98. package/dist/uni/uni-ui/uni-popup-message/uni-popup-message.vue +126 -125
  99. package/dist/uni/uni-ui/uni-popup-share/uni-popup-share.vue +172 -172
  100. package/dist/uni/uni-ui/uni-rate/uni-rate.vue +343 -347
  101. package/dist/uni/uni-ui/uni-row/uni-row.vue +180 -182
  102. package/dist/uni/uni-ui/uni-scss/changelog.md +11 -4
  103. package/dist/uni/uni-ui/uni-scss/package.json +73 -73
  104. package/dist/uni/uni-ui/uni-scss/readme.md +2 -1
  105. package/dist/uni/uni-ui/uni-scss/styles/setting/_border.scss +2 -2
  106. package/dist/uni/uni-ui/uni-scss/styles/setting/_color.scss +46 -47
  107. package/dist/uni/uni-ui/uni-scss/styles/setting/_radius.scss +49 -49
  108. package/dist/uni/uni-ui/uni-scss/styles/setting/_space.scss +52 -53
  109. package/dist/uni/uni-ui/uni-scss/styles/setting/_styles.scss +142 -147
  110. package/dist/uni/uni-ui/uni-scss/styles/setting/_text.scss +20 -20
  111. package/dist/uni/uni-ui/uni-scss/styles/setting/_variables.scss +111 -95
  112. package/dist/uni/uni-ui/uni-scss/styles/tools/functions.scss +28 -18
  113. package/dist/uni/uni-ui/uni-scss/theme.scss +10 -7
  114. package/dist/uni/uni-ui/uni-scss/variables.scss +42 -24
  115. package/dist/uni/uni-ui/uni-search-bar/i18n/en.json +3 -3
  116. package/dist/uni/uni-ui/uni-search-bar/i18n/index.js +8 -7
  117. package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hans.json +2 -2
  118. package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hant.json +2 -2
  119. package/dist/uni/uni-ui/uni-search-bar/uni-search-bar.vue +290 -281
  120. package/dist/uni/uni-ui/uni-section/uni-section.vue +149 -146
  121. package/dist/uni/uni-ui/uni-segmented-control/uni-segmented-control.vue +141 -131
  122. package/dist/uni/uni-ui/uni-steps/uni-steps.vue +255 -236
  123. package/dist/uni/uni-ui/uni-swipe-action/uni-swipe-action.vue +51 -51
  124. package/dist/uni/uni-ui/uni-swipe-action-item/bindingx.js +276 -282
  125. package/dist/uni/uni-ui/uni-swipe-action-item/isPC.js +10 -10
  126. package/dist/uni/uni-ui/uni-swipe-action-item/mpalipay.js +182 -187
  127. package/dist/uni/uni-ui/uni-swipe-action-item/mpother.js +235 -244
  128. package/dist/uni/uni-ui/uni-swipe-action-item/mpwxs.js +70 -75
  129. package/dist/uni/uni-ui/uni-swipe-action-item/render.js +238 -247
  130. package/dist/uni/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +387 -313
  131. package/dist/uni/uni-ui/uni-swipe-action-item/wx.wxs +206 -215
  132. package/dist/uni/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +241 -197
  133. package/dist/uni/uni-ui/uni-table/uni-table.vue +445 -447
  134. package/dist/uni/uni-ui/uni-tag/uni-tag.vue +234 -244
  135. package/dist/uni/uni-ui/uni-tbody/uni-tbody.vue +20 -23
  136. package/dist/uni/uni-ui/uni-td/uni-td.vue +79 -80
  137. package/dist/uni/uni-ui/uni-th/filter-dropdown.vue +510 -503
  138. package/dist/uni/uni-ui/uni-th/uni-th.vue +289 -273
  139. package/dist/uni/uni-ui/uni-thead/uni-thead.vue +115 -114
  140. package/dist/uni/uni-ui/uni-title/uni-title.vue +151 -154
  141. package/dist/uni/uni-ui/uni-tooltip/uni-tooltip.vue +55 -60
  142. package/dist/uni/uni-ui/uni-tr/table-checkbox.vue +162 -163
  143. package/dist/uni/uni-ui/uni-tr/uni-tr.vue +158 -157
  144. package/dist/uni/uni-ui/uni-transition/createAnimation.js +130 -113
  145. package/dist/uni/uni-ui/uni-transition/uni-transition.vue +274 -272
  146. package/package.json +1 -1
@@ -3,8 +3,8 @@ var MIN_DISTANCE = 10;
3
3
  /**
4
4
  * 判断当前是否为H5、app-vue
5
5
  */
6
- var IS_HTML5 = false
7
- if (typeof window === 'object') IS_HTML5 = true
6
+ var IS_HTML5 = false;
7
+ if (typeof window === 'object') IS_HTML5 = true;
8
8
 
9
9
  /**
10
10
  * 监听页面内值的变化,主要用于动态开关swipe-action
@@ -14,17 +14,17 @@ if (typeof window === 'object') IS_HTML5 = true
14
14
  * @param {Object} instance
15
15
  */
16
16
  function showWatch(newVal, oldVal, ownerInstance, instance) {
17
- var state = instance.getState()
18
- getDom(instance, ownerInstance)
19
- if (newVal && newVal !== 'none') {
20
- openState(newVal, instance, ownerInstance)
21
- return
22
- }
23
-
24
- if (state.left) {
25
- openState('none', instance, ownerInstance)
26
- }
27
- resetTouchStatus(instance)
17
+ var state = instance.getState();
18
+ getDom(instance, ownerInstance);
19
+ if (newVal && newVal !== 'none') {
20
+ openState(newVal, instance, ownerInstance);
21
+ return;
22
+ }
23
+
24
+ if (state.left) {
25
+ openState('none', instance, ownerInstance);
26
+ }
27
+ resetTouchStatus(instance);
28
28
  }
29
29
 
30
30
  /**
@@ -33,23 +33,23 @@ function showWatch(newVal, oldVal, ownerInstance, instance) {
33
33
  * @param {Object} ins
34
34
  */
35
35
  function touchstart(e, ownerInstance) {
36
- var instance = e.instance;
37
- var disabled = instance.getDataset().disabled
38
- var state = instance.getState();
39
- getDom(instance, ownerInstance)
40
- // fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
41
- disabled = (typeof(disabled) === 'string' ? JSON.parse(disabled) : disabled) || false;
42
- if (disabled) return
43
- // 开始触摸时移除动画类
44
- instance.requestAnimationFrame(function() {
45
- instance.removeClass('ani');
46
- ownerInstance.callMethod('closeSwipe');
47
- })
48
-
49
- // 记录上次的位置
50
- state.x = state.left || 0
51
- // 计算滑动开始位置
52
- stopTouchStart(e, ownerInstance)
36
+ var instance = e.instance;
37
+ var disabled = instance.getDataset().disabled;
38
+ var state = instance.getState();
39
+ getDom(instance, ownerInstance);
40
+ // fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
41
+ disabled = (typeof disabled === 'string' ? JSON.parse(disabled) : disabled) || false;
42
+ if (disabled) return;
43
+ // 开始触摸时移除动画类
44
+ instance.requestAnimationFrame(function () {
45
+ instance.removeClass('ani');
46
+ ownerInstance.callMethod('closeSwipe');
47
+ });
48
+
49
+ // 记录上次的位置
50
+ state.x = state.left || 0;
51
+ // 计算滑动开始位置
52
+ stopTouchStart(e, ownerInstance);
53
53
  }
54
54
 
55
55
  /**
@@ -58,24 +58,24 @@ function touchstart(e, ownerInstance) {
58
58
  * @param {Object} ownerInstance
59
59
  */
60
60
  function touchmove(e, ownerInstance) {
61
- var instance = e.instance;
62
- var disabled = instance.getDataset().disabled
63
- var state = instance.getState()
64
- // fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
65
- disabled = (typeof(disabled) === 'string' ? JSON.parse(disabled) : disabled) || false;
66
- if (disabled) return
67
- // 是否可以滑动页面
68
- stopTouchMove(e);
69
- if (state.direction !== 'horizontal') {
70
- return;
71
- }
72
-
73
- if (e.preventDefault) {
74
- // 阻止页面滚动
75
- e.preventDefault()
76
- }
77
-
78
- move(state.x + state.deltaX, instance, ownerInstance)
61
+ var instance = e.instance;
62
+ var disabled = instance.getDataset().disabled;
63
+ var state = instance.getState();
64
+ // fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
65
+ disabled = (typeof disabled === 'string' ? JSON.parse(disabled) : disabled) || false;
66
+ if (disabled) return;
67
+ // 是否可以滑动页面
68
+ stopTouchMove(e);
69
+ if (state.direction !== 'horizontal') {
70
+ return;
71
+ }
72
+
73
+ if (e.preventDefault) {
74
+ // 阻止页面滚动
75
+ e.preventDefault();
76
+ }
77
+
78
+ move(state.x + state.deltaX, instance, ownerInstance);
79
79
  }
80
80
 
81
81
  /**
@@ -84,17 +84,16 @@ function touchmove(e, ownerInstance) {
84
84
  * @param {Object} ownerInstance
85
85
  */
86
86
  function touchend(e, ownerInstance) {
87
- var instance = e.instance;
88
- var disabled = instance.getDataset().disabled
89
- var state = instance.getState()
90
- // fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
91
- disabled = (typeof(disabled) === 'string' ? JSON.parse(disabled) : disabled) || false;
92
-
93
- if (disabled) return
94
- // 滑动过程中触摸结束,通过阙值判断是开启还是关闭
95
- // fixed by mehaotian 定时器解决点击按钮,touchend 触发比 click 事件时机早的问题 ,主要是 ios13
96
- moveDirection(state.left, instance, ownerInstance)
97
-
87
+ var instance = e.instance;
88
+ var disabled = instance.getDataset().disabled;
89
+ var state = instance.getState();
90
+ // fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
91
+ disabled = (typeof disabled === 'string' ? JSON.parse(disabled) : disabled) || false;
92
+
93
+ if (disabled) return;
94
+ // 滑动过程中触摸结束,通过阙值判断是开启还是关闭
95
+ // fixed by mehaotian 定时器解决点击按钮,touchend 触发比 click 事件时机早的问题 ,主要是 ios13
96
+ moveDirection(state.left, instance, ownerInstance);
98
97
  }
99
98
 
100
99
  /**
@@ -104,19 +103,18 @@ function touchend(e, ownerInstance) {
104
103
  * @param {Object} ownerInstance
105
104
  */
106
105
  function move(value, instance, ownerInstance) {
107
- value = value || 0
108
- var state = instance.getState()
109
- var leftWidth = state.leftWidth
110
- var rightWidth = state.rightWidth
111
- // 获取可滑动范围
112
- state.left = range(value, -rightWidth, leftWidth);
113
- instance.requestAnimationFrame(function() {
114
- instance.setStyle({
115
- transform: 'translateX(' + state.left + 'px)',
116
- '-webkit-transform': 'translateX(' + state.left + 'px)'
117
- })
118
- })
119
-
106
+ value = value || 0;
107
+ var state = instance.getState();
108
+ var leftWidth = state.leftWidth;
109
+ var rightWidth = state.rightWidth;
110
+ // 获取可滑动范围
111
+ state.left = range(value, -rightWidth, leftWidth);
112
+ instance.requestAnimationFrame(function () {
113
+ instance.setStyle({
114
+ transform: 'translateX(' + state.left + 'px)',
115
+ '-webkit-transform': 'translateX(' + state.left + 'px)',
116
+ });
117
+ });
120
118
  }
121
119
 
122
120
  /**
@@ -125,21 +123,21 @@ function move(value, instance, ownerInstance) {
125
123
  * @param {Object} ownerInstance
126
124
  */
127
125
  function getDom(instance, ownerInstance) {
128
- var state = instance.getState()
129
- var leftDom = ownerInstance.selectComponent('.button-group--left')
130
- var rightDom = ownerInstance.selectComponent('.button-group--right')
131
- var leftStyles = {
132
- width: 0
133
- }
134
- var rightStyles = {
135
- width: 0
136
- }
137
- leftStyles = leftDom.getBoundingClientRect()
138
- rightStyles = rightDom.getBoundingClientRect()
139
-
140
- state.leftWidth = leftStyles.width || 0
141
- state.rightWidth = rightStyles.width || 0
142
- state.threshold = instance.getDataset().threshold
126
+ var state = instance.getState();
127
+ var leftDom = ownerInstance.selectComponent('.button-group--left');
128
+ var rightDom = ownerInstance.selectComponent('.button-group--right');
129
+ var leftStyles = {
130
+ width: 0,
131
+ };
132
+ var rightStyles = {
133
+ width: 0,
134
+ };
135
+ leftStyles = leftDom.getBoundingClientRect();
136
+ rightStyles = rightDom.getBoundingClientRect();
137
+
138
+ state.leftWidth = leftStyles.width || 0;
139
+ state.rightWidth = rightStyles.width || 0;
140
+ state.threshold = instance.getDataset().threshold;
143
141
  }
144
142
 
145
143
  /**
@@ -149,10 +147,9 @@ function getDom(instance, ownerInstance) {
149
147
  * @param {Object} max
150
148
  */
151
149
  function range(num, min, max) {
152
- return Math.min(Math.max(num, min), max);
150
+ return Math.min(Math.max(num, min), max);
153
151
  }
154
152
 
155
-
156
153
  /**
157
154
  * 移动方向判断
158
155
  * @param {Object} left
@@ -161,32 +158,28 @@ function range(num, min, max) {
161
158
  * @param {Object} ins
162
159
  */
163
160
  function moveDirection(left, ins, ownerInstance) {
164
- var state = ins.getState()
165
- var threshold = state.threshold
166
- var position = state.position
167
- var isopen = state.isopen || 'none'
168
- var leftWidth = state.leftWidth
169
- var rightWidth = state.rightWidth
170
- if (state.deltaX === 0) {
171
- openState('none', ins, ownerInstance)
172
- return
173
- }
174
- if ((isopen === 'none' && rightWidth > 0 && -left > threshold) || (isopen !== 'none' && rightWidth > 0 &&
175
- rightWidth +
176
- left < threshold)) {
177
- // right
178
- openState('right', ins, ownerInstance)
179
- } else if ((isopen === 'none' && leftWidth > 0 && left > threshold) || (isopen !== 'none' && leftWidth > 0 &&
180
- leftWidth - left < threshold)) {
181
- // left
182
- openState('left', ins, ownerInstance)
183
- } else {
184
- // default
185
- openState('none', ins, ownerInstance)
186
- }
161
+ var state = ins.getState();
162
+ var threshold = state.threshold;
163
+ var position = state.position;
164
+ var isopen = state.isopen || 'none';
165
+ var leftWidth = state.leftWidth;
166
+ var rightWidth = state.rightWidth;
167
+ if (state.deltaX === 0) {
168
+ openState('none', ins, ownerInstance);
169
+ return;
170
+ }
171
+ if ((isopen === 'none' && rightWidth > 0 && -left > threshold) || (isopen !== 'none' && rightWidth > 0 && rightWidth + left < threshold)) {
172
+ // right
173
+ openState('right', ins, ownerInstance);
174
+ } else if ((isopen === 'none' && leftWidth > 0 && left > threshold) || (isopen !== 'none' && leftWidth > 0 && leftWidth - left < threshold)) {
175
+ // left
176
+ openState('left', ins, ownerInstance);
177
+ } else {
178
+ // default
179
+ openState('none', ins, ownerInstance);
180
+ }
187
181
  }
188
182
 
189
-
190
183
  /**
191
184
  * 开启状态
192
185
  * @param {Boolean} type
@@ -194,50 +187,48 @@ function moveDirection(left, ins, ownerInstance) {
194
187
  * @param {Object} ownerInstance
195
188
  */
196
189
  function openState(type, ins, ownerInstance) {
197
- var state = ins.getState()
198
- var leftWidth = state.leftWidth
199
- var rightWidth = state.rightWidth
200
- var left = ''
201
- state.isopen = state.isopen ? state.isopen : 'none'
202
- switch (type) {
203
- case "left":
204
- left = leftWidth
205
- break
206
- case "right":
207
- left = -rightWidth
208
- break
209
- default:
210
- left = 0
211
- }
212
-
213
- // && !state.throttle
214
-
215
- if (state.isopen !== type) {
216
- state.throttle = true
217
- ownerInstance.callMethod('change', {
218
- open: type
219
- })
220
-
221
- }
222
-
223
- state.isopen = type
224
- // 添加动画类
225
- ins.requestAnimationFrame(function() {
226
- ins.addClass('ani');
227
- move(left, ins, ownerInstance)
228
- })
229
- // 设置最终移动位置,理论上只要进入到这个函数,肯定是要打开的
190
+ var state = ins.getState();
191
+ var leftWidth = state.leftWidth;
192
+ var rightWidth = state.rightWidth;
193
+ var left = '';
194
+ state.isopen = state.isopen ? state.isopen : 'none';
195
+ switch (type) {
196
+ case 'left':
197
+ left = leftWidth;
198
+ break;
199
+ case 'right':
200
+ left = -rightWidth;
201
+ break;
202
+ default:
203
+ left = 0;
204
+ }
205
+
206
+ // && !state.throttle
207
+
208
+ if (state.isopen !== type) {
209
+ state.throttle = true;
210
+ ownerInstance.callMethod('change', {
211
+ open: type,
212
+ });
213
+ }
214
+
215
+ state.isopen = type;
216
+ // 添加动画类
217
+ ins.requestAnimationFrame(function () {
218
+ ins.addClass('ani');
219
+ move(left, ins, ownerInstance);
220
+ });
221
+ // 设置最终移动位置,理论上只要进入到这个函数,肯定是要打开的
230
222
  }
231
223
 
232
-
233
224
  function getDirection(x, y) {
234
- if (x > y && x > MIN_DISTANCE) {
235
- return 'horizontal';
236
- }
237
- if (y > x && y > MIN_DISTANCE) {
238
- return 'vertical';
239
- }
240
- return '';
225
+ if (x > y && x > MIN_DISTANCE) {
226
+ return 'horizontal';
227
+ }
228
+ if (y > x && y > MIN_DISTANCE) {
229
+ return 'vertical';
230
+ }
231
+ return '';
241
232
  }
242
233
 
243
234
  /**
@@ -245,12 +236,12 @@ function getDirection(x, y) {
245
236
  * @param {Object} event
246
237
  */
247
238
  function resetTouchStatus(instance) {
248
- var state = instance.getState();
249
- state.direction = '';
250
- state.deltaX = 0;
251
- state.deltaY = 0;
252
- state.offsetX = 0;
253
- state.offsetY = 0;
239
+ var state = instance.getState();
240
+ state.direction = '';
241
+ state.deltaX = 0;
242
+ state.deltaY = 0;
243
+ state.offsetX = 0;
244
+ state.offsetY = 0;
254
245
  }
255
246
 
256
247
  /**
@@ -258,15 +249,15 @@ function resetTouchStatus(instance) {
258
249
  * @param {Object} event
259
250
  */
260
251
  function stopTouchStart(event) {
261
- var instance = event.instance;
262
- var state = instance.getState();
263
- resetTouchStatus(instance);
264
- var touch = event.touches[0];
265
- if (IS_HTML5 && isPC()) {
266
- touch = event;
267
- }
268
- state.startX = touch.clientX;
269
- state.startY = touch.clientY;
252
+ var instance = event.instance;
253
+ var state = instance.getState();
254
+ resetTouchStatus(instance);
255
+ var touch = event.touches[0];
256
+ if (IS_HTML5 && isPC()) {
257
+ touch = event;
258
+ }
259
+ state.startX = touch.clientX;
260
+ state.startY = touch.clientY;
270
261
  }
271
262
 
272
263
  /**
@@ -274,68 +265,68 @@ function stopTouchStart(event) {
274
265
  * @param {Object} event
275
266
  */
276
267
  function stopTouchMove(event) {
277
- var instance = event.instance;
278
- var state = instance.getState();
279
- var touch = event.touches[0];
280
- if (IS_HTML5 && isPC()) {
281
- touch = event;
282
- }
283
- state.deltaX = touch.clientX - state.startX;
284
- state.deltaY = touch.clientY - state.startY;
285
- state.offsetY = Math.abs(state.deltaY);
286
- state.offsetX = Math.abs(state.deltaX);
287
- state.direction = state.direction || getDirection(state.offsetX, state.offsetY);
268
+ var instance = event.instance;
269
+ var state = instance.getState();
270
+ var touch = event.touches[0];
271
+ if (IS_HTML5 && isPC()) {
272
+ touch = event;
273
+ }
274
+ state.deltaX = touch.clientX - state.startX;
275
+ state.deltaY = touch.clientY - state.startY;
276
+ state.offsetY = Math.abs(state.deltaY);
277
+ state.offsetX = Math.abs(state.deltaX);
278
+ state.direction = state.direction || getDirection(state.offsetX, state.offsetY);
288
279
  }
289
280
 
290
281
  function isPC() {
291
- var userAgentInfo = navigator.userAgent;
292
- var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
293
- var flag = true;
294
- for (var v = 0; v < Agents.length - 1; v++) {
295
- if (userAgentInfo.indexOf(Agents[v]) > 0) {
296
- flag = false;
297
- break;
298
- }
299
- }
300
- return flag;
282
+ var userAgentInfo = navigator.userAgent;
283
+ var Agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod'];
284
+ var flag = true;
285
+ for (var v = 0; v < Agents.length - 1; v++) {
286
+ if (userAgentInfo.indexOf(Agents[v]) > 0) {
287
+ flag = false;
288
+ break;
289
+ }
290
+ }
291
+ return flag;
301
292
  }
302
293
 
303
- var movable = false
294
+ var movable = false;
304
295
 
305
296
  function mousedown(e, ins) {
306
- if (!IS_HTML5) return
307
- if (!isPC()) return
308
- touchstart(e, ins)
309
- movable = true
297
+ if (!IS_HTML5) return;
298
+ if (!isPC()) return;
299
+ touchstart(e, ins);
300
+ movable = true;
310
301
  }
311
302
 
312
303
  function mousemove(e, ins) {
313
- if (!IS_HTML5) return
314
- if (!isPC()) return
315
- if (!movable) return
316
- touchmove(e, ins)
304
+ if (!IS_HTML5) return;
305
+ if (!isPC()) return;
306
+ if (!movable) return;
307
+ touchmove(e, ins);
317
308
  }
318
309
 
319
310
  function mouseup(e, ins) {
320
- if (!IS_HTML5) return
321
- if (!isPC()) return
322
- touchend(e, ins)
323
- movable = false
311
+ if (!IS_HTML5) return;
312
+ if (!isPC()) return;
313
+ touchend(e, ins);
314
+ movable = false;
324
315
  }
325
316
 
326
317
  function mouseleave(e, ins) {
327
- if (!IS_HTML5) return
328
- if (!isPC()) return
329
- movable = false
318
+ if (!IS_HTML5) return;
319
+ if (!isPC()) return;
320
+ movable = false;
330
321
  }
331
322
 
332
323
  module.exports = {
333
- showWatch: showWatch,
334
- touchstart: touchstart,
335
- touchmove: touchmove,
336
- touchend: touchend,
337
- mousedown: mousedown,
338
- mousemove: mousemove,
339
- mouseup: mouseup,
340
- mouseleave: mouseleave
341
- }
324
+ showWatch: showWatch,
325
+ touchstart: touchstart,
326
+ touchmove: touchmove,
327
+ touchend: touchend,
328
+ mousedown: mousedown,
329
+ mousemove: mousemove,
330
+ mouseup: mouseup,
331
+ mouseleave: mouseleave,
332
+ };