Skip to content

feat: taro-picker 组件添加 平铺展示 #1518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 37 commits into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
a7878df
fix: marge主分支 (#1)
yangxiaolu1993 Jun 27, 2022
4ab2003
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jun 27, 2022
f98d540
feat: imagepreview重复问题修改
yangxiaolu1993 Jun 27, 2022
67b6cad
fix: picker 组件重影问题修改
yangxiaolu1993 Jun 27, 2022
236f2fa
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jun 27, 2022
3a01721
fix: 科技样式同步
yangxiaolu1993 Jun 27, 2022
6baa48c
Merge branch 'next' of https://github.com/yangxiaolu1993/nutui into next
yangxiaolu1993 Jun 27, 2022
dbf8062
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jun 30, 2022
257bbde
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 1, 2022
6540137
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 1, 2022
535da7c
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 4, 2022
3def99e
feat: picker组件惯性滚动优化
yangxiaolu1993 Jul 6, 2022
20cde08
feat: picker组件惯性滚动优化
yangxiaolu1993 Jul 6, 2022
8f6801f
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 6, 2022
3875a2a
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 7, 2022
d00b6d6
fix: issue问题修噶
yangxiaolu1993 Jul 8, 2022
0bc2db1
fix: datepicker国际化修噶
yangxiaolu1993 Jul 8, 2022
99c8f79
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 8, 2022
eb482f4
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 11, 2022
afb0ea6
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 15, 2022
2fa73b1
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 21, 2022
8d4f961
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 27, 2022
0eacdbb
fix: datePicker在year-month下,maxDate不生效问题解决
yangxiaolu1993 Jul 27, 2022
64f2c62
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 27, 2022
e420d76
fix: picker异步处理
yangxiaolu1993 Jul 27, 2022
c466171
fix: picker taro
yangxiaolu1993 Jul 27, 2022
780e3b6
fix: picker问题修改
yangxiaolu1993 Jul 27, 2022
6422c66
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 28, 2022
a58e1c4
feat: address 新增插槽
yangxiaolu1993 Jul 29, 2022
7e5f199
feat: address 新增插槽
yangxiaolu1993 Jul 29, 2022
f601b7b
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 29, 2022
382d5ff
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 29, 2022
b8280e3
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Aug 1, 2022
0e713bb
feat: picker-Taro 添加 平铺展示
yangxiaolu1993 Aug 1, 2022
07a41f4
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Aug 1, 2022
1d57e72
feat: picker-Taro 添加 平铺展示
yangxiaolu1993 Aug 1, 2022
a242433
Merge branch 'next' of https://github.com/yangxiaolu1993/nutui into next
yangxiaolu1993 Aug 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 36 additions & 18 deletions src/packages/__VUE/picker/ColumnTaro.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
<template>
<view class="nut-picker__list" @touchstart="onTouchStart" @touchmove="onTouchMove" @touchend="onTouchEnd">
<view class="nut-picker-roller" ref="roller" :style="touchTileStyle" @transitionend="stopMomentum">
<!-- 3D 效果 -->
<view
class="nut-picker-roller-item"
:class="{ 'nut-picker-roller-item-hidden': isHidden(index + 1) }"
v-for="(item, index) in column"
:style="setRollerStyle(index + 1)"
:key="item.value ? item.value : index"
>
{{ item.text }}
</view>
<view
class="nut-picker-roller"
ref="roller"
:id="'roller' + refRandomId"
:style="threeDimensional ? touchRollerStyle : touchTileStyle"
@transitionend="stopMomentum"
>
<template v-for="(item, index) in column" :key="item.value ? item.value : index">
<!-- 3D 效果 -->
<view
class="nut-picker-roller-item"
:class="{ 'nut-picker-roller-item-hidden': isHidden(index + 1) }"
:style="setRollerStyle(index + 1)"
v-if="item && item.text && threeDimensional"
>
{{ item.text }}
</view>
<!-- 平铺 -->
<view class="nut-picker-roller-item-tile" v-if="item && item.text && !threeDimensional">
{{ item.text }}
</view>
</template>
</view>
<view class="nut-picker-roller-mask"></view>
<view class="nut-picker-content">
<view class="nut-picker-list-panel" ref="list" :id="'list' + refRandomId" :style="touchListStyle"> </view>
<view class="nut-picker-content" ref="listbox" :id="'listbox' + refRandomId" v-if="threeDimensional">
<view class="nut-picker-list-panel" ref="list" :id="'list' + refRandomId" :style="touchTileStyle"> </view>
</view>
</view>
</template>
Expand Down Expand Up @@ -76,6 +87,7 @@ export default create({
const roller = ref(null);
const list = ref(null);
const listitem = ref(null);
const listbox = ref(null);

const moving = ref(false); // 是否处于滚动中
const touchDeg = ref(0);
Expand All @@ -88,14 +100,14 @@ export default create({
const INERTIA_TIME = 300;
const INERTIA_DISTANCE = 15;

const touchListStyle = computed(() => {
const touchTileStyle = computed(() => {
return {
transition: `transform ${touchTime.value}ms cubic-bezier(0.17, 0.89, 0.45, 1)`,
transform: `translate3d(0, ${state.scrollDistance}px, 0)`
};
});

const touchTileStyle = computed(() => {
const touchRollerStyle = computed(() => {
return {
transition: `transform ${touchTime.value}ms cubic-bezier(0.17, 0.89, 0.45, 1)`,
transform: `rotate3d(1, 0, 0, ${touchDeg.value})`
Expand All @@ -108,8 +120,12 @@ export default create({
const onTouchStart = (event: TouchEvent) => {
touch.start(event);
if (moving.value) {
const { transform } = window.getComputedStyle(list.value as any);
let dom = list.value as any;
if (!props.threeDimensional) {
dom = roller.value as any;
}

const { transform } = window.getComputedStyle(dom);
state.scrollDistance = +parseInt(transform.split(', ')[1]);
}

Expand Down Expand Up @@ -255,11 +271,12 @@ export default create({
// 惯性滚动结束
const stopMomentum = () => {
moving.value = false;
console.log('滚动结束');
setChooseValue();
};

const getReference = async () => {
const refe = await useTaroRect(listbox, Taro);
state.lineSpacing = refe.height ? refe.height : 36;
modifyStatus(true);
};

Expand Down Expand Up @@ -319,11 +336,12 @@ export default create({
roller,
list,
listitem,
listbox,
onTouchStart,
onTouchMove,
onTouchEnd,
touchTileStyle,
touchListStyle,
touchRollerStyle,
setMove,
refRandomId,
stopMomentum
Expand Down
4 changes: 3 additions & 1 deletion src/packages/__VUE/picker/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ app.use(OverLay);

### 平铺展示

`threeDimensional` 可关闭 3D 滚动效果。

:::demo
```html
<template>
Expand Down Expand Up @@ -429,7 +431,7 @@ Picker 组件在底部和顶部分别设置了插槽,可进行自定义设置
| title | 设置标题 | String | - |
| cancel-text | 取消按钮文案 | String | 取消 |
| ok-text | 确定按钮文案 | String | 确定 |
| three-dimensional`小程序不支持` `v3.1.23` | 是否开启3D效果 | Boolean | true |
| three-dimensional`v3.1.23` | 是否开启3D效果 | Boolean | true |

### Columns 数据结构

Expand Down
2 changes: 1 addition & 1 deletion src/packages/__VUE/picker/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default create({
// 是否开启3D效果
threeDimensional: {
type: Boolean,
default: false
default: true
}
},
emits: ['close', 'change', 'confirm', 'update:visible', 'update:modelValue'],
Expand Down