@tuya-miniapp/smart-ui 2.6.4-beta-6 → 2.6.4-beta-8

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.
@@ -22,3 +22,4 @@ export declare function replacePlaceholders(template: any, values: any): any;
22
22
  export declare const getSafeAreaInsetMin: () => number;
23
23
  export declare function getSafeBottomOffset(): number;
24
24
  export declare const getDateString: (date: Date) => string | undefined;
25
+ export declare function generateRangeArray(start: number, end: number): number[];
@@ -111,3 +111,10 @@ export const getDateString = (date) => {
111
111
  const formattedDate = `${year}/${month}/${day}`;
112
112
  return formattedDate;
113
113
  };
114
+ export function generateRangeArray(start, end) {
115
+ const resultArray = [];
116
+ for (let i = start; i < end; i++) {
117
+ resultArray.push(i);
118
+ }
119
+ return resultArray;
120
+ }
@@ -1 +1 @@
1
- @import '../common/index.css';:root{--smart-ui-overlay:rgba(0,0,0,.4);--smart-ui-dialog-background:#fff;--smart-ui-border-image:linear-gradient(90deg,transparent,rgba(0,0,0,.3),transparent)}:root[theme=dark]{--smart-ui-overlay:rgba(0,0,0,.7);--smart-ui-dialog-background:#333;--smart-ui-border-image:linear-gradient(90deg,hsla(0,0%,100%,0),hsla(0,0%,100%,.3),hsla(0,0%,100%,0))}.smart-picker-column{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-size:var(--picker-option-font-size,16px);font-weight:var(--font-weight-bold,500);text-align:center}.smart-picker-column,.smart-picker-column__offset{position:relative;width:100%}.smart-picker-column__visual{position:absolute;top:0;width:100%}.smart-picker-column__item{pointer-events:none}.smart-picker-column__item--selected{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-weight:var(--picker-option-selected-font-weight-bold,var(--font-weight-bold,700))}.smart-picker-column__item--disabled{opacity:var(--picker-option-disabled-opacity,.3)}.smart-picker-column__mask{background:transparent;display:flex;flex-direction:column;height:100%;position:absolute;top:0;width:100%;z-index:10}.smart-picker-column__mask__item{flex:1}.smart-picker-column__unit{align-items:center;display:flex;justify-content:center;position:absolute;top:50%;transform:translateY(-50%);width:100%}.smart-picker-column__unit_text{color:var(--picker-option-unit-text-color,var(--app-B6-N4,rgba(0,0,0,.4)));font-size:var(--picker-option-unit-font-size,12px);left:100%;margin-left:var(--picker-option-unit-mid-size,4px);position:absolute;text-align:left;top:50%;transform:translateY(-50%);white-space:nowrap}.smart-picker-column__max-text{color:transparent;font-size:var(--picker-option-font-size,16px);font-weight:var(--font-weight-bold,500);position:relative}.smart-picker-column--disabled{opacity:var(--picker-option-disabled-opacity,.3)}
1
+ @import '../common/index.css';:root{--smart-ui-overlay:rgba(0,0,0,.4);--smart-ui-dialog-background:#fff;--smart-ui-border-image:linear-gradient(90deg,transparent,rgba(0,0,0,.3),transparent)}:root[theme=dark]{--smart-ui-overlay:rgba(0,0,0,.7);--smart-ui-dialog-background:#333;--smart-ui-border-image:linear-gradient(90deg,hsla(0,0%,100%,0),hsla(0,0%,100%,.3),hsla(0,0%,100%,0))}.smart-picker-column{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-size:var(--picker-option-font-size,16px);font-weight:var(--font-weight-bold,500);text-align:center}.smart-picker-column,.smart-picker-column__offset{position:relative;width:100%}.smart-picker-column__visual{position:absolute;top:0;width:100%}.smart-picker-column__item--selected{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-weight:var(--picker-option-selected-font-weight-bold,var(--font-weight-bold,700))}.smart-picker-column__item--disabled{opacity:var(--picker-option-disabled-opacity,.3);pointer-events:none}.smart-picker-column__mask{background:transparent;display:flex;flex-direction:column;height:100%;position:absolute;top:0;width:100%;z-index:10}.smart-picker-column__mask__item{flex:1}.smart-picker-column__unit{align-items:center;display:flex;justify-content:center;position:absolute;top:50%;transform:translateY(-50%);width:100%}.smart-picker-column__unit_text{color:var(--picker-option-unit-text-color,var(--app-B6-N4,rgba(0,0,0,.4)));font-size:var(--picker-option-unit-font-size,12px);left:100%;margin-left:var(--picker-option-unit-mid-size,4px);position:absolute;text-align:left;top:50%;transform:translateY(-50%);white-space:nowrap}.smart-picker-column__max-text{color:transparent;font-size:var(--picker-option-font-size,16px);font-weight:var(--font-weight-bold,500);position:relative}.smart-picker-column--disabled{opacity:var(--picker-option-disabled-opacity,.3)}.smart-picker-column__item_0 .smart-picker-column__item__text:after{content:var(--picker-item-content_0,"")}.smart-picker-column__item_1 .smart-picker-column__item__text:after{content:var(--picker-item-content_1,"")}.smart-picker-column__item_2 .smart-picker-column__item__text:after{content:var(--picker-item-content_2,"")}.smart-picker-column__item_3 .smart-picker-column__item__text:after{content:var(--picker-item-content_3,"")}.smart-picker-column__item_4 .smart-picker-column__item__text:after{content:var(--picker-item-content_4,"")}.smart-picker-column__item_5 .smart-picker-column__item__text:after{content:var(--picker-item-content_5,"")}.smart-picker-column__item_6 .smart-picker-column__item__text:after{content:var(--picker-item-content_6,"")}.smart-picker-column__item_7 .smart-picker-column__item__text:after{content:var(--picker-item-content_7,"")}.smart-picker-column__item_8 .smart-picker-column__item__text:after{content:var(--picker-item-content_8,"")}.smart-picker-column__item_9 .smart-picker-column__item__text:after{content:var(--picker-item-content_9,"")}.smart-picker-column__item_10 .smart-picker-column__item__text:after{content:var(--picker-item-content_10,"")}.smart-picker-column__item_11 .smart-picker-column__item__text:after{content:var(--picker-item-content_11,"")}.smart-picker-column__item_12 .smart-picker-column__item__text:after{content:var(--picker-item-content_12,"")}.smart-picker-column__item_13 .smart-picker-column__item__text:after{content:var(--picker-item-content_13,"")}.smart-picker-column__item_14 .smart-picker-column__item__text:after{content:var(--picker-item-content_14,"")}.smart-picker-column__item_15 .smart-picker-column__item__text:after{content:var(--picker-item-content_15,"")}.smart-picker-column__item_16 .smart-picker-column__item__text:after{content:var(--picker-item-content_16,"")}.smart-picker-column__item_17 .smart-picker-column__item__text:after{content:var(--picker-item-content_17,"")}.smart-picker-column__item_18 .smart-picker-column__item__text:after{content:var(--picker-item-content_18,"")}.smart-picker-column__item_19 .smart-picker-column__item__text:after{content:var(--picker-item-content_19,"")}.smart-picker-column__item_20 .smart-picker-column__item__text:after{content:var(--picker-item-content_20,"")}
@@ -1,17 +1,13 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { SmartComponent } from '../common/component';
11
- import { range } from '../common/utils';
2
+ import { generateRangeArray, range } from '../common/utils';
12
3
  import { isObj } from '../common/validator';
13
4
  import ty from '../common/ty';
14
- const DEFAULT_DURATION = 400;
5
+ const compIdList = [];
6
+ const getId = () => {
7
+ const id = 'smart-picker-column-' + compIdList.length;
8
+ compIdList.push(id);
9
+ return id;
10
+ };
15
11
  SmartComponent({
16
12
  classes: ['active-class'],
17
13
  props: {
@@ -30,8 +26,8 @@ SmartComponent({
30
26
  observer(value) {
31
27
  if (!this.data.isInit)
32
28
  return;
29
+ this.updateViewOptions();
33
30
  this.updateUint(value);
34
- this.updateVisibleOptions(this.data.currentIndex);
35
31
  },
36
32
  },
37
33
  defaultIndex: {
@@ -49,10 +45,10 @@ SmartComponent({
49
45
  activeIndex: {
50
46
  type: Number,
51
47
  value: -1,
52
- observer(index) {
48
+ observer() {
53
49
  if (!this.data.isInit)
54
50
  return;
55
- this.setIndex(index, false, this.data.changeAnimation, this.data.animationTime);
51
+ this.updateViewOptions();
56
52
  },
57
53
  },
58
54
  unit: {
@@ -63,6 +59,10 @@ SmartComponent({
63
59
  type: Number,
64
60
  value: 300,
65
61
  },
62
+ loop: {
63
+ type: Boolean,
64
+ value: false,
65
+ },
66
66
  },
67
67
  data: {
68
68
  startY: 0,
@@ -77,158 +77,73 @@ SmartComponent({
77
77
  playing: false,
78
78
  isInit: false,
79
79
  maxText: '',
80
+ instanceId: '',
80
81
  timer: null,
81
82
  preOffsetList: [],
83
+ viewOptions: [],
82
84
  },
83
85
  created() {
84
- const { defaultIndex, activeIndex, options } = this.data;
86
+ this.setData({
87
+ instanceId: getId(),
88
+ });
89
+ this.checkIndex();
90
+ this.updateViewOptions();
91
+ const { options } = this.data;
85
92
  this.updateUint(options);
86
- this.setIndex(activeIndex !== -1 ? activeIndex : defaultIndex, false, this.data.changeAnimation, this.data.animationTime);
87
93
  this.setData({
88
94
  isInit: true,
89
95
  });
90
96
  },
91
97
  methods: {
92
- getCount() {
93
- return this.data.options.length;
94
- },
95
- onTouchStart(event) {
96
- if (this.data.disabled) {
98
+ checkIndex() {
99
+ const { activeIndex } = this.data;
100
+ const index = this.adjustIndex(activeIndex);
101
+ if (activeIndex === index)
97
102
  return;
98
- }
99
- if (this.data.timer) {
100
- clearTimeout(this.data.timer);
101
- this.setData({
102
- timer: null,
103
- });
104
- }
105
- if (!this.data.playing) {
106
- this.$emit('animation-start');
107
- }
108
103
  this.setData({
109
- startY: event.touches[0].clientY,
110
- startOffset: this.data.offset,
111
- duration: 100,
112
- playing: true,
113
- timer: null,
114
- preOffsetList: [this.data.offset],
104
+ activeIndex: index,
115
105
  });
116
106
  },
117
- onTouchMove(event) {
118
- if (this.data.disabled) {
119
- return;
120
- }
107
+ adjustIndex(index) {
121
108
  const { data } = this;
122
- const { preOffsetList } = data;
123
- const deltaY = event.touches[0].clientY - data.startY;
124
- const offset = range(data.startOffset + deltaY, -(this.getCount() * data.itemHeight), data.itemHeight);
125
- const direction = this.checkIsDown(offset);
126
- // 上一次滚动的索引
127
- const preIndex = range(Math.round(-preOffsetList[preOffsetList.length - 1] / data.itemHeight), 0, this.getCount() - 1);
128
- // 最终定位索引
129
- const index = range(Math.round(-offset / data.itemHeight), 0, this.getCount() - 1);
130
- if ((direction === 'up' && index < data.renderStart + 8) ||
131
- (direction === 'down' && index > data.renderStart + data.renderNum - 8)) {
132
- this.updateVisibleOptions(index);
109
+ const count = this.data.options.length;
110
+ index = range(index, 0, count);
111
+ for (let i = index; i < count; i++) {
112
+ if (!this.isDisabled(data.options[i]))
113
+ return i;
133
114
  }
134
- // 索引变化时 粗发震动反馈
135
- if (index !== preIndex) {
136
- // @ts-ignore
137
- this.vibrateShort();
115
+ for (let i = index - 1; i >= 0; i--) {
116
+ if (!this.isDisabled(data.options[i]))
117
+ return i;
138
118
  }
139
- const animationIndex = Math.abs(-offset / data.itemHeight);
140
- this.setData({
141
- offset,
142
- animationIndex: animationIndex,
143
- preOffsetList: [...data.preOffsetList, offset],
144
- animate: false,
145
- });
146
119
  },
147
- onTouchEnd() {
148
- return __awaiter(this, void 0, void 0, function* () {
149
- const { data } = this;
150
- if (data.disabled) {
151
- return;
152
- }
153
- const { preOffsetList } = data;
154
- let preOffset = Math.max(Math.abs(preOffsetList[preOffsetList.length - 3] - preOffsetList[preOffsetList.length - 4]), Math.abs(preOffsetList[preOffsetList.length - 2] - preOffsetList[preOffsetList.length - 3]), Math.abs(preOffsetList[preOffsetList.length - 1] - preOffsetList[preOffsetList.length - 2]));
155
- if (isNaN(preOffset))
156
- preOffset = 0;
157
- preOffset = Math.min(preOffset, 40);
158
- // 三次同样的距离 说明用户一直在顶部或者底部滑动 或在move途中已经是上下边缘了
159
- const isSameTouch = (preOffsetList[preOffsetList.length - 1] === preOffsetList[preOffsetList.length - 2] &&
160
- preOffsetList[preOffsetList.length - 2] === preOffsetList[preOffsetList.length - 3]) ||
161
- preOffsetList[preOffsetList.length - 1] === -(this.getCount() * data.itemHeight) ||
162
- preOffsetList[preOffsetList.length - 1] === data.itemHeight;
163
- // 是否是向下滚动
164
- const direction = this.checkIsDown();
165
- // 当滚动速度比较慢时(<3) 不增加惯性滚动距离
166
- const offset = Math.abs(preOffset) < 3 || isSameTouch || !direction
167
- ? data.offset
168
- : data.offset + (direction === 'down' ? -preOffset : preOffset) * 10;
169
- // 有数字的最大滚动距离
170
- const countHeight = (this.getCount() - 1) * data.itemHeight;
171
- // 动画最大滚动距离 上下各加一个 data.itemHeight 的滚动空间
172
- const animationOffset = range(offset, -(this.getCount() * data.itemHeight), data.itemHeight);
173
- // 最终定位滚动位置
174
- const finOffset = animationOffset < -countHeight ? -countHeight : animationOffset > 0 ? 0 : animationOffset;
175
- // 获取索引
176
- const index = range(Math.round(-finOffset / data.itemHeight), 0, this.getCount() - 1);
177
- // 获取索引的标准距离
178
- const offsetData = -index * data.itemHeight;
179
- // 增加惯性音效
180
- if (Math.abs(offsetData - data.offset) > data.itemHeight && !isSameTouch) {
181
- const countVibrate = Math.abs(offsetData - data.offset) / data.itemHeight;
182
- // @ts-ignore
183
- this.vibrateShort(Math.floor(countVibrate), data.animationTime);
184
- }
185
- // 最终定位索引
186
- this.setData({
187
- duration: isSameTouch ? 150 : data.animationTime,
188
- animationIndex: index,
189
- offset: offsetData,
190
- animate: true,
191
- });
192
- // 更新列表
193
- if ((direction === 'up' && index < data.renderStart + 8) ||
194
- (direction === 'down' && index > data.renderStart + data.renderNum - 8)) {
195
- yield this.updateVisibleOptions(index);
196
- }
197
- // 更新索引
198
- if (index !== data.currentIndex) {
199
- const time = isSameTouch ? 150 : data.animationTime;
200
- // if (!isSameTouch) {
201
- // this.timer = setInterval(() => {
202
- // if (Math.abs(this.data.animationIndex - index) < 0.5) return clearInterval(this.timer);
203
- // this.setData({
204
- // animationIndex: this.data.animationIndex + (index - data.currentIndex > 0 ? 1 : -1),
205
- // });
206
- // }, data.animationTime / Math.abs(index - data.currentIndex));
207
- // }
208
- return this.setData({
209
- timer: setTimeout(() => __awaiter(this, void 0, void 0, function* () {
210
- this.setIndex(index, true, false, this.data.animationTime);
211
- }), time),
212
- });
213
- }
214
- this.setData({
215
- playing: false,
216
- });
217
- this.$emit('animation-end');
218
- });
120
+ isDisabled(option) {
121
+ return isObj(option) && option.disabled;
219
122
  },
220
- checkIsDown(curr) {
221
- const { data } = this;
222
- const { preOffsetList } = data;
223
- const currOffset = curr === undefined ? preOffsetList[preOffsetList.length - 1] : curr;
224
- const preOffset = curr === undefined
225
- ? preOffsetList[preOffsetList.length - 2]
226
- : preOffsetList[preOffsetList.length - 1];
227
- if (currOffset === undefined || preOffset === undefined || currOffset === preOffset)
228
- return;
229
- return currOffset < preOffset ? 'down' : 'up';
123
+ updateViewOptions() {
124
+ const currActiveIndex = this.data.activeIndex < 0 ? 0 : this.data.activeIndex;
125
+ let partNum = Math.floor(currActiveIndex / 10);
126
+ const lastNum = this.data.activeIndex - partNum * 10;
127
+ if (lastNum < 5 && partNum > 0) {
128
+ partNum -= 1;
129
+ }
130
+ const part2Times = Math.floor(partNum / 2);
131
+ const part2Percent = partNum % 2;
132
+ const onePartOffset = part2Percent + part2Times;
133
+ const twoPartOffset = part2Times;
134
+ const isReverse = onePartOffset > twoPartOffset;
135
+ const startPart = twoPartOffset + onePartOffset;
136
+ const viewIndexList = !isReverse
137
+ ? generateRangeArray(startPart * 10, startPart * 10 + 20)
138
+ : [
139
+ ...generateRangeArray(startPart * 10 + 10, startPart * 10 + 20),
140
+ ...generateRangeArray(startPart * 10, startPart * 10 + 10),
141
+ ];
142
+ this.setData({
143
+ viewOptions: viewIndexList,
144
+ });
230
145
  },
231
- vibrateShort(count, time = DEFAULT_DURATION) {
146
+ vibrateShort(count, time) {
232
147
  if (!count) {
233
148
  ty.vibrateShort({ type: 'light' });
234
149
  return;
@@ -241,17 +156,7 @@ SmartComponent({
241
156
  }
242
157
  has++;
243
158
  this.vibrateShort();
244
- }, time / count - 20);
245
- },
246
- onClickItem(event) {
247
- if (this.data.disabled)
248
- return;
249
- const { index } = event.currentTarget.dataset;
250
- if (index === this.data.currentIndex || index < 0 || index > this.data.options.length - 1) {
251
- return;
252
- }
253
- this.vibrateShort(Math.abs(index - this.data.currentIndex), DEFAULT_DURATION);
254
- this.setIndex(index, true, true, this.data.animationTime);
159
+ }, (time || this.data.animationTime) / count - 20);
255
160
  },
256
161
  updateUint(options) {
257
162
  const { unit, valueKey } = this.data;
@@ -267,127 +172,43 @@ SmartComponent({
267
172
  this.setData({ maxText });
268
173
  }
269
174
  },
270
- updateVisibleOptions(targetIndex) {
271
- const { options, visibleItemCount, currentIndex } = this.data;
272
- if (visibleItemCount < 20 && options.length > visibleItemCount) {
273
- let renderNum = 0;
274
- let renderStart = 0;
275
- // 选项多于 20 个时,进行列表优化
276
- renderNum = Math.max(visibleItemCount * 2, 20);
277
- renderStart = Math.max(0, targetIndex - renderNum / 2);
278
- const renderEnd = Math.min(options.length, renderStart + renderNum);
279
- if (currentIndex >= 0) {
280
- if (currentIndex < targetIndex) {
281
- renderStart = Math.max(0, currentIndex - renderNum / 2);
282
- }
283
- }
284
- renderNum = renderEnd - renderStart;
285
- const optionsV = options.slice(renderStart, renderEnd);
286
- return this.set({ optionsV, renderStart, renderNum });
287
- }
288
- return this.set({
289
- optionsV: options,
290
- renderStart: 0,
291
- renderNum: options.length,
292
- });
293
- },
294
- adjustIndex(index) {
295
- const { data } = this;
296
- const count = this.getCount();
297
- index = range(index, 0, count);
298
- for (let i = index; i < count; i++) {
299
- if (!this.isDisabled(data.options[i]))
300
- return i;
301
- }
302
- for (let i = index - 1; i >= 0; i--) {
303
- if (!this.isDisabled(data.options[i]))
304
- return i;
305
- }
306
- },
307
- isDisabled(option) {
308
- return isObj(option) && option.disabled;
309
- },
310
175
  getOptionText(option) {
311
176
  const { data } = this;
312
177
  return isObj(option) && data.valueKey in option ? option[data.valueKey] : option;
313
178
  },
314
- setIndex(index, userAction, animate, time = DEFAULT_DURATION) {
315
- const { data } = this;
316
- index = this.adjustIndex(index) || 0;
317
- const offset = -index * data.itemHeight;
318
- if (this.timer) {
319
- clearTimeout(this.timer);
320
- this.timer = null;
321
- }
322
- if (!data.playing) {
323
- this.$emit('animation-start');
324
- this.setData({
325
- playing: true,
326
- });
327
- }
328
- if (index !== data.currentIndex) {
329
- // 需要动画的情况下,保持最大的截取
330
- this.updateVisibleOptions(index);
331
- if (animate) {
332
- return this.set({
333
- currentIndex: index,
334
- animationIndex: index,
335
- offset,
336
- animate: true,
337
- duration: time,
338
- }).then(() => {
339
- if (!userAction) {
340
- this.setData({
341
- playing: false,
342
- });
343
- this.$emit('animation-end');
344
- return;
345
- }
346
- this.$emit('change', index);
347
- this.setData({
348
- playing: false,
349
- });
350
- this.$emit('animation-end');
351
- });
352
- }
353
- return this.set({
354
- offset,
355
- currentIndex: index,
356
- animationIndex: index,
357
- animate: !!animate,
358
- }).then(() => {
359
- if (!userAction) {
360
- this.setData({
361
- playing: false,
362
- });
363
- this.$emit('animation-end');
364
- return;
365
- }
366
- this.$emit('change', index);
367
- this.setData({
368
- playing: false,
369
- });
370
- this.$emit('animation-end');
371
- });
372
- }
373
- this.setData({
374
- playing: false,
375
- });
376
- this.$emit('animation-end');
377
- return this.set({ offset });
378
- },
379
179
  setValue(value) {
380
180
  const { options } = this.data;
381
181
  for (let i = 0; i < options.length; i++) {
382
182
  if (this.getOptionText(options[i]) === value) {
383
- return this.setIndex(i, false, this.data.changeAnimation, this.data.animationTime);
183
+ return this.setIndex(i);
384
184
  }
385
185
  }
386
186
  return Promise.resolve();
387
187
  },
188
+ setIndex(index) {
189
+ this.setData({
190
+ activeIndex: index,
191
+ });
192
+ },
388
193
  getValue() {
389
194
  const { data } = this;
390
- return data.options[data.currentIndex];
195
+ return data.options[data.activeIndex < 0 ? 0 : data.activeIndex];
196
+ },
197
+ viewOptionsChange(list) {
198
+ this.setData({
199
+ viewOptions: list,
200
+ });
201
+ },
202
+ activeIndexChange(index) {
203
+ this.setData({
204
+ activeIndex: index,
205
+ });
206
+ this.$emit('change', index);
207
+ },
208
+ animationIndexChange(index) {
209
+ this.setData({
210
+ animationIndex: index,
211
+ });
391
212
  },
392
213
  },
393
214
  });
@@ -4,33 +4,71 @@
4
4
  <view
5
5
  class="{{ utils.bem('picker-column', { disabled }) }} custom-class"
6
6
  style="{{ computed.rootStyle({ itemHeight, visibleItemCount }) }}"
7
- bind:touchstart="onTouchStart"
8
- catch:touchmove="onTouchMove"
9
- bind:touchend="onTouchEnd"
10
- bind:touchcancel="onTouchEnd"
7
+ instanceId="{{instanceId}}"
8
+ id="{{instanceId}}"
9
+ data-options="{{options}}"
10
+ data-valuekey="{{valueKey}}"
11
+ data-itemheight="{{itemHeight}}"
12
+ data-visibleitemcount="{{visibleItemCount}}"
13
+ data-activeindex="{{activeIndex}}"
14
+ data-loop="{{loop}}"
15
+ data-animationtime="{{animationTime}}"
16
+ options="{{options}}"
17
+ activeindex="{{activeIndex}}"
18
+ loop="{{loop}}"
19
+ valuekey="{{valueKey}}"
20
+ itemheight="{{itemHeight}}"
21
+ visibleitemcount="{{visibleItemCount}}"
22
+ animationtime="{{animationTime}}"
23
+ change:options="{{computed.updateValue(instanceId, 'options')}}"
24
+ change:valuekey="{{computed.updateValue(instanceId,'valueKey')}}"
25
+ change:itemheight="{{computed.updateValue(instanceId,'itemHeight')}}"
26
+ change:visibleitemcount="{{computed.updateValue(instanceId, 'visibleItemCount')}}"
27
+ change:activeindex="{{computed.updateValue(instanceId,'activeIndex')}}"
28
+ change:loop="{{computed.updateValue(instanceId,'loop')}}"
29
+ change:animationtime="{{computed.updateValue(instanceId,'animationTime')}}"
30
+ change:instanceid="{{computed.updateValue(instanceId,'instanceId')}}"
31
+ bind:touchstart="{{computed.touchStart(instanceId)}}"
32
+ catch:touchmove="{{computed.touchMove(instanceId)}}"
33
+ bind:touchend="{{computed.touchEnd(instanceId)}}"
34
+ bind:touchcancel="{{computed.touchEnd(instanceId)}}"
11
35
  >
12
- <view class="smart-picker-column__offset" style="height: {{ itemHeight * options.length }}px;{{ computed.wrapperStyle({ offset, itemHeight, visibleItemCount, animate, duration, renderStart, unit }) }}" id="options">
13
- <view class="smart-picker-column__visual" style="{{ computed.wrapperInterStyle({ offset, itemHeight, visibleItemCount, renderStart }) }}">
14
- <view
15
- wx:for="{{ optionsV }}"
16
- wx:for-item="option"
17
- wx:key="*this"
18
- data-index="{{ renderStart + index }}"
19
- style="{{computed.wrapperItemStyle({ itemHeight, fontStyle, activeStyle: renderStart + index === currentIndex ? activeStyle : '', animationIndex, index: renderStart + index, visibleItemCount })}}"
20
- class="{{ computed.wrapperItemClass({ index, renderStart, animationIndex, option })}}"
21
- >
22
- {{ computed.optionText(option, valueKey) }}
36
+ <view
37
+ id="options"
38
+ class="smart-picker-column__offset"
39
+ style="height: {{ itemHeight * options.length }}px;{{ computed.wrapperStyle({ offset, itemHeight, visibleItemCount, animate, duration, renderStart, unit, loop }) }}"
40
+ >
41
+ <view class="smart-picker-column__visual">
42
+ <view class="smart-picker-column__visual__item_1">
43
+ <view
44
+ wx:for="{{ computed.sliceArray(viewOptions, 0, 10) }}"
45
+ wx:key="index"
46
+ data-index="{{item}}"
47
+ style="{{computed.wrapperItemStyle({ itemHeight, animationIndex, index: item, visibleItemCount })}}"
48
+ class="smart-picker-column__item_{{index}} {{ computed.wrapperItemClass({ index: item, animationIndex, options })}}"
49
+ bind:tap="{{computed.tapItem(instanceId)}}"
50
+ >
51
+ <view
52
+ class="smart-picker-column__item__text"
53
+ style="{{computed.wrapperItemTextStyle({ fontStyle, activeStyle, index: item, animationIndex })}}"
54
+ ></view>
55
+ </view>
56
+ </view>
57
+ <view class="smart-picker-column__visual__item_2">
58
+ <view
59
+ wx:for="{{ computed.sliceArray(viewOptions, 10) }}"
60
+ wx:key="index"
61
+ data-index="{{item}}"
62
+ style="{{computed.wrapperItemStyle({ itemHeight, fontStyle, activeStyle: item === currentIndex ? activeStyle : '', animationIndex, index: item, visibleItemCount })}}"
63
+ class="smart-picker-column__item_{{index + 10}} {{ computed.wrapperItemClass({ index: item, animationIndex, options })}}"
64
+ bind:tap="{{computed.tapItem(instanceId)}}"
65
+ >
66
+ <view
67
+ class="smart-picker-column__item__text"
68
+ style="{{computed.wrapperItemTextStyle({ fontStyle, activeStyle, index: item, animationIndex })}}"
69
+ ></view>
70
+ </view>
23
71
  </view>
24
- </view>
25
- </view>
26
- <view class="smart-picker-column__mask">
27
- <view
28
- wx:for="{{ visibleItemCount }}"
29
- wx:key="index"
30
- class="smart-picker-column__mask__item"
31
- data-index="{{ currentIndex + index - 2 }}"
32
- bind:tap="onClickItem"
33
- >
34
72
  </view>
35
73
  </view>
36
74
  <view wx:if="{{unit}}" class="smart-picker-column__unit" style="height: {{ itemHeight }}px">