Skip to content

Commit 4097d62

Browse files
yangxiaolu1993lkjh3214lkjh3214szg2008richard1015
authored
feat: taro-picker 组件添加 平铺展示 (#1518)
* fix: marge主分支 (#1) * doc: calendar 文档修改 (#1410) * feat: 添加range组件、calendar组件在线文档 * fix: 文档调整 * fix: 重构calendar组件 * feat: 日历组件重构,文档修改,功能完善 * fix: 格式化 * fix: 代码格式化调整。 * fix: 去除无用代码 * fix: 文档调整 * fix: 文档调整 * fix: taro demo 样式修改 * feat: range组件功能完善,新增 竖向操作,刻度展示。 * fix: 冲突解决 * feat: taro功能新增,兼容处理,文档修改 * feat: 添加range组件,jdt主题色 * fix: 修改组件初始化逻辑 * feat: 新增h5 日期多选功能 * feat: taro版本添加 日期多选功能 * fix: 修复多选,无法选中开头结尾日期问题 * fix: 文档修改,添加en-US 文档 * fix: 文档完善 Co-authored-by: lkjh3214 <[email protected]> Co-authored-by: love_forever <[email protected]> * feat: imagepreview 部分功能补齐 (#1412) * feat: image新增单元测试 * feat: ellipsis添加单元测试 * feat: imagepreview 添加 * fix: popop单元测试修改 * docs: 添加版本号 * feat: support highlight for JetBrains web-types * test(imagepreview): edit snap * fix(image): dts edit import * docs(input): demo和md国际化文案修改 (#1414) * fix: 抽离 input ConfirmTextType * feat: input、switch国际化 * feat: category、address国际化 * feat: taro升级maxlength问题 * fix: 国际化增加默认字段 * fix: blank * fix: input组件国际化文案修改 * style: add ellipsis add sass * docs(elevator): 增加吸顶props * feat: input组件新增input slot插槽 (#1418) * fix: 抽离 input ConfirmTextType * feat: input、switch国际化 * feat: category、address国际化 * feat: taro升级maxlength问题 * fix: 国际化增加默认字段 * fix: blank * fix: input组件国际化文案修改 * feat: input组件新增input slot插槽 * release: v3.1.22 * Update README.md add alipay img * Update README.md * docs: changelog 3.1.22 Co-authored-by: lkjh3214 <[email protected]> Co-authored-by: lkjh3214 <[email protected]> Co-authored-by: love_forever <[email protected]> Co-authored-by: richard1015 <[email protected]> Co-authored-by: ailululu <[email protected]> Co-authored-by: snandy <[email protected]> * feat: imagepreview重复问题修改 * fix: picker 组件重影问题修改 * fix: 科技样式同步 * feat: picker组件惯性滚动优化 * feat: picker组件惯性滚动优化 * fix: issue问题修噶 * fix: datepicker国际化修噶 * fix: datePicker在year-month下,maxDate不生效问题解决 * fix: picker异步处理 * fix: picker taro * fix: picker问题修改 * feat: address 新增插槽 * feat: address 新增插槽 * feat: picker-Taro 添加 平铺展示 * feat: picker-Taro 添加 平铺展示 Co-authored-by: lkjh3214 <[email protected]> Co-authored-by: lkjh3214 <[email protected]> Co-authored-by: love_forever <[email protected]> Co-authored-by: richard1015 <[email protected]> Co-authored-by: ailululu <[email protected]> Co-authored-by: snandy <[email protected]>
1 parent 734d955 commit 4097d62

File tree

3 files changed

+40
-20
lines changed

3 files changed

+40
-20
lines changed

src/packages/__VUE/picker/ColumnTaro.vue

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
11
<template>
22
<view class="nut-picker__list" @touchstart="onTouchStart" @touchmove="onTouchMove" @touchend="onTouchEnd">
3-
<view class="nut-picker-roller" ref="roller" :style="touchTileStyle" @transitionend="stopMomentum">
4-
<!-- 3D 效果 -->
5-
<view
6-
class="nut-picker-roller-item"
7-
:class="{ 'nut-picker-roller-item-hidden': isHidden(index + 1) }"
8-
v-for="(item, index) in column"
9-
:style="setRollerStyle(index + 1)"
10-
:key="item.value ? item.value : index"
11-
>
12-
{{ item.text }}
13-
</view>
3+
<view
4+
class="nut-picker-roller"
5+
ref="roller"
6+
:id="'roller' + refRandomId"
7+
:style="threeDimensional ? touchRollerStyle : touchTileStyle"
8+
@transitionend="stopMomentum"
9+
>
10+
<template v-for="(item, index) in column" :key="item.value ? item.value : index">
11+
<!-- 3D 效果 -->
12+
<view
13+
class="nut-picker-roller-item"
14+
:class="{ 'nut-picker-roller-item-hidden': isHidden(index + 1) }"
15+
:style="setRollerStyle(index + 1)"
16+
v-if="item && item.text && threeDimensional"
17+
>
18+
{{ item.text }}
19+
</view>
20+
<!-- 平铺 -->
21+
<view class="nut-picker-roller-item-tile" v-if="item && item.text && !threeDimensional">
22+
{{ item.text }}
23+
</view>
24+
</template>
1425
</view>
1526
<view class="nut-picker-roller-mask"></view>
16-
<view class="nut-picker-content">
17-
<view class="nut-picker-list-panel" ref="list" :id="'list' + refRandomId" :style="touchListStyle"> </view>
27+
<view class="nut-picker-content" ref="listbox" :id="'listbox' + refRandomId" v-if="threeDimensional">
28+
<view class="nut-picker-list-panel" ref="list" :id="'list' + refRandomId" :style="touchTileStyle"> </view>
1829
</view>
1930
</view>
2031
</template>
@@ -76,6 +87,7 @@ export default create({
7687
const roller = ref(null);
7788
const list = ref(null);
7889
const listitem = ref(null);
90+
const listbox = ref(null);
7991
8092
const moving = ref(false); // 是否处于滚动中
8193
const touchDeg = ref(0);
@@ -88,14 +100,14 @@ export default create({
88100
const INERTIA_TIME = 300;
89101
const INERTIA_DISTANCE = 15;
90102
91-
const touchListStyle = computed(() => {
103+
const touchTileStyle = computed(() => {
92104
return {
93105
transition: `transform ${touchTime.value}ms cubic-bezier(0.17, 0.89, 0.45, 1)`,
94106
transform: `translate3d(0, ${state.scrollDistance}px, 0)`
95107
};
96108
});
97109
98-
const touchTileStyle = computed(() => {
110+
const touchRollerStyle = computed(() => {
99111
return {
100112
transition: `transform ${touchTime.value}ms cubic-bezier(0.17, 0.89, 0.45, 1)`,
101113
transform: `rotate3d(1, 0, 0, ${touchDeg.value})`
@@ -108,8 +120,12 @@ export default create({
108120
const onTouchStart = (event: TouchEvent) => {
109121
touch.start(event);
110122
if (moving.value) {
111-
const { transform } = window.getComputedStyle(list.value as any);
123+
let dom = list.value as any;
124+
if (!props.threeDimensional) {
125+
dom = roller.value as any;
126+
}
112127
128+
const { transform } = window.getComputedStyle(dom);
113129
state.scrollDistance = +parseInt(transform.split(', ')[1]);
114130
}
115131
@@ -255,11 +271,12 @@ export default create({
255271
// 惯性滚动结束
256272
const stopMomentum = () => {
257273
moving.value = false;
258-
console.log('滚动结束');
259274
setChooseValue();
260275
};
261276
262277
const getReference = async () => {
278+
const refe = await useTaroRect(listbox, Taro);
279+
state.lineSpacing = refe.height ? refe.height : 36;
263280
modifyStatus(true);
264281
};
265282
@@ -319,11 +336,12 @@ export default create({
319336
roller,
320337
list,
321338
listitem,
339+
listbox,
322340
onTouchStart,
323341
onTouchMove,
324342
onTouchEnd,
325343
touchTileStyle,
326-
touchListStyle,
344+
touchRollerStyle,
327345
setMove,
328346
refRandomId,
329347
stopMomentum

src/packages/__VUE/picker/doc.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ app.use(OverLay);
121121

122122
### 平铺展示
123123

124+
`threeDimensional` 可关闭 3D 滚动效果。
125+
124126
:::demo
125127
```html
126128
<template>
@@ -429,7 +431,7 @@ Picker 组件在底部和顶部分别设置了插槽,可进行自定义设置
429431
| title | 设置标题 | String | - |
430432
| cancel-text | 取消按钮文案 | String | 取消 |
431433
| ok-text | 确定按钮文案 | String | 确定 |
432-
| three-dimensional`小程序不支持` `v3.1.23` | 是否开启3D效果 | Boolean | true |
434+
| three-dimensional`v3.1.23` | 是否开启3D效果 | Boolean | true |
433435

434436
### Columns 数据结构
435437

src/packages/__VUE/picker/index.taro.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default create({
8282
// 是否开启3D效果
8383
threeDimensional: {
8484
type: Boolean,
85-
default: false
85+
default: true
8686
}
8787
},
8888
emits: ['close', 'change', 'confirm', 'update:visible', 'update:modelValue'],

0 commit comments

Comments
 (0)