@gmcb/uv-ui 0.2.26

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 (285) hide show
  1. package/CHANGELOG.md +295 -0
  2. package/LICENSE +21 -0
  3. package/README.md +164 -0
  4. package/components/uv-action-sheet/props.js +50 -0
  5. package/components/uv-action-sheet/uv-action-sheet.vue +280 -0
  6. package/components/uv-album/uv-album.vue +312 -0
  7. package/components/uv-alert/props.js +45 -0
  8. package/components/uv-alert/uv-alert.vue +246 -0
  9. package/components/uv-avatar/props.js +85 -0
  10. package/components/uv-avatar/uv-avatar.vue +182 -0
  11. package/components/uv-avatar-group/props.js +53 -0
  12. package/components/uv-avatar-group/uv-avatar-group.vue +106 -0
  13. package/components/uv-back-top/props.js +58 -0
  14. package/components/uv-back-top/uv-back-top.vue +116 -0
  15. package/components/uv-badge/props.js +73 -0
  16. package/components/uv-badge/uv-badge.vue +176 -0
  17. package/components/uv-button/nvue.scss +46 -0
  18. package/components/uv-button/props.js +163 -0
  19. package/components/uv-button/uv-button.vue +529 -0
  20. package/components/uv-button/vue.scss +93 -0
  21. package/components/uv-calendar/calendar.js +546 -0
  22. package/components/uv-calendar/header.vue +104 -0
  23. package/components/uv-calendar/month.vue +616 -0
  24. package/components/uv-calendar/props.js +145 -0
  25. package/components/uv-calendar/uv-calendar.vue +390 -0
  26. package/components/uv-calendars/calendar-body.vue +376 -0
  27. package/components/uv-calendars/calendar-item.vue +248 -0
  28. package/components/uv-calendars/calendar.js +546 -0
  29. package/components/uv-calendars/i18n/en.json +12 -0
  30. package/components/uv-calendars/i18n/index.js +8 -0
  31. package/components/uv-calendars/i18n/zh-Hans.json +12 -0
  32. package/components/uv-calendars/i18n/zh-Hant.json +12 -0
  33. package/components/uv-calendars/util.js +435 -0
  34. package/components/uv-calendars/uv-calendars.vue +452 -0
  35. package/components/uv-cell/props.js +116 -0
  36. package/components/uv-cell/uv-cell.vue +209 -0
  37. package/components/uv-cell-group/props.js +15 -0
  38. package/components/uv-cell-group/uv-cell-group.vue +63 -0
  39. package/components/uv-checkbox/props.js +70 -0
  40. package/components/uv-checkbox/uv-checkbox.vue +371 -0
  41. package/components/uv-checkbox-group/props.js +84 -0
  42. package/components/uv-checkbox-group/uv-checkbox-group.vue +119 -0
  43. package/components/uv-code/props.js +35 -0
  44. package/components/uv-code/uv-code.vue +136 -0
  45. package/components/uv-code-input/props.js +83 -0
  46. package/components/uv-code-input/uv-code-input.vue +272 -0
  47. package/components/uv-col/props.js +30 -0
  48. package/components/uv-col/uv-col.vue +165 -0
  49. package/components/uv-collapse/props.js +20 -0
  50. package/components/uv-collapse/uv-collapse.vue +86 -0
  51. package/components/uv-collapse-item/props.js +60 -0
  52. package/components/uv-collapse-item/uv-collapse-item.vue +228 -0
  53. package/components/uv-column-notice/props.js +61 -0
  54. package/components/uv-column-notice/uv-column-notice.vue +176 -0
  55. package/components/uv-count-down/props.js +25 -0
  56. package/components/uv-count-down/utils.js +62 -0
  57. package/components/uv-count-down/uv-count-down.vue +169 -0
  58. package/components/uv-count-to/props.js +60 -0
  59. package/components/uv-count-to/uv-count-to.vue +187 -0
  60. package/components/uv-datetime-picker/props.js +130 -0
  61. package/components/uv-datetime-picker/uv-datetime-picker.vue +355 -0
  62. package/components/uv-divider/props.js +45 -0
  63. package/components/uv-divider/uv-divider.vue +113 -0
  64. package/components/uv-drop-down/uv-drop-down.vue +135 -0
  65. package/components/uv-drop-down-item/uv-drop-down-item.vue +169 -0
  66. package/components/uv-drop-down-popup/uv-drop-down-popup.vue +242 -0
  67. package/components/uv-empty/props.js +60 -0
  68. package/components/uv-empty/uv-empty.vue +126 -0
  69. package/components/uv-form/props.js +46 -0
  70. package/components/uv-form/uv-form.vue +209 -0
  71. package/components/uv-form/valid.js +1343 -0
  72. package/components/uv-form-item/props.js +49 -0
  73. package/components/uv-form-item/uv-form-item.vue +226 -0
  74. package/components/uv-gap/props.js +25 -0
  75. package/components/uv-gap/uv-gap.vue +36 -0
  76. package/components/uv-grid/props.js +20 -0
  77. package/components/uv-grid/uv-grid.vue +100 -0
  78. package/components/uv-grid-item/props.js +15 -0
  79. package/components/uv-grid-item/uv-grid-item.vue +223 -0
  80. package/components/uv-icon/icons.js +160 -0
  81. package/components/uv-icon/props.js +90 -0
  82. package/components/uv-icon/uv-icon.vue +226 -0
  83. package/components/uv-icon/uvicons.ttf +0 -0
  84. package/components/uv-image/props.js +100 -0
  85. package/components/uv-image/uv-image.vue +296 -0
  86. package/components/uv-index-anchor/props.js +30 -0
  87. package/components/uv-index-anchor/uv-index-anchor.vue +98 -0
  88. package/components/uv-index-item/uv-index-item.vue +87 -0
  89. package/components/uv-index-list/props.js +30 -0
  90. package/components/uv-index-list/uv-index-list.vue +461 -0
  91. package/components/uv-input/props.js +175 -0
  92. package/components/uv-input/uv-input.vue +348 -0
  93. package/components/uv-keyboard/props.js +95 -0
  94. package/components/uv-keyboard/uv-keyboard.vue +180 -0
  95. package/components/uv-keyboard-car/props.js +24 -0
  96. package/components/uv-keyboard-car/uv-keyboard-car.vue +347 -0
  97. package/components/uv-keyboard-number/props.js +19 -0
  98. package/components/uv-keyboard-number/uv-keyboard-number.vue +201 -0
  99. package/components/uv-line/props.js +34 -0
  100. package/components/uv-line/uv-line.vue +60 -0
  101. package/components/uv-line-progress/props.js +29 -0
  102. package/components/uv-line-progress/uv-line-progress.vue +146 -0
  103. package/components/uv-link/props.js +40 -0
  104. package/components/uv-link/uv-link.vue +83 -0
  105. package/components/uv-list/uv-list.vue +147 -0
  106. package/components/uv-list-item/uv-list-item.vue +535 -0
  107. package/components/uv-load-more/props.js +95 -0
  108. package/components/uv-load-more/uv-load-more.vue +152 -0
  109. package/components/uv-loading-icon/props.js +67 -0
  110. package/components/uv-loading-icon/uv-loading-icon.vue +347 -0
  111. package/components/uv-loading-page/props.js +55 -0
  112. package/components/uv-loading-page/uv-loading-page.vue +96 -0
  113. package/components/uv-modal/props.js +90 -0
  114. package/components/uv-modal/uv-modal.vue +245 -0
  115. package/components/uv-navbar/props.js +89 -0
  116. package/components/uv-navbar/uv-navbar.vue +245 -0
  117. package/components/uv-no-network/props.js +20 -0
  118. package/components/uv-no-network/uv-no-network.vue +222 -0
  119. package/components/uv-notice-bar/props.js +76 -0
  120. package/components/uv-notice-bar/uv-notice-bar.vue +110 -0
  121. package/components/uv-notify/props.js +45 -0
  122. package/components/uv-notify/uv-notify.vue +220 -0
  123. package/components/uv-number-box/props.js +118 -0
  124. package/components/uv-number-box/uv-number-box.vue +397 -0
  125. package/components/uv-overlay/props.js +25 -0
  126. package/components/uv-overlay/uv-overlay.vue +85 -0
  127. package/components/uv-parse/node/node.vue +576 -0
  128. package/components/uv-parse/parser.js +1335 -0
  129. package/components/uv-parse/uv-parse.vue +498 -0
  130. package/components/uv-pick-color/colors.js +217 -0
  131. package/components/uv-pick-color/props.js +47 -0
  132. package/components/uv-pick-color/uv-pick-color.vue +551 -0
  133. package/components/uv-picker/props.js +95 -0
  134. package/components/uv-picker/uv-picker.vue +329 -0
  135. package/components/uv-popup/keypress.js +45 -0
  136. package/components/uv-popup/uv-popup.vue +537 -0
  137. package/components/uv-preview-video/uv-preview-video.vue +52 -0
  138. package/components/uv-qrcode/cache.js +1 -0
  139. package/components/uv-qrcode/gcanvas/bridge/bridge-weex.js +241 -0
  140. package/components/uv-qrcode/gcanvas/context-2d/FillStyleLinearGradient.js +18 -0
  141. package/components/uv-qrcode/gcanvas/context-2d/FillStylePattern.js +8 -0
  142. package/components/uv-qrcode/gcanvas/context-2d/FillStyleRadialGradient.js +17 -0
  143. package/components/uv-qrcode/gcanvas/context-2d/RenderingContext.js +666 -0
  144. package/components/uv-qrcode/gcanvas/context-webgl/ActiveInfo.js +11 -0
  145. package/components/uv-qrcode/gcanvas/context-webgl/Buffer.js +21 -0
  146. package/components/uv-qrcode/gcanvas/context-webgl/Framebuffer.js +21 -0
  147. package/components/uv-qrcode/gcanvas/context-webgl/GLenum.js +298 -0
  148. package/components/uv-qrcode/gcanvas/context-webgl/GLmethod.js +142 -0
  149. package/components/uv-qrcode/gcanvas/context-webgl/GLtype.js +23 -0
  150. package/components/uv-qrcode/gcanvas/context-webgl/Program.js +21 -0
  151. package/components/uv-qrcode/gcanvas/context-webgl/Renderbuffer.js +21 -0
  152. package/components/uv-qrcode/gcanvas/context-webgl/RenderingContext.js +1191 -0
  153. package/components/uv-qrcode/gcanvas/context-webgl/Shader.js +22 -0
  154. package/components/uv-qrcode/gcanvas/context-webgl/ShaderPrecisionFormat.js +11 -0
  155. package/components/uv-qrcode/gcanvas/context-webgl/Texture.js +22 -0
  156. package/components/uv-qrcode/gcanvas/context-webgl/UniformLocation.js +22 -0
  157. package/components/uv-qrcode/gcanvas/context-webgl/classUtils.js +3 -0
  158. package/components/uv-qrcode/gcanvas/env/canvas.js +74 -0
  159. package/components/uv-qrcode/gcanvas/env/image.js +96 -0
  160. package/components/uv-qrcode/gcanvas/env/tool.js +24 -0
  161. package/components/uv-qrcode/gcanvas/index.js +39 -0
  162. package/components/uv-qrcode/props.js +85 -0
  163. package/components/uv-qrcode/qrcode.js +34 -0
  164. package/components/uv-qrcode/queue.js +41 -0
  165. package/components/uv-qrcode/uv-qrcode.vue +1038 -0
  166. package/components/uv-radio/props.js +65 -0
  167. package/components/uv-radio/uv-radio.vue +349 -0
  168. package/components/uv-radio-group/props.js +89 -0
  169. package/components/uv-radio-group/uv-radio-group.vue +115 -0
  170. package/components/uv-rate/props.js +73 -0
  171. package/components/uv-rate/uv-rate.vue +274 -0
  172. package/components/uv-read-more/props.js +62 -0
  173. package/components/uv-read-more/uv-read-more.vue +162 -0
  174. package/components/uv-row/props.js +20 -0
  175. package/components/uv-row/uv-row.vue +95 -0
  176. package/components/uv-row-notice/props.js +40 -0
  177. package/components/uv-row-notice/uv-row-notice.vue +341 -0
  178. package/components/uv-safe-bottom/uv-safe-bottom.vue +67 -0
  179. package/components/uv-scroll-list/nvue.js +29 -0
  180. package/components/uv-scroll-list/props.js +35 -0
  181. package/components/uv-scroll-list/scrollWxs.wxs +51 -0
  182. package/components/uv-scroll-list/uv-scroll-list.vue +218 -0
  183. package/components/uv-search/props.js +127 -0
  184. package/components/uv-search/uv-search.vue +311 -0
  185. package/components/uv-skeleton/props.js +65 -0
  186. package/components/uv-skeleton/uv-skeleton.vue +250 -0
  187. package/components/uv-skeletons/uv-skeletons.vue +247 -0
  188. package/components/uv-slider/props.js +58 -0
  189. package/components/uv-slider/uv-slider.vue +58 -0
  190. package/components/uv-status-bar/props.js +8 -0
  191. package/components/uv-status-bar/uv-status-bar.vue +54 -0
  192. package/components/uv-steps/props.js +40 -0
  193. package/components/uv-steps/uv-steps.vue +83 -0
  194. package/components/uv-steps-item/props.js +25 -0
  195. package/components/uv-steps-item/uv-steps-item.vue +347 -0
  196. package/components/uv-sticky/props.js +41 -0
  197. package/components/uv-sticky/uv-sticky.vue +223 -0
  198. package/components/uv-subsection/props.js +54 -0
  199. package/components/uv-subsection/uv-subsection.vue +269 -0
  200. package/components/uv-swipe-action/props.js +10 -0
  201. package/components/uv-swipe-action/uv-swipe-action.vue +65 -0
  202. package/components/uv-swipe-action-item/index - backup.wxs +256 -0
  203. package/components/uv-swipe-action-item/index.wxs +225 -0
  204. package/components/uv-swipe-action-item/nvue - backup.js +264 -0
  205. package/components/uv-swipe-action-item/nvue.js +182 -0
  206. package/components/uv-swipe-action-item/props.js +40 -0
  207. package/components/uv-swipe-action-item/uv-swipe-action-item.vue +200 -0
  208. package/components/uv-swipe-action-item/wxs.js +15 -0
  209. package/components/uv-swiper/props.js +136 -0
  210. package/components/uv-swiper/uv-swiper.vue +263 -0
  211. package/components/uv-swiper-indicator/props.js +30 -0
  212. package/components/uv-swiper-indicator/uv-swiper-indicator.vue +112 -0
  213. package/components/uv-switch/props.js +58 -0
  214. package/components/uv-switch/uv-switch.vue +182 -0
  215. package/components/uv-tabbar/props.js +50 -0
  216. package/components/uv-tabbar/uv-tabbar.vue +146 -0
  217. package/components/uv-tabbar-item/props.js +40 -0
  218. package/components/uv-tabbar-item/uv-tabbar-item.vue +146 -0
  219. package/components/uv-tabs/props.js +71 -0
  220. package/components/uv-tabs/uv-tabs.vue +391 -0
  221. package/components/uv-tags/props.js +104 -0
  222. package/components/uv-tags/uv-tags.vue +379 -0
  223. package/components/uv-text/props.js +113 -0
  224. package/components/uv-text/uv-text.vue +218 -0
  225. package/components/uv-text/value.js +87 -0
  226. package/components/uv-textarea/props.js +138 -0
  227. package/components/uv-textarea/uv-textarea.vue +238 -0
  228. package/components/uv-toast/uv-toast.vue +292 -0
  229. package/components/uv-toolbar/props.js +40 -0
  230. package/components/uv-toolbar/uv-toolbar.vue +109 -0
  231. package/components/uv-tooltip/props.js +60 -0
  232. package/components/uv-tooltip/uv-tooltip.vue +372 -0
  233. package/components/uv-transition/createAnimation.js +131 -0
  234. package/components/uv-transition/props.js +31 -0
  235. package/components/uv-transition/uv-transition.vue +320 -0
  236. package/components/uv-upload/mixin.js +22 -0
  237. package/components/uv-upload/props.js +130 -0
  238. package/components/uv-upload/utils.js +151 -0
  239. package/components/uv-upload/uv-upload.vue +488 -0
  240. package/components/uv-vtabs/props.js +79 -0
  241. package/components/uv-vtabs/uv-vtabs.vue +438 -0
  242. package/components/uv-vtabs-item/uv-vtabs-item.vue +68 -0
  243. package/components/uv-waterfall/props.js +69 -0
  244. package/components/uv-waterfall/uv-waterfall.vue +265 -0
  245. package/index.js +82 -0
  246. package/index.scss +7 -0
  247. package/libs/config/config.js +34 -0
  248. package/libs/css/color.scss +32 -0
  249. package/libs/css/common.scss +100 -0
  250. package/libs/css/components.scss +23 -0
  251. package/libs/css/variable.scss +111 -0
  252. package/libs/css/vue.scss +40 -0
  253. package/libs/function/colorGradient.js +134 -0
  254. package/libs/function/compress.js +27 -0
  255. package/libs/function/debounce.js +29 -0
  256. package/libs/function/digit.js +167 -0
  257. package/libs/function/index.js +734 -0
  258. package/libs/function/platform.js +75 -0
  259. package/libs/function/test.js +287 -0
  260. package/libs/function/throttle.js +30 -0
  261. package/libs/luch-request/adapters/index.js +132 -0
  262. package/libs/luch-request/core/InterceptorManager.js +51 -0
  263. package/libs/luch-request/core/Request.js +201 -0
  264. package/libs/luch-request/core/buildFullPath.js +20 -0
  265. package/libs/luch-request/core/defaults.js +33 -0
  266. package/libs/luch-request/core/dispatchRequest.js +6 -0
  267. package/libs/luch-request/core/mergeConfig.js +126 -0
  268. package/libs/luch-request/core/settle.js +16 -0
  269. package/libs/luch-request/helpers/buildURL.js +64 -0
  270. package/libs/luch-request/helpers/combineURLs.js +14 -0
  271. package/libs/luch-request/helpers/isAbsoluteURL.js +14 -0
  272. package/libs/luch-request/index.d.ts +197 -0
  273. package/libs/luch-request/index.js +2 -0
  274. package/libs/luch-request/utils/clone.js +264 -0
  275. package/libs/luch-request/utils.js +135 -0
  276. package/libs/mixin/button.js +13 -0
  277. package/libs/mixin/mixin.js +172 -0
  278. package/libs/mixin/mpMixin.js +8 -0
  279. package/libs/mixin/mpShare.js +13 -0
  280. package/libs/mixin/openType.js +47 -0
  281. package/libs/mixin/touch.js +59 -0
  282. package/libs/util/dayjs.js +216 -0
  283. package/libs/util/route.js +126 -0
  284. package/package.json +28 -0
  285. package/theme.scss +43 -0
@@ -0,0 +1,256 @@
1
+ /**
2
+ * 此为wxs模块,只支持APP-VUE,微信和QQ小程序以及H5平台
3
+ * wxs内部不支持es6语法,变量只能使用var定义,无法使用解构,箭头函数等特性
4
+ */
5
+
6
+ // 开始触摸
7
+ function touchstart(event, ownerInstance) {
8
+ // 触发事件的组件的ComponentDescriptor实例
9
+ var instance = event.instance
10
+ // wxs内的局部变量快照,此快照是属于整个组件的,在touchstart和touchmove事件中都能获取到相同的结果
11
+ var state = instance.getState()
12
+ if (state.disable) return
13
+ var touches = event.touches
14
+ // 如果进行的是多指触控,不允许进行操作
15
+ if (touches && touches.length > 1) return
16
+ // 标识当前为滑动中状态
17
+ state.moving = true
18
+ // 记录触摸开始点的坐标值
19
+ state.startX = touches[0].pageX
20
+ state.startY = touches[0].pageY
21
+ }
22
+
23
+ // 触摸滑动
24
+ function touchmove(event, ownerInstance) {
25
+ // 触发事件的组件的ComponentDescriptor实例
26
+ var instance = event.instance
27
+ // wxs内的局部变量快照
28
+ var state = instance.getState()
29
+ if (state.disabled || !state.moving) return
30
+
31
+ var touches = event.touches
32
+ var pageX = touches[0].pageX
33
+ var pageY = touches[0].pageY
34
+ var moveX = pageX - state.startX
35
+ var moveY = pageY - state.startY
36
+ var buttonsWidth = state.buttonsWidth
37
+
38
+ // 移动的X轴距离大于Y轴距离,也即终点与起点位置连线,与X轴夹角小于45度时,禁止页面滚动
39
+ if (Math.abs(moveX) > Math.abs(moveY) || Math.abs(moveX) > state.threshold) {
40
+ event.preventDefault()
41
+ event.stopPropagation()
42
+ }
43
+ // 如果移动的X轴距离小于Y轴距离,也即终点位置与起点位置连线,与Y轴夹角小于45度时,认为是页面上下滑动,而不是左右滑动单元格
44
+ if (Math.abs(moveX) < Math.abs(moveY)) return
45
+
46
+ // 限制右滑的距离,不允许内容部分往右偏移,右滑会导致X轴偏移值大于0,以此做判断
47
+ // 此处不能直接return,因为滑动过程中会缺失某些关键点坐标,会导致错乱,最好的办法就是
48
+ // 在超出后,设置为0
49
+ if (state.status === 'open') {
50
+ // 在开启状态下,向左滑动,需忽略
51
+ if (moveX < 0) moveX = 0
52
+ // 想要收起菜单,最大能移动的距离为按钮的总宽度
53
+ if (moveX > buttonsWidth) moveX = buttonsWidth
54
+ // 如果是已经打开了的状态,向左滑动时,移动收起菜单
55
+ moveSwipeAction(-buttonsWidth + moveX, instance, ownerInstance)
56
+ } else {
57
+ // 关闭状态下,右滑动需忽略
58
+ if (moveX > 0) moveX = 0
59
+ // 滑动的距离不允许超过所有按钮的总宽度,此时只能是左滑,最终设置按钮的总宽度,同时为负数
60
+ if (Math.abs(moveX) > buttonsWidth) moveX = -buttonsWidth
61
+ // 只要是在滑过程中,就不断移动菜单的内容部分,从而使隐藏的菜单显示出来
62
+ moveSwipeAction(moveX, instance, ownerInstance)
63
+ }
64
+ }
65
+
66
+ // 触摸结束
67
+ function touchend(event, ownerInstance) {
68
+ // 触发事件的组件的ComponentDescriptor实例
69
+ var instance = event.instance
70
+ // wxs内的局部变量快照
71
+ var state = instance.getState()
72
+ if (!state.moving || state.disabled) return
73
+ var touches = event.changedTouches ? event.changedTouches[0] : {}
74
+ var pageX = touches.pageX
75
+ var pageY = touches.pageY
76
+ var moveX = pageX - state.startX
77
+ if (state.status === 'open') {
78
+ // 在展开的状态下,继续左滑,无需操作
79
+ if (moveX < 0) return
80
+ // 在开启状态下,点击一下内容区域,moveX为0,也即没有进行移动,这时执行收起菜单逻辑
81
+ if (moveX === 0) {
82
+ return closeSwipeAction(instance, ownerInstance)
83
+ }
84
+ // 在开启状态下,滑动距离小于阈值,则默认为不关闭,同时恢复原来的打开状态
85
+ if (Math.abs(moveX) < state.threshold) {
86
+ openSwipeAction(instance, ownerInstance)
87
+ } else {
88
+ // 如果滑动距离大于阈值,则执行收起逻辑
89
+ closeSwipeAction(instance, ownerInstance)
90
+ }
91
+ } else {
92
+ // 在关闭的状态下,右滑,无需操作
93
+ if (moveX > 0) return
94
+ // 理由同上
95
+ if (Math.abs(moveX) < state.threshold) {
96
+ closeSwipeAction(instance, ownerInstance)
97
+ } else {
98
+ openSwipeAction(instance, ownerInstance)
99
+ }
100
+ }
101
+ }
102
+
103
+ // 获取过渡时间
104
+ function getDuration(value) {
105
+ if (value.toString().indexOf('s') >= 0) return value
106
+ return value > 30 ? value + 'ms' : value + 's'
107
+ }
108
+
109
+ // 滑动结束时判断滑动的方向
110
+ function getMoveDirection(instance, ownerInstance) {
111
+ var state = instance.getState()
112
+ }
113
+
114
+ // 移动滑动选择器内容区域,同时显示出其隐藏的菜单
115
+ function moveSwipeAction(moveX, instance, ownerInstance) {
116
+ var state = instance.getState()
117
+ // 获取所有按钮的实例,需要通过它去设置按钮的位移
118
+ var buttons = ownerInstance.selectAllComponents('.uv-swipe-action-item__right__button')
119
+ var len = buttons.length
120
+ var previewButtonsMoveX = 0
121
+
122
+ // 设置菜单内容部分的偏移
123
+ instance.requestAnimationFrame(function() {
124
+ instance.setStyle({
125
+ // 设置translateX的值
126
+ 'transition': 'none',
127
+ transform: 'translateX(' + moveX + 'px)',
128
+ '-webkit-transform': 'translateX(' + moveX + 'px)'
129
+ })
130
+ // 折叠按钮动画
131
+ for (var i = len - 1; i >= 0; i--) {
132
+ // 通过比例,得出元素自身该移动的距离
133
+ var translateX = state.buttons[i].width / state.buttonsWidth * moveX
134
+ // 最终移动的距离,是通过自身比例算出的距离,再加上在它之前所有按钮移动的距离之和
135
+ var realTranslateX = translateX + previewButtonsMoveX
136
+ buttons[i].setStyle({
137
+ // 在移动期间,不能使用过渡效果,否则会造成卡顿,本质原因是每次移动一点,就要花一定时间去过渡这个过程
138
+ 'transition': 'none',
139
+ 'transform': 'translateX(' + realTranslateX + 'px)',
140
+ '-webkit-transform': 'translateX(' + realTranslateX + 'px)'
141
+ })
142
+ // 记录本按钮之前的所有按钮的移动距离之和
143
+ previewButtonsMoveX += translateX
144
+ }
145
+ })
146
+ }
147
+
148
+ // 一次性展开滑动菜单
149
+ function openSwipeAction(instance, ownerInstance) {
150
+ var state = instance.getState()
151
+ // 获取所有按钮的实例,需要通过它去设置按钮的位移
152
+ var buttons = ownerInstance.selectAllComponents('.uv-swipe-action-item__right__button')
153
+ var len = buttons.length
154
+ // 处理duration单位问题
155
+ const duration = getDuration(state.duration)
156
+ // 展开过程中,是向左移动,所以X的偏移应该为负值
157
+ var buttonsWidth = -state.buttonsWidth
158
+ var previewButtonsMoveX = 0
159
+ instance.requestAnimationFrame(function() {
160
+ // 设置菜单主体内容
161
+ instance.setStyle({
162
+ 'transition': 'transform ' + duration,
163
+ 'transform': 'translateX(' + buttonsWidth + 'px)',
164
+ '-webkit-transform': 'translateX(' + buttonsWidth + 'px)',
165
+ })
166
+ // 设置各个隐藏的按钮为展开的状态
167
+ for (var i = len - 1; i >= 0; i--) {
168
+ // 通过比例,得出元素自身该移动的距离
169
+ var translateX = state.buttons[i].width / state.buttonsWidth * buttonsWidth
170
+ // 最终移动的距离,是通过自身比例算出的距离,再加上在它之前所有按钮移动的距离之和
171
+ var realTranslateX = translateX + previewButtonsMoveX
172
+ buttons[i].setStyle({
173
+ // 在移动期间,需要加上动画效果
174
+ 'transition': 'transform ' + duration,
175
+ 'transform': 'translateX(' + realTranslateX + 'px)',
176
+ '-webkit-transform': 'translateX(' + realTranslateX + 'px)'
177
+ })
178
+ // 记录本按钮之前的所有按钮的移动距离之和
179
+ previewButtonsMoveX += translateX
180
+ }
181
+ })
182
+ setStatus('open', instance)
183
+ }
184
+
185
+ // 标记菜单的当前状态,open-已经打开,close-已经关闭
186
+ function setStatus(status, instance) {
187
+ var state = instance.getState()
188
+ state.status = status
189
+ }
190
+
191
+ // 一次性收起滑动菜单
192
+ function closeSwipeAction(instance, ownerInstance) {
193
+ var state = instance.getState()
194
+ // 获取所有按钮的实例,需要通过它去设置按钮的位移
195
+ var buttons = ownerInstance.selectAllComponents('.uv-swipe-action-item__right__button')
196
+ var len = buttons.length
197
+ // 处理duration单位问题
198
+ const duration = getDuration(state.duration)
199
+ instance.requestAnimationFrame(function() {
200
+ // 设置菜单主体内容
201
+ instance.setStyle({
202
+ 'transition': 'transform ' + duration,
203
+ 'transform': 'translateX(0px)',
204
+ '-webkit-transform': 'translateX(0px)'
205
+ })
206
+ // 设置各个隐藏的按钮为收起的状态
207
+ for (var i = len - 1; i >= 0; i--) {
208
+ buttons[i].setStyle({
209
+ 'transition': 'transform ' + duration,
210
+ 'transform': 'translateX(0px)',
211
+ '-webkit-transform': 'translateX(0px)'
212
+ })
213
+ }
214
+ })
215
+ setStatus('close', instance)
216
+ }
217
+
218
+ // show的状态发生变化
219
+ function showChange(newValue, oldValue, ownerInstance, instance) {
220
+ var state = instance.getState()
221
+ if (state.disabled) return
222
+ // 打开或关闭单元格
223
+ if (newValue) {
224
+ openSwipeAction(instance, ownerInstance)
225
+ } else {
226
+ closeSwipeAction(instance, ownerInstance)
227
+ }
228
+ }
229
+
230
+ // 菜单尺寸发生变化
231
+ function sizeChange(newValue, oldValue, ownerInstance, instance) {
232
+ // wxs内的局部变量快照
233
+ var state = instance.getState()
234
+ state.disabled = newValue.disabled
235
+ state.duration = newValue.duration
236
+ state.show = newValue.show
237
+ state.threshold = newValue.threshold
238
+ state.buttons = newValue.buttons
239
+
240
+ var len = state.buttons.length
241
+ if (len) {
242
+ var buttonsWidth = 0
243
+ var buttons = newValue.buttons
244
+ for (var i = 0; i < len; i++) {
245
+ buttonsWidth += buttons[i].width
246
+ }
247
+ }
248
+ state.buttonsWidth = buttonsWidth
249
+ }
250
+
251
+ module.exports = {
252
+ touchstart: touchstart,
253
+ touchmove: touchmove,
254
+ touchend: touchend,
255
+ sizeChange: sizeChange
256
+ }
@@ -0,0 +1,225 @@
1
+ /**
2
+ * 此为wxs模块,只支持APP-VUE,微信和QQ小程序以及H5平台
3
+ * wxs内部不支持es6语法,变量只能使用var定义,无法使用解构,箭头函数等特性
4
+ */
5
+
6
+ // 开始触摸
7
+ function touchstart(event, ownerInstance) {
8
+ // 触发事件的组件的ComponentDescriptor实例
9
+ var instance = event.instance
10
+ // wxs内的局部变量快照,此快照是属于整个组件的,在touchstart和touchmove事件中都能获取到相同的结果
11
+ var state = instance.getState()
12
+ if (state.disabled) return
13
+ var touches = event.touches
14
+ // 如果进行的是多指触控,不允许进行操作
15
+ if (touches && touches.length > 1) return
16
+ // 标识当前为滑动中状态
17
+ state.moving = true
18
+ // 记录触摸开始点的坐标值
19
+ state.startX = touches[0].pageX
20
+ state.startY = touches[0].pageY
21
+
22
+ ownerInstance.callMethod('closeOther')
23
+ }
24
+
25
+ // 触摸滑动
26
+ function touchmove(event, ownerInstance) {
27
+ // 触发事件的组件的ComponentDescriptor实例
28
+ var instance = event.instance
29
+ // wxs内的局部变量快照
30
+ var state = instance.getState()
31
+ if (state.disabled || !state.moving) return
32
+ var touches = event.touches
33
+ var pageX = touches[0].pageX
34
+ var pageY = touches[0].pageY
35
+ var moveX = pageX - state.startX
36
+ var moveY = pageY - state.startY
37
+ var buttonsWidth = state.buttonsWidth
38
+
39
+ // 移动的X轴距离大于Y轴距离,也即终点与起点位置连线,与X轴夹角小于45度时,禁止页面滚动
40
+ if (Math.abs(moveX) > Math.abs(moveY) || Math.abs(moveX) > state.threshold) {
41
+ event.preventDefault && event.preventDefault()
42
+ event.stopPropagation && event.stopPropagation()
43
+ }
44
+ // 如果移动的X轴距离小于Y轴距离,也即终点位置与起点位置连线,与Y轴夹角小于45度时,认为是页面上下滑动,而不是左右滑动单元格
45
+ if (Math.abs(moveX) < Math.abs(moveY)) return
46
+
47
+ // 限制右滑的距离,不允许内容部分往右偏移,右滑会导致X轴偏移值大于0,以此做判断
48
+ // 此处不能直接return,因为滑动过程中会缺失某些关键点坐标,会导致错乱,最好的办法就是
49
+ // 在超出后,设置为0
50
+ if (state.status === 'open') {
51
+ // 在开启状态下,向左滑动,需忽略
52
+ if (moveX < 0) moveX = 0
53
+ // 想要收起菜单,最大能移动的距离为按钮的总宽度
54
+ if (moveX > buttonsWidth) moveX = buttonsWidth
55
+ // 如果是已经打开了的状态,向左滑动时,移动收起菜单
56
+ moveSwipeAction(-buttonsWidth + moveX, instance, ownerInstance)
57
+ } else {
58
+ // 关闭状态下,右滑动需忽略
59
+ if (moveX > 0) moveX = 0
60
+ // 滑动的距离不允许超过所有按钮的总宽度,此时只能是左滑,最终设置按钮的总宽度,同时为负数
61
+ if (Math.abs(moveX) > buttonsWidth) moveX = -buttonsWidth
62
+ // 只要是在滑过程中,就不断移动单元格内容部分,从而使隐藏的菜单显示出来
63
+ moveSwipeAction(moveX, instance, ownerInstance)
64
+ }
65
+ }
66
+
67
+ // 触摸结束
68
+ function touchend(event, ownerInstance) {
69
+ // 触发事件的组件的ComponentDescriptor实例
70
+ var instance = event.instance
71
+ // wxs内的局部变量快照
72
+ var state = instance.getState()
73
+ if (!state.moving || state.disabled) return
74
+ var touches = event.changedTouches ? event.changedTouches[0] : {}
75
+ var pageX = touches.pageX
76
+ var pageY = touches.pageY
77
+ var moveX = pageX - state.startX
78
+ if (state.status === 'open') {
79
+ // 在展开的状态下,继续左滑,无需操作
80
+ if (moveX < 0) return
81
+ // 在开启状态下,点击一下内容区域,moveX为0,也即没有进行移动,这时执行收起菜单逻辑
82
+ if (moveX === 0) {
83
+ return closeSwipeAction(instance, ownerInstance)
84
+ }
85
+ // 在开启状态下,滑动距离小于阈值,则默认为不关闭,同时恢复原来的打开状态
86
+ if (Math.abs(moveX) < state.threshold) {
87
+ openSwipeAction(instance, ownerInstance)
88
+ } else {
89
+ // 如果滑动距离大于阈值,则执行收起逻辑
90
+ closeSwipeAction(instance, ownerInstance)
91
+ }
92
+ } else {
93
+ // 在关闭的状态下,右滑,无需操作
94
+ if (moveX > 0) return
95
+ // 理由同上
96
+ if (Math.abs(moveX) < state.threshold) {
97
+ closeSwipeAction(instance, ownerInstance)
98
+ } else {
99
+ openSwipeAction(instance, ownerInstance)
100
+ }
101
+ }
102
+ }
103
+
104
+ // 获取过渡时间
105
+ function getDuration(value) {
106
+ if (value.toString().indexOf('s') >= 0) return value
107
+ return value > 30 ? value + 'ms' : value + 's'
108
+ }
109
+
110
+ // 滑动结束时判断滑动的方向
111
+ function getMoveDirection(instance, ownerInstance) {
112
+ var state = instance.getState()
113
+ }
114
+
115
+ // 移动滑动选择器内容区域,同时显示出其隐藏的菜单
116
+ function moveSwipeAction(moveX, instance, ownerInstance) {
117
+ var state = instance.getState()
118
+ // 获取所有按钮的实例,需要通过它去设置按钮的位移
119
+ var buttons = ownerInstance.selectAllComponents('.uv-swipe-action-item__right__button')
120
+
121
+ // 设置菜单内容部分的偏移
122
+ instance.requestAnimationFrame(function() {
123
+ instance.setStyle({
124
+ // 设置translateX的值
125
+ 'transition': 'none',
126
+ transform: 'translateX(' + moveX + 'px)',
127
+ '-webkit-transform': 'translateX(' + moveX + 'px)'
128
+ })
129
+ })
130
+ }
131
+
132
+ // 一次性展开滑动菜单
133
+ function openSwipeAction(instance, ownerInstance) {
134
+ var state = instance.getState()
135
+ // 获取所有按钮的实例,需要通过它去设置按钮的位移
136
+ var buttons = ownerInstance.selectAllComponents('.uv-swipe-action-item__right__button')
137
+ // 处理duration单位问题
138
+ var duration = getDuration(state.duration)
139
+ // 展开过程中,是向左移动,所以X的偏移应该为负值
140
+ var buttonsWidth = -state.buttonsWidth
141
+ instance.requestAnimationFrame(function() {
142
+ // 设置菜单主体内容
143
+ instance.setStyle({
144
+ 'transition': 'transform ' + duration,
145
+ 'transform': 'translateX(' + buttonsWidth + 'px)',
146
+ '-webkit-transform': 'translateX(' + buttonsWidth + 'px)',
147
+ })
148
+ })
149
+ setStatus('open', instance, ownerInstance)
150
+ }
151
+
152
+ // 标记菜单的当前状态,open-已经打开,close-已经关闭
153
+ function setStatus(status, instance, ownerInstance) {
154
+ var state = instance.getState()
155
+ state.status = status
156
+ ownerInstance.callMethod('setState', status)
157
+ }
158
+
159
+ // 一次性收起滑动菜单
160
+ function closeSwipeAction(instance, ownerInstance) {
161
+ var state = instance.getState()
162
+ // 获取所有按钮的实例,需要通过它去设置按钮的位移
163
+ var buttons = ownerInstance.selectAllComponents('.uv-swipe-action-item__right__button')
164
+ var len = buttons.length
165
+ // 处理duration单位问题
166
+ var duration = getDuration(state.duration)
167
+ instance.requestAnimationFrame(function() {
168
+ // 设置菜单主体内容
169
+ instance.setStyle({
170
+ 'transition': 'transform ' + duration,
171
+ 'transform': 'translateX(0px)',
172
+ '-webkit-transform': 'translateX(0px)'
173
+ })
174
+ // 设置各个隐藏的按钮为收起的状态
175
+ for (var i = len - 1; i >= 0; i--) {
176
+ buttons[i].setStyle({
177
+ 'transition': 'transform ' + duration,
178
+ 'transform': 'translateX(0px)',
179
+ '-webkit-transform': 'translateX(0px)'
180
+ })
181
+ }
182
+ })
183
+ setStatus('close', instance, ownerInstance)
184
+ }
185
+
186
+ // status的状态发生变化
187
+ function statusChange(newValue, oldValue, ownerInstance, instance) {
188
+ var state = instance.getState()
189
+ if (state.disabled) return
190
+ // 打开或关闭单元格
191
+ if (newValue === 'close' && state.status === 'open') {
192
+ closeSwipeAction(instance, ownerInstance)
193
+ } else if(newValue === 'open' && state.status === 'close') {
194
+ openSwipeAction(instance, ownerInstance)
195
+ }
196
+ }
197
+
198
+ // 菜单尺寸发生变化
199
+ function sizeChange(newValue, oldValue, ownerInstance, instance) {
200
+ // wxs内的局部变量快照
201
+ var state = instance.getState()
202
+ state.disabled = newValue.disabled
203
+ state.duration = newValue.duration
204
+ state.show = newValue.show
205
+ state.threshold = newValue.threshold
206
+ state.buttons = newValue.buttons
207
+
208
+ if (state.buttons) {
209
+ var len = state.buttons.length
210
+ var buttonsWidth = 0
211
+ var buttons = newValue.buttons
212
+ for (var i = 0; i < len; i++) {
213
+ buttonsWidth += buttons[i].width
214
+ }
215
+ }
216
+ state.buttonsWidth = buttonsWidth
217
+ }
218
+
219
+ module.exports = {
220
+ touchstart: touchstart,
221
+ touchmove: touchmove,
222
+ touchend: touchend,
223
+ sizeChange: sizeChange,
224
+ statusChange: statusChange
225
+ }