@tuya-miniapp/smart-ui 2.7.1-beta-7 → 2.7.1-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.
|
@@ -64,6 +64,12 @@ SmartComponent({
|
|
|
64
64
|
loop: {
|
|
65
65
|
type: Boolean,
|
|
66
66
|
value: false,
|
|
67
|
+
observer() {
|
|
68
|
+
if (!this.data.isInit)
|
|
69
|
+
return;
|
|
70
|
+
this.updateCurrentIndex(this.data.currentIndex);
|
|
71
|
+
this.updateVisibleOptions();
|
|
72
|
+
},
|
|
67
73
|
},
|
|
68
74
|
},
|
|
69
75
|
data: {
|
|
@@ -97,7 +103,7 @@ SmartComponent({
|
|
|
97
103
|
const count = this.data.options.length;
|
|
98
104
|
let animationIndex = this.getAnimationIndex(currIndex);
|
|
99
105
|
animationIndex = this.adjustIndex(animationIndex);
|
|
100
|
-
let currActiveIndex = this.data.loop ? ((animationIndex + 1) % count) - 1 : animationIndex;
|
|
106
|
+
let currActiveIndex = this.data.loop && count > 1 ? ((animationIndex + 1) % count) - 1 : animationIndex;
|
|
101
107
|
if (currActiveIndex < 0) {
|
|
102
108
|
currActiveIndex += count;
|
|
103
109
|
}
|
|
@@ -115,7 +121,7 @@ SmartComponent({
|
|
|
115
121
|
getAnimationIndex(currentIndex) {
|
|
116
122
|
const { animationIndex } = this.data;
|
|
117
123
|
const length = this.data.options.length || 1;
|
|
118
|
-
if (this.data.loop) {
|
|
124
|
+
if (this.data.loop && length > 1) {
|
|
119
125
|
const newAnimationIndex = this.getNewAnimationIndex(animationIndex, currentIndex, length, this.data.loop);
|
|
120
126
|
return newAnimationIndex;
|
|
121
127
|
}
|
|
@@ -169,7 +175,7 @@ SmartComponent({
|
|
|
169
175
|
const partCount = Math.floor(this.data.visibleItemCount / 2) + 3;
|
|
170
176
|
const newArr = new Array(vOptionLength).fill('');
|
|
171
177
|
const newValueArr = new Array(partCount * 2 + 1).fill('');
|
|
172
|
-
if (this.data.loop) {
|
|
178
|
+
if (this.data.loop && this.data.options.length > 1) {
|
|
173
179
|
// 循环模式:根据 options 首尾填充 newValueArr 数组
|
|
174
180
|
const optionsLength = this.data.options.length;
|
|
175
181
|
if (optionsLength === 0) {
|
|
@@ -243,7 +249,7 @@ SmartComponent({
|
|
|
243
249
|
adjustIndex(index) {
|
|
244
250
|
const { data } = this;
|
|
245
251
|
const count = this.getCount();
|
|
246
|
-
if (this.data.loop) {
|
|
252
|
+
if (this.data.loop && count > 1) {
|
|
247
253
|
for (let i = 0; i < count; i++) {
|
|
248
254
|
const targetIndex = index + i;
|
|
249
255
|
let optionIndex = ((targetIndex + 1) % count) - 1;
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
data-itemheight="{{itemHeight}}"
|
|
14
14
|
data-visibleitemcount="{{visibleItemCount}}"
|
|
15
15
|
data-activeindex="{{currentIndex}}"
|
|
16
|
-
data-loop="{{loop}}"
|
|
16
|
+
data-loop="{{loop && options.length > 1}}"
|
|
17
17
|
data-animationtime="{{animationTime}}"
|
|
18
18
|
isdestroy="{{isDestroy}}"
|
|
19
19
|
options="{{options}}"
|
|
20
20
|
activeindex="{{currentIndex}}"
|
|
21
21
|
changeanimation="{{changeAnimation}}"
|
|
22
|
-
loop="{{loop}}"
|
|
22
|
+
loop="{{loop && options.length > 1}}"
|
|
23
23
|
valuekey="{{valueKey}}"
|
|
24
24
|
itemheight="{{itemHeight}}"
|
|
25
25
|
visibleitemcount="{{visibleItemCount}}"
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
bind:touchend="{{computed.touchEnd(instanceId)}}"
|
|
39
39
|
bind:touchcancel="{{computed.touchEnd(instanceId)}}"
|
|
40
40
|
>
|
|
41
|
-
<view class="smart-picker-column__offset" style="{{ computed.wrapperStyle({ animationIndex, itemHeight, animationTime, unit, moving, optionsVIndexList, options, valueKey, visibleItemCount, loop, changeAnimation }) }}" id="options">
|
|
41
|
+
<view class="smart-picker-column__offset" style="{{ computed.wrapperStyle({ animationIndex, itemHeight, animationTime, unit, moving, optionsVIndexList, options, valueKey, visibleItemCount, loop: loop && options.length > 1, changeAnimation }) }}" id="options">
|
|
42
42
|
<view
|
|
43
43
|
wx:for="{{ optionsVIndexList }}"
|
|
44
44
|
wx:for-item="optionIndex"
|
|
@@ -69,6 +69,12 @@ var getId = function () {
|
|
|
69
69
|
loop: {
|
|
70
70
|
type: Boolean,
|
|
71
71
|
value: false,
|
|
72
|
+
observer: function () {
|
|
73
|
+
if (!this.data.isInit)
|
|
74
|
+
return;
|
|
75
|
+
this.updateCurrentIndex(this.data.currentIndex);
|
|
76
|
+
this.updateVisibleOptions();
|
|
77
|
+
},
|
|
72
78
|
},
|
|
73
79
|
},
|
|
74
80
|
data: {
|
|
@@ -102,7 +108,7 @@ var getId = function () {
|
|
|
102
108
|
var count = this.data.options.length;
|
|
103
109
|
var animationIndex = this.getAnimationIndex(currIndex);
|
|
104
110
|
animationIndex = this.adjustIndex(animationIndex);
|
|
105
|
-
var currActiveIndex = this.data.loop ? ((animationIndex + 1) % count) - 1 : animationIndex;
|
|
111
|
+
var currActiveIndex = this.data.loop && count > 1 ? ((animationIndex + 1) % count) - 1 : animationIndex;
|
|
106
112
|
if (currActiveIndex < 0) {
|
|
107
113
|
currActiveIndex += count;
|
|
108
114
|
}
|
|
@@ -120,7 +126,7 @@ var getId = function () {
|
|
|
120
126
|
getAnimationIndex: function (currentIndex) {
|
|
121
127
|
var animationIndex = this.data.animationIndex;
|
|
122
128
|
var length = this.data.options.length || 1;
|
|
123
|
-
if (this.data.loop) {
|
|
129
|
+
if (this.data.loop && length > 1) {
|
|
124
130
|
var newAnimationIndex = this.getNewAnimationIndex(animationIndex, currentIndex, length, this.data.loop);
|
|
125
131
|
return newAnimationIndex;
|
|
126
132
|
}
|
|
@@ -175,7 +181,7 @@ var getId = function () {
|
|
|
175
181
|
var partCount = Math.floor(this.data.visibleItemCount / 2) + 3;
|
|
176
182
|
var newArr = new Array(vOptionLength).fill('');
|
|
177
183
|
var newValueArr = new Array(partCount * 2 + 1).fill('');
|
|
178
|
-
if (this.data.loop) {
|
|
184
|
+
if (this.data.loop && this.data.options.length > 1) {
|
|
179
185
|
// 循环模式:根据 options 首尾填充 newValueArr 数组
|
|
180
186
|
var optionsLength_1 = this.data.options.length;
|
|
181
187
|
if (optionsLength_1 === 0) {
|
|
@@ -249,7 +255,7 @@ var getId = function () {
|
|
|
249
255
|
adjustIndex: function (index) {
|
|
250
256
|
var data = this.data;
|
|
251
257
|
var count = this.getCount();
|
|
252
|
-
if (this.data.loop) {
|
|
258
|
+
if (this.data.loop && count > 1) {
|
|
253
259
|
for (var i = 0; i < count; i++) {
|
|
254
260
|
var targetIndex = index + i;
|
|
255
261
|
var optionIndex = ((targetIndex + 1) % count) - 1;
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
data-itemheight="{{itemHeight}}"
|
|
14
14
|
data-visibleitemcount="{{visibleItemCount}}"
|
|
15
15
|
data-activeindex="{{currentIndex}}"
|
|
16
|
-
data-loop="{{loop}}"
|
|
16
|
+
data-loop="{{loop && options.length > 1}}"
|
|
17
17
|
data-animationtime="{{animationTime}}"
|
|
18
18
|
isdestroy="{{isDestroy}}"
|
|
19
19
|
options="{{options}}"
|
|
20
20
|
activeindex="{{currentIndex}}"
|
|
21
21
|
changeanimation="{{changeAnimation}}"
|
|
22
|
-
loop="{{loop}}"
|
|
22
|
+
loop="{{loop && options.length > 1}}"
|
|
23
23
|
valuekey="{{valueKey}}"
|
|
24
24
|
itemheight="{{itemHeight}}"
|
|
25
25
|
visibleitemcount="{{visibleItemCount}}"
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
bind:touchend="{{computed.touchEnd(instanceId)}}"
|
|
39
39
|
bind:touchcancel="{{computed.touchEnd(instanceId)}}"
|
|
40
40
|
>
|
|
41
|
-
<view class="smart-picker-column__offset" style="{{ computed.wrapperStyle({ animationIndex, itemHeight, animationTime, unit, moving, optionsVIndexList, options, valueKey, visibleItemCount, loop, changeAnimation }) }}" id="options">
|
|
41
|
+
<view class="smart-picker-column__offset" style="{{ computed.wrapperStyle({ animationIndex, itemHeight, animationTime, unit, moving, optionsVIndexList, options, valueKey, visibleItemCount, loop: loop && options.length > 1, changeAnimation }) }}" id="options">
|
|
42
42
|
<view
|
|
43
43
|
wx:for="{{ optionsVIndexList }}"
|
|
44
44
|
wx:for-item="optionIndex"
|