stellar-ui-v2 1.35.3
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.
- package/common/css/common.scss +61 -0
- package/components/ste-animate/README.md +117 -0
- package/components/ste-animate/animate.scss +247 -0
- package/components/ste-animate/ste-animate.vue +200 -0
- package/components/ste-badge/README.md +171 -0
- package/components/ste-badge/ste-badge.vue +238 -0
- package/components/ste-barcode/README.md +36 -0
- package/components/ste-barcode/encode2.js +317 -0
- package/components/ste-barcode/ste-barcode.vue +213 -0
- package/components/ste-button/README.md +129 -0
- package/components/ste-button/ste-button.vue +345 -0
- package/components/ste-calendar/README.md +304 -0
- package/components/ste-calendar/self-date.js +119 -0
- package/components/ste-calendar/ste-calendar.vue +578 -0
- package/components/ste-checkbox/README.md +297 -0
- package/components/ste-checkbox/ste-checkbox.vue +305 -0
- package/components/ste-checkbox-group/ste-checkbox-group.vue +133 -0
- package/components/ste-code-input/README.md +67 -0
- package/components/ste-code-input/ste-code-input.vue +302 -0
- package/components/ste-date-picker/README.md +135 -0
- package/components/ste-date-picker/ste-date-picker.vue +407 -0
- package/components/ste-drag/README.md +103 -0
- package/components/ste-drag/ste-drag.vue +203 -0
- package/components/ste-dropdown-menu/README.md +358 -0
- package/components/ste-dropdown-menu/ste-dropdown-menu.vue +405 -0
- package/components/ste-dropdown-menu-item/ste-dropdown-menu-item.vue +176 -0
- package/components/ste-icon/README.md +90 -0
- package/components/ste-icon/iconfont.css +8 -0
- package/components/ste-icon/ste-icon.vue +147 -0
- package/components/ste-image/README.md +154 -0
- package/components/ste-image/ste-image.vue +218 -0
- package/components/ste-index-item/ste-index-item.vue +96 -0
- package/components/ste-index-list/README.md +153 -0
- package/components/ste-index-list/ste-index-list.vue +128 -0
- package/components/ste-input/README.md +146 -0
- package/components/ste-input/ste-input.vue +480 -0
- package/components/ste-loading/README.md +81 -0
- package/components/ste-loading/ste-loading.vue +166 -0
- package/components/ste-media-preview/README.md +243 -0
- package/components/ste-media-preview/TouchScaleing.js +102 -0
- package/components/ste-media-preview/ste-media-preview.vue +267 -0
- package/components/ste-message-box/README.md +217 -0
- package/components/ste-message-box/ste-message-box.js +72 -0
- package/components/ste-message-box/ste-message-box.vue +380 -0
- package/components/ste-notice-bar/README.md +129 -0
- package/components/ste-notice-bar/ste-notice-bar.vue +331 -0
- package/components/ste-number-keyboard/README.md +246 -0
- package/components/ste-number-keyboard/keyboard.vue +140 -0
- package/components/ste-number-keyboard/ste-number-keyboard.vue +240 -0
- package/components/ste-picker/ste-picker.vue +258 -0
- package/components/ste-popup/README.md +148 -0
- package/components/ste-popup/ste-popup.vue +337 -0
- package/components/ste-price/README.md +129 -0
- package/components/ste-price/ste-price.vue +258 -0
- package/components/ste-progress/README.md +87 -0
- package/components/ste-progress/ste-progress.vue +200 -0
- package/components/ste-qrcode/README.md +50 -0
- package/components/ste-qrcode/ste-qrcode.vue +164 -0
- package/components/ste-qrcode/uqrcode.js +34 -0
- package/components/ste-radio/README.md +286 -0
- package/components/ste-radio/ste-radio.vue +293 -0
- package/components/ste-radio-group/ste-radio-group.vue +128 -0
- package/components/ste-rate/README.md +115 -0
- package/components/ste-rate/ste-rate.vue +202 -0
- package/components/ste-read-more/README.md +111 -0
- package/components/ste-read-more/ste-read-more.vue +133 -0
- package/components/ste-rich-text/README.md +31 -0
- package/components/ste-rich-text/ste-rich-text.vue +70 -0
- package/components/ste-scroll-to/README.md +68 -0
- package/components/ste-scroll-to/mixin.js +173 -0
- package/components/ste-scroll-to/ste-scroll-to.vue +45 -0
- package/components/ste-scroll-to-item/ste-scroll-to-item.vue +25 -0
- package/components/ste-search/README.md +262 -0
- package/components/ste-search/ste-search.vue +547 -0
- package/components/ste-select/README.md +434 -0
- package/components/ste-select/datapager.vue +62 -0
- package/components/ste-select/datetime.vue +106 -0
- package/components/ste-select/defaultDate.js +142 -0
- package/components/ste-select/ste-select.vue +843 -0
- package/components/ste-signature/README.md +105 -0
- package/components/ste-signature/ste-signature.vue +220 -0
- package/components/ste-slider/README.md +165 -0
- package/components/ste-slider/ste-slider.vue +544 -0
- package/components/ste-step/ste-step.vue +264 -0
- package/components/ste-stepper/README.md +170 -0
- package/components/ste-stepper/ste-stepper.vue +373 -0
- package/components/ste-steps/README.md +132 -0
- package/components/ste-steps/ste-steps.vue +65 -0
- package/components/ste-sticky/README.md +52 -0
- package/components/ste-sticky/ste-sticky.vue +127 -0
- package/components/ste-swipe-action/README.md +197 -0
- package/components/ste-swipe-action/ste-swipe-action.vue +303 -0
- package/components/ste-swipe-action-group/ste-swipe-action-group.vue +104 -0
- package/components/ste-swiper/README.md +173 -0
- package/components/ste-swiper/ste-swiper.vue +462 -0
- package/components/ste-swiper-item/ste-swiper-item.vue +41 -0
- package/components/ste-switch/README.md +110 -0
- package/components/ste-switch/ste-switch.vue +144 -0
- package/components/ste-tab/ste-tab.vue +87 -0
- package/components/ste-table/README.md +785 -0
- package/components/ste-table/common.js +8 -0
- package/components/ste-table/ste-table.vue +666 -0
- package/components/ste-table/utils.js +20 -0
- package/components/ste-table-column/checkbox-icon.vue +65 -0
- package/components/ste-table-column/common.scss +65 -0
- package/components/ste-table-column/radio-icon.vue +110 -0
- package/components/ste-table-column/ste-table-column.vue +255 -0
- package/components/ste-table-column/sub-table.vue +116 -0
- package/components/ste-table-column/table-popover.vue +204 -0
- package/components/ste-table-column/var.scss +1 -0
- package/components/ste-tabs/README.md +475 -0
- package/components/ste-tabs/props.js +212 -0
- package/components/ste-tabs/ste-tabs.vue +758 -0
- package/components/ste-text/README.md +66 -0
- package/components/ste-text/ste-text.vue +72 -0
- package/components/ste-toast/README.md +243 -0
- package/components/ste-toast/ste-toast.js +69 -0
- package/components/ste-toast/ste-toast.vue +231 -0
- package/components/ste-touch-swipe/README.md +104 -0
- package/components/ste-touch-swipe/TouchEvent.js +72 -0
- package/components/ste-touch-swipe/ste-touch-swipe.vue +327 -0
- package/components/ste-touch-swipe-item/ste-touch-swipe-item.vue +33 -0
- package/components/ste-tour/README.md +194 -0
- package/components/ste-tour/ste-tour.vue +355 -0
- package/components/ste-tree/README.md +240 -0
- package/components/ste-tree/ste-tree.vue +350 -0
- package/components/ste-upload/README.md +276 -0
- package/components/ste-upload/ReadFile.js +229 -0
- package/components/ste-upload/ste-upload.vue +526 -0
- package/components/ste-video/README.md +60 -0
- package/components/ste-video/props.js +149 -0
- package/components/ste-video/ste-video.vue +647 -0
- package/config/color.js +22 -0
- package/index.js +2 -0
- package/package.json +19 -0
- package/utils/Color.js +66 -0
- package/utils/System.js +110 -0
- package/utils/dayjs.min.js +1 -0
- package/utils/mixin.js +67 -0
- package/utils/store.js +7 -0
- package/utils/utils.js +604 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# TouchSwipe 手势切屏
|
|
2
|
+
手势切屏组件,支持水平手势切换和垂直手势切换。
|
|
3
|
+
|
|
4
|
+
---$
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
#### 水平切换,固定宽度
|
|
8
|
+
- 外层使用`ste-touch-swipe`父标签包裹
|
|
9
|
+
- `index`属性设置当前激活区域,支持`sync`双向绑定
|
|
10
|
+
- `width`属性设置区域宽度,默认`100%`
|
|
11
|
+
- 内层使用`ste-touch-swipe-item`子标签包裹每一块区域的内容
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
```html
|
|
15
|
+
<ste-touch-swipe width="690" :index.sync="hIndex">
|
|
16
|
+
<ste-touch-swipe-item v-for="(img, index) in imgs" :key="index">
|
|
17
|
+
<image :src="img" mode="widthFix" style="width: 100%" />
|
|
18
|
+
</ste-touch-swipe-item>
|
|
19
|
+
</ste-touch-swipe>
|
|
20
|
+
|
|
21
|
+
<script>
|
|
22
|
+
export default {
|
|
23
|
+
data() {
|
|
24
|
+
return {
|
|
25
|
+
hIndex: 0,
|
|
26
|
+
imgs: [
|
|
27
|
+
'https://image.whzb.com/chain/StellarUI/image/img1.jpg',
|
|
28
|
+
'https://image.whzb.com/chain/StellarUI/image/img2.jfif',
|
|
29
|
+
'https://image.whzb.com/chain/StellarUI/image/img3.jpg',
|
|
30
|
+
'https://image.whzb.com/chain/StellarUI/image/img4.jpg',
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
</script>
|
|
36
|
+
```
|
|
37
|
+
#### 垂直切换,固定高度
|
|
38
|
+
- 外层使用`ste-touch-swipe`父标签包裹
|
|
39
|
+
- `height`属性设置区域高度,默认`100%`
|
|
40
|
+
- 内层使用`ste-touch-swipe-item`子标签包裹每一块区域的内容
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<ste-touch-swipe height="600" direction="vertical" :index.sync="vIndex">
|
|
45
|
+
<ste-touch-swipe-item v-for="(img, index) in imgs" :key="index">
|
|
46
|
+
<image :src="img" mode="heightFix" style="height: 100%" />
|
|
47
|
+
</ste-touch-swipe-item>
|
|
48
|
+
</ste-touch-swipe>
|
|
49
|
+
|
|
50
|
+
<script>
|
|
51
|
+
export default {
|
|
52
|
+
data() {
|
|
53
|
+
return {
|
|
54
|
+
vIndex: 0,
|
|
55
|
+
imgs: [
|
|
56
|
+
'https://image.whzb.com/chain/StellarUI/image/img1.jpg',
|
|
57
|
+
'https://image.whzb.com/chain/StellarUI/image/img2.jfif',
|
|
58
|
+
'https://image.whzb.com/chain/StellarUI/image/img3.jpg',
|
|
59
|
+
'https://image.whzb.com/chain/StellarUI/image/img4.jpg',
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
</script>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
---$
|
|
69
|
+
### API
|
|
70
|
+
### touch-swipe Props
|
|
71
|
+
|
|
72
|
+
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|
|
73
|
+
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------- | ------------ | --------------------------------------------------------------------------- |
|
|
74
|
+
| `index` | 当前展示的面板索引,支持 sync 双向绑定 | `Number` | `0` | - |
|
|
75
|
+
| `direction` | 滑动方向 | `String` | `horizontal` | `horizontal`:水平方向(必须固定宽度) <br />`vertical`:垂直方向(必须固定高度) |
|
|
76
|
+
| `width` | 宽度(单位 rpx) | `String`/`Number` | `100%` | - |
|
|
77
|
+
| `height` | 高度(单位 rpx) | `String`/`Number` | `100%` | - |
|
|
78
|
+
| `duration` | 动画时长(单位 s) | `Number` | `0.3` | - |
|
|
79
|
+
| `swipeThreshold` | 灵敏度(0-1 之间的数值,数值越小越灵敏) | `Number` | `0.35` | - |
|
|
80
|
+
| `disabled` | 是否禁用 | `Boolean` | `false` | - |
|
|
81
|
+
| `childrenLength` | 子元素数量(使用 `touch-swipe-item` 作为子元素时不需要传递,不使用 `touch-swipe-item` 作为子元素盒子时必传) | `Number` | `0` | - |
|
|
82
|
+
| `disabledIndexs` | 禁用的面板索引(使用 `touch-swipe-item` 作为子元素时直接在 `touch-swipe-item` 上定义某个标签禁用即可,不使用 `touch-swipe-item` 作为子元素盒子时可传) | `Array` | `[]` | - |
|
|
83
|
+
|
|
84
|
+
### touch-swipe Event
|
|
85
|
+
|
|
86
|
+
| 事件名 | 说明 | 事件参数 |
|
|
87
|
+
| -------- | ------------ | ------------- |
|
|
88
|
+
| `change` | 滑动切换触发 | 最新的`index` |
|
|
89
|
+
|
|
90
|
+
### touch-swipe Method
|
|
91
|
+
|
|
92
|
+
| 事件名 | 说明 | 事件参数 |
|
|
93
|
+
| --------| ------------ | ------------- |
|
|
94
|
+
| `init` | 初始化滑块信息,在渲染完成后调用 | - |
|
|
95
|
+
|
|
96
|
+
### touch-swipe-item Props
|
|
97
|
+
|
|
98
|
+
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|
|
99
|
+
| ---------- | ------------------------------------------------ | --------- | ------- | ------ |
|
|
100
|
+
| `disabled` | 是否禁用当前子元素(禁用后无法滑动到当前子元素) | `Boolean` | `false` | --- |
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
---$
|
|
104
|
+
{{xuyajun}}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export default class TouchEvent {
|
|
2
|
+
startX = null;
|
|
3
|
+
startY = null;
|
|
4
|
+
moveX = null;
|
|
5
|
+
moveY = null;
|
|
6
|
+
// 滑动的最小距离
|
|
7
|
+
minDis = 50;
|
|
8
|
+
timeout = null;
|
|
9
|
+
|
|
10
|
+
constructor(minDis = 50) {
|
|
11
|
+
this.minDis = minDis;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
_getInfo(e) {
|
|
15
|
+
return e.changedTouches?.length ? e.changedTouches[0] : e;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// 滑动开始
|
|
19
|
+
touchStart(e) {
|
|
20
|
+
const { pageX, pageY } = this._getInfo(e);
|
|
21
|
+
this.startX = pageX;
|
|
22
|
+
this.startY = pageY;
|
|
23
|
+
}
|
|
24
|
+
touchMove(e) {
|
|
25
|
+
if (this.startX === null || this.startY === null) return null;
|
|
26
|
+
const { pageX, pageY } = this._getInfo(e);
|
|
27
|
+
const moveX = pageX - this.startX;
|
|
28
|
+
const moveY = pageY - this.startY;
|
|
29
|
+
if (Math.abs(moveX - this.moveX) < 1 && Math.abs(moveY - this.moveY) < 1) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
this.moveX = moveX;
|
|
33
|
+
this.moveY = moveY;
|
|
34
|
+
|
|
35
|
+
return { moveX, moveY };
|
|
36
|
+
}
|
|
37
|
+
// 滑动结束
|
|
38
|
+
touchEnd(e) {
|
|
39
|
+
if (this.startX === null || this.startY === null) {
|
|
40
|
+
return {
|
|
41
|
+
direction: null,
|
|
42
|
+
moveX: 0,
|
|
43
|
+
moveY: 0,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const { pageX, pageY } = this._getInfo(e);
|
|
47
|
+
const moveX = pageX - this.startX;
|
|
48
|
+
const moveY = pageY - this.startY;
|
|
49
|
+
this.startX = null;
|
|
50
|
+
this.startY = null;
|
|
51
|
+
this.moveX = null;
|
|
52
|
+
this.moveY = null;
|
|
53
|
+
let direction = null;
|
|
54
|
+
|
|
55
|
+
if (Math.abs(moveX) > Math.abs(moveY) && Math.abs(moveX) > this.minDis) {
|
|
56
|
+
if (moveX > 0) {
|
|
57
|
+
direction = 'right';
|
|
58
|
+
} else {
|
|
59
|
+
direction = 'left';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (Math.abs(moveY) > Math.abs(moveX) && Math.abs(moveY) > this.minDis) {
|
|
63
|
+
if (moveY > 0) {
|
|
64
|
+
direction = 'down';
|
|
65
|
+
} else {
|
|
66
|
+
direction = 'up';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return { direction, moveX, moveY };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="ste-touch-swipe-root" :style="[cmpRootStyle]">
|
|
3
|
+
<view
|
|
4
|
+
class="content"
|
|
5
|
+
@mousedown="onTouchstart"
|
|
6
|
+
@mousemove="onTouchmove"
|
|
7
|
+
@mouseup="onTouchend"
|
|
8
|
+
@mouseleave="onTouchend"
|
|
9
|
+
@touchstart="onTouchstart"
|
|
10
|
+
@touchmove.stop="onTouchmove"
|
|
11
|
+
@touchend="onTouchend"
|
|
12
|
+
@touchcancel="onTouchend"
|
|
13
|
+
>
|
|
14
|
+
<view class="content-view" :style="[cmpBoxStyle, cmpTransform]">
|
|
15
|
+
<slot />
|
|
16
|
+
</view>
|
|
17
|
+
</view>
|
|
18
|
+
</view>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script>
|
|
22
|
+
import utils from '../../utils/utils.js';
|
|
23
|
+
import TouchEvent from './TouchEvent.js';
|
|
24
|
+
import { parentMixin } from '../../utils/mixin.js';
|
|
25
|
+
/**
|
|
26
|
+
* touch-swipe 手势切屏
|
|
27
|
+
* @description 手势切屏组件
|
|
28
|
+
* @tutorial https://stellar-ui.intecloud.com.cn/pc/index/index?name=ste-touch-swipe
|
|
29
|
+
* @property {Number} index 当前展示的面板索引,支持sync双向绑定
|
|
30
|
+
* @property {String} direction 滑动方向
|
|
31
|
+
* @value horizontal (默认)水平方向:必须固定宽度
|
|
32
|
+
* @value vertical 垂直方向:必须固定高度
|
|
33
|
+
* @property {String | Number} width 宽度,默认值100%
|
|
34
|
+
* @property {String | Number} height 高度,默认值100%
|
|
35
|
+
* @property {Number} duration 动画时长,单位s
|
|
36
|
+
* @property {Number} swipeThreshold 灵敏度(0-1之间的数值,数值越小越灵敏)
|
|
37
|
+
* @property {Boolean} disabled 是否禁用
|
|
38
|
+
* @property {Number} childrenLength 面板数量(使用touch-swipe-item作为子元素时不需要传递,不使用touch-swipe-item作为子元素盒子时必传)
|
|
39
|
+
* @property {Array} disabledIndexs 禁用的面板索引(使用touch-swipe-item作为子元素时直接在touch-swipe-item上定义某个标签禁用即可,不使用touch-swipe-item作为子元素盒子时可传)
|
|
40
|
+
* */
|
|
41
|
+
export default {
|
|
42
|
+
group: '导航组件',
|
|
43
|
+
title: 'TouchSwipe 手势切屏',
|
|
44
|
+
name: 'ste-touch-swipe',
|
|
45
|
+
mixins: [parentMixin('ste-touch-swipe')],
|
|
46
|
+
provide() {
|
|
47
|
+
return {
|
|
48
|
+
_flickPanel: { getParent: () => this },
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
props: {
|
|
52
|
+
// 当前展示的面板索引
|
|
53
|
+
index: {
|
|
54
|
+
type: [Number, null],
|
|
55
|
+
default: () => 0,
|
|
56
|
+
},
|
|
57
|
+
// 滑动方向 "horizontal" | "vertical"(水平方向时宽度必须固定,垂直方向时高度必须固定)
|
|
58
|
+
direction: {
|
|
59
|
+
type: [String, null],
|
|
60
|
+
default: () => 'horizontal',
|
|
61
|
+
},
|
|
62
|
+
width: {
|
|
63
|
+
type: [String, Number, null],
|
|
64
|
+
default: () => '100%',
|
|
65
|
+
},
|
|
66
|
+
height: {
|
|
67
|
+
type: [String, Number, null],
|
|
68
|
+
default: () => '100%',
|
|
69
|
+
},
|
|
70
|
+
// 动画时长
|
|
71
|
+
duration: {
|
|
72
|
+
type: [Number, null],
|
|
73
|
+
default: () => 0.3,
|
|
74
|
+
},
|
|
75
|
+
// 灵敏度(0-1之间的数值,数值越小越灵敏)
|
|
76
|
+
swipeThreshold: {
|
|
77
|
+
type: [Number, null],
|
|
78
|
+
default: () => 0.35,
|
|
79
|
+
},
|
|
80
|
+
// 是否禁用
|
|
81
|
+
disabled: {
|
|
82
|
+
type: [Boolean, null],
|
|
83
|
+
default: () => false,
|
|
84
|
+
},
|
|
85
|
+
// 面板数量(使用touch-swipe-item作为子元素时不需要传递,不使用touch-swipe-item作为子元素盒子时必传)
|
|
86
|
+
childrenLength: {
|
|
87
|
+
type: [Number, null],
|
|
88
|
+
default: () => 0,
|
|
89
|
+
},
|
|
90
|
+
// 禁用的面板索引(使用touch-swipe-item作为子元素时直接在touch-swipe-item上定义某个标签禁用即可,不使用touch-swipe-item作为子元素盒子时可传)
|
|
91
|
+
disabledIndexs: {
|
|
92
|
+
type: [Array, null],
|
|
93
|
+
default: () => [],
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
data() {
|
|
97
|
+
return {
|
|
98
|
+
initializing: true,
|
|
99
|
+
showNode: false,
|
|
100
|
+
boxEl: null,
|
|
101
|
+
touch: new TouchEvent(),
|
|
102
|
+
moveing: false,
|
|
103
|
+
translateX: 0,
|
|
104
|
+
translateY: 0,
|
|
105
|
+
dataIndex: 0,
|
|
106
|
+
dataChildrenLength: 0,
|
|
107
|
+
dataDisabledIndexs: [],
|
|
108
|
+
_timeout: null,
|
|
109
|
+
};
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
computed: {
|
|
113
|
+
cmpRootStyle() {
|
|
114
|
+
return {
|
|
115
|
+
'--touch-swipe-width': utils.formatPx(this.width),
|
|
116
|
+
'--touch-swipe-height': utils.formatPx(this.height),
|
|
117
|
+
opacity: this.showNode ? '1' : '0',
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
cmpChildrenLength() {
|
|
121
|
+
return this.childrenLength ? this.childrenLength : this.dataChildrenLength;
|
|
122
|
+
},
|
|
123
|
+
cmpDisabledIndexs() {
|
|
124
|
+
return this.disabledIndexs.length ? this.disabledIndexs : this.dataDisabledIndexs;
|
|
125
|
+
},
|
|
126
|
+
cmpBoxStyle() {
|
|
127
|
+
let style = {};
|
|
128
|
+
if (this.direction === 'horizontal') {
|
|
129
|
+
style.gridTemplateColumns = `repeat(${this.cmpChildrenLength || 'auto-fill'}, 100%)`;
|
|
130
|
+
} else if (this.direction === 'vertical') {
|
|
131
|
+
style.gridTemplateRows = `repeat(${this.cmpChildrenLength || 'auto-fill'}, 100%)`;
|
|
132
|
+
}
|
|
133
|
+
return style;
|
|
134
|
+
},
|
|
135
|
+
cmpTransform() {
|
|
136
|
+
this.$nextTick(() => {
|
|
137
|
+
if (!this.showNode) this.showNode = true;
|
|
138
|
+
});
|
|
139
|
+
let transform = '';
|
|
140
|
+
if (this.direction === 'horizontal') {
|
|
141
|
+
transform = `translateX(${this.translateX}px)`;
|
|
142
|
+
} else if (this.direction === 'vertical') {
|
|
143
|
+
transform = `translateY(${this.translateY}px)`;
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
transform,
|
|
147
|
+
transitionDuration: this.initializing || this.moveing ? 'inherit' : `${this.duration}s`,
|
|
148
|
+
};
|
|
149
|
+
},
|
|
150
|
+
cmpItemLefts() {
|
|
151
|
+
const list = [];
|
|
152
|
+
if (!this.boxEl?.width) return list;
|
|
153
|
+
for (let i = 0; i < this.cmpChildrenLength; i++) {
|
|
154
|
+
list.push(this.boxEl.width * i);
|
|
155
|
+
}
|
|
156
|
+
return list;
|
|
157
|
+
},
|
|
158
|
+
cmpItemTops() {
|
|
159
|
+
const list = [];
|
|
160
|
+
if (!this.boxEl?.height) return list;
|
|
161
|
+
for (let i = 0; i < this.cmpChildrenLength; i++) {
|
|
162
|
+
list.push(this.boxEl.height * i);
|
|
163
|
+
}
|
|
164
|
+
return list;
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
watch: {
|
|
168
|
+
index: {
|
|
169
|
+
handler(v) {
|
|
170
|
+
if (this.dataIndex === v) return;
|
|
171
|
+
this.dataIndex = v;
|
|
172
|
+
},
|
|
173
|
+
immediate: true,
|
|
174
|
+
},
|
|
175
|
+
dataIndex() {
|
|
176
|
+
if (!this.cmpChildrenLength) return;
|
|
177
|
+
this.$nextTick(async () => {
|
|
178
|
+
await this.getBoxSize();
|
|
179
|
+
this.setTransform();
|
|
180
|
+
});
|
|
181
|
+
},
|
|
182
|
+
children() {
|
|
183
|
+
if (!this.cmpChildrenLength) return;
|
|
184
|
+
this.$nextTick(async () => {
|
|
185
|
+
await this.getBoxSize();
|
|
186
|
+
});
|
|
187
|
+
},
|
|
188
|
+
cmpItemLefts() {
|
|
189
|
+
if (!this.cmpChildrenLength) return;
|
|
190
|
+
this.$nextTick(async () => {
|
|
191
|
+
this.setTransform();
|
|
192
|
+
});
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
async mounted() {
|
|
196
|
+
await this.getBoxSize();
|
|
197
|
+
this.init();
|
|
198
|
+
},
|
|
199
|
+
methods: {
|
|
200
|
+
init() {
|
|
201
|
+
clearTimeout(this._timeout);
|
|
202
|
+
this.showNode = false;
|
|
203
|
+
this._timeout = setTimeout(() => {
|
|
204
|
+
if (this.dataChildrenLength !== this.children.length) this.dataChildrenLength = this.children.length;
|
|
205
|
+
let disabledIndexs = [];
|
|
206
|
+
this.children.forEach((m, i) => {
|
|
207
|
+
if (m.disabled) disabledIndexs.push(i);
|
|
208
|
+
});
|
|
209
|
+
let diff = this.dataDisabledIndexs.length !== disabledIndexs.length;
|
|
210
|
+
if (!diff) {
|
|
211
|
+
for (let i = 0; i < this.dataDisabledIndexs.length; i++) {
|
|
212
|
+
if (this.dataDisabledIndexs[i] !== disabledIndexs[i]) {
|
|
213
|
+
diff = true;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (diff) this.dataDisabledIndexs = disabledIndexs;
|
|
219
|
+
this.$nextTick(async () => {
|
|
220
|
+
await this.getBoxSize();
|
|
221
|
+
this.showNode = true;
|
|
222
|
+
});
|
|
223
|
+
}, 50);
|
|
224
|
+
},
|
|
225
|
+
async getBoxSize() {
|
|
226
|
+
if (this.boxEl && this.boxEl.width > 0 && this.boxEl.height > 0) return;
|
|
227
|
+
this.boxEl = await utils.querySelector('.ste-touch-swipe-root', this);
|
|
228
|
+
},
|
|
229
|
+
setTransform() {
|
|
230
|
+
if (!this.cmpItemLefts?.length) return;
|
|
231
|
+
if (this.direction === 'horizontal') {
|
|
232
|
+
this.translateX = -this.cmpItemLefts[this.dataIndex];
|
|
233
|
+
} else if (this.direction === 'vertical') {
|
|
234
|
+
this.translateY = -this.cmpItemTops[this.dataIndex];
|
|
235
|
+
}
|
|
236
|
+
if (this.initializing) {
|
|
237
|
+
setTimeout(() => {
|
|
238
|
+
this.initializing = false;
|
|
239
|
+
}, 50);
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
nextItem(moveX, moveY) {
|
|
243
|
+
let index = this.dataIndex;
|
|
244
|
+
if (this.direction === 'horizontal' && moveX !== 0) {
|
|
245
|
+
index = moveX > 0 ? index - 1 : index + 1;
|
|
246
|
+
} else if (this.direction === 'vertical' && moveY !== 0) {
|
|
247
|
+
index = moveY > 0 ? index - 1 : index + 1;
|
|
248
|
+
}
|
|
249
|
+
const disabled = this.cmpDisabledIndexs.indexOf(index) !== -1;
|
|
250
|
+
return [index, disabled];
|
|
251
|
+
},
|
|
252
|
+
swipeNext(moveX, moveY) {
|
|
253
|
+
if (this.direction === 'horizontal') {
|
|
254
|
+
return Math.abs(moveX) > this.boxEl.width * this.swipeThreshold;
|
|
255
|
+
} else if (this.direction === 'vertical') {
|
|
256
|
+
return Math.abs(moveY) > this.boxEl.height * this.swipeThreshold;
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
onTouchstart(e) {
|
|
260
|
+
if (this.disabled || !this.touch) return;
|
|
261
|
+
this.moveing = true;
|
|
262
|
+
this.getBoxSize();
|
|
263
|
+
this.touch.touchStart(e);
|
|
264
|
+
},
|
|
265
|
+
onTouchmove(e) {
|
|
266
|
+
if (this.disabled || this.duration === 0 || !this.touch || !this.moveing) return;
|
|
267
|
+
const res = this.touch.touchMove(e);
|
|
268
|
+
if (!res) return;
|
|
269
|
+
let { moveX, moveY } = res;
|
|
270
|
+
const [nextIndex, nextDisabled] = this.nextItem(moveX, moveY);
|
|
271
|
+
if (nextDisabled || nextIndex < 0 || nextIndex > this.cmpChildrenLength - 1) {
|
|
272
|
+
if (this.direction === 'horizontal') {
|
|
273
|
+
moveX = Math.floor(moveX / 4);
|
|
274
|
+
} else if (this.direction === 'vertical') {
|
|
275
|
+
moveY = Math.floor(moveY / 4);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (this.direction === 'horizontal') {
|
|
279
|
+
this.translateX = -this.cmpItemLefts[this.dataIndex] + Math.floor(moveX);
|
|
280
|
+
} else if (this.direction === 'vertical') {
|
|
281
|
+
this.translateY = -this.cmpItemTops[this.dataIndex] + Math.floor(moveY);
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
onTouchend(e) {
|
|
285
|
+
if (this.disabled || !this.touch) return;
|
|
286
|
+
this.moveing = false;
|
|
287
|
+
const { moveX, moveY } = this.touch.touchEnd(e);
|
|
288
|
+
if (this.direction === 'horizontal' && !moveX) return;
|
|
289
|
+
else if (this.direction === 'vertical' && !moveY) return;
|
|
290
|
+
const [nextIndex, nextDisabled] = this.nextItem(moveX, moveY);
|
|
291
|
+
const isSwipeNext = this.swipeNext(moveX, moveY);
|
|
292
|
+
if (nextDisabled || !isSwipeNext || nextIndex < 0 || nextIndex > this.cmpChildrenLength - 1) {
|
|
293
|
+
if (this.direction === 'horizontal') {
|
|
294
|
+
this.$nextTick(() => {
|
|
295
|
+
this.translateX = -this.cmpItemLefts[this.dataIndex];
|
|
296
|
+
});
|
|
297
|
+
} else if (this.direction === 'vertical') {
|
|
298
|
+
this.$nextTick(() => {
|
|
299
|
+
this.translateY = -this.cmpItemTops[this.dataIndex];
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
this.dataIndex = nextIndex;
|
|
305
|
+
this.$emit('update:index', nextIndex);
|
|
306
|
+
this.$emit('change', nextIndex);
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
};
|
|
310
|
+
</script>
|
|
311
|
+
|
|
312
|
+
<style lang="scss" scoped>
|
|
313
|
+
.ste-touch-swipe-root {
|
|
314
|
+
width: var(--touch-swipe-width);
|
|
315
|
+
height: var(--touch-swipe-height);
|
|
316
|
+
.content {
|
|
317
|
+
width: 100%;
|
|
318
|
+
height: 100%;
|
|
319
|
+
overflow: hidden;
|
|
320
|
+
.content-view {
|
|
321
|
+
width: 100%;
|
|
322
|
+
height: 100%;
|
|
323
|
+
display: grid;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
</style>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="ste-touch-swipe-item-root">
|
|
3
|
+
<slot />
|
|
4
|
+
</view>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import { childMixin } from '../../utils/mixin.js';
|
|
9
|
+
/**
|
|
10
|
+
* ste-touch-swipe-item 手势切屏
|
|
11
|
+
* @description 手势切屏组件
|
|
12
|
+
* @tutorial https://stellar-ui.intecloud.com.cn/pc/index/index?name=ste-touch-swipe
|
|
13
|
+
* @property {Boolean} disabled 当前面板是否禁用
|
|
14
|
+
*/
|
|
15
|
+
export default {
|
|
16
|
+
name: 'ste-touch-swipe-item',
|
|
17
|
+
mixins: [childMixin('ste-touch-swipe')],
|
|
18
|
+
props: {
|
|
19
|
+
disabled: {
|
|
20
|
+
type: [Boolean, null],
|
|
21
|
+
default: () => false,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<style lang="scss" scoped>
|
|
28
|
+
.ste-touch-swipe-item-root {
|
|
29
|
+
width: 100%;
|
|
30
|
+
height: 100%;
|
|
31
|
+
display: inline-block;
|
|
32
|
+
}
|
|
33
|
+
</style>
|