@tuya-miniapp/smart-ui 2.3.1 → 2.3.2-beta-1

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.
@@ -92,6 +92,12 @@ SmartComponent({
92
92
  innerValue: Date.now(),
93
93
  columns: [],
94
94
  },
95
+ created() {
96
+ const innerValue = this.correctValue(this.data.value);
97
+ this.updateColumnValue(innerValue).then(() => {
98
+ this.$emit('input', innerValue);
99
+ });
100
+ },
95
101
  methods: {
96
102
  updateValue() {
97
103
  const { data } = this;
@@ -368,11 +374,11 @@ SmartComponent({
368
374
  .then(() => this.updateColumns())
369
375
  .then(() => picker.setValues(values));
370
376
  },
371
- },
372
- created() {
373
- const innerValue = this.correctValue(this.data.value);
374
- this.updateColumnValue(innerValue).then(() => {
375
- this.$emit('input', innerValue);
376
- });
377
+ onAnimationStart() {
378
+ this.$emit('animation-start');
379
+ },
380
+ onAnimationEnd() {
381
+ this.$emit('animation-end');
382
+ },
377
383
  },
378
384
  });
@@ -14,4 +14,6 @@
14
14
  bind:change="onChange"
15
15
  bind:confirm="onConfirm"
16
16
  bind:cancel="onCancel"
17
+ bind:animation-start="onAnimationStart"
18
+ bind:animation-end="onAnimationEnd"
17
19
  />
@@ -30,9 +30,7 @@ SmartComponent({
30
30
  }
31
31
  },
32
32
  } }),
33
- data: {
34
- animating: false,
35
- },
33
+ data: {},
36
34
  beforeCreate() {
37
35
  Object.defineProperty(this, 'children', {
38
36
  get: () => this.selectAllComponents('.smart-picker__column') || [],
@@ -145,20 +143,21 @@ SmartComponent({
145
143
  return Promise.all(stack);
146
144
  },
147
145
  animationStart() {
148
- if (this.data.animating)
146
+ if (this.animating)
149
147
  return;
150
- this.setData({
151
- animating: true,
152
- });
148
+ this.animating = true;
153
149
  this.$emit('animation-start');
154
150
  },
155
151
  animationEnd() {
156
- if (!this.data.animating)
157
- return;
158
- this.setData({
159
- animating: false,
160
- });
161
- this.$emit('animation-end');
152
+ const { endTimeout } = this;
153
+ if (endTimeout) {
154
+ clearTimeout(endTimeout);
155
+ }
156
+ this.endTimeout = setTimeout(() => {
157
+ this.$emit('animation-end');
158
+ this.animating = false;
159
+ this.endTimeout = null;
160
+ }, 300);
162
161
  },
163
162
  },
164
163
  });
@@ -26,6 +26,8 @@ SmartComponent({
26
26
  type: Array,
27
27
  value: [],
28
28
  observer(value) {
29
+ if (!this.data.isInit)
30
+ return;
29
31
  this.updateUint(value);
30
32
  this.updateVisibleOptions(this.data.currentIndex);
31
33
  },
@@ -42,6 +44,8 @@ SmartComponent({
42
44
  type: Number,
43
45
  value: -1,
44
46
  observer(index) {
47
+ if (!this.data.isInit)
48
+ return;
45
49
  this.setIndex(index, false, this.data.changeAnimation);
46
50
  },
47
51
  },
@@ -61,6 +65,7 @@ SmartComponent({
61
65
  renderStart: 0,
62
66
  animate: false,
63
67
  playing: false,
68
+ isInit: false,
64
69
  maxText: '',
65
70
  timer: null,
66
71
  preOffsetList: [],
@@ -69,6 +74,9 @@ SmartComponent({
69
74
  const { defaultIndex, activeIndex, options } = this.data;
70
75
  this.updateUint(options);
71
76
  this.setIndex(activeIndex !== -1 ? activeIndex : defaultIndex, false, this.data.changeAnimation);
77
+ this.setData({
78
+ isInit: true,
79
+ });
72
80
  },
73
81
  methods: {
74
82
  getCount() {
@@ -116,6 +116,13 @@ var defaultFormatter = function (type, value) {
116
116
  innerValue: Date.now(),
117
117
  columns: [],
118
118
  },
119
+ created: function () {
120
+ var _this = this;
121
+ var innerValue = this.correctValue(this.data.value);
122
+ this.updateColumnValue(innerValue).then(function () {
123
+ _this.$emit('input', innerValue);
124
+ });
125
+ },
119
126
  methods: {
120
127
  updateValue: function () {
121
128
  var _this = this;
@@ -404,12 +411,11 @@ var defaultFormatter = function (type, value) {
404
411
  .then(function () { return _this.updateColumns(); })
405
412
  .then(function () { return picker.setValues(values); });
406
413
  },
407
- },
408
- created: function () {
409
- var _this = this;
410
- var innerValue = this.correctValue(this.data.value);
411
- this.updateColumnValue(innerValue).then(function () {
412
- _this.$emit('input', innerValue);
413
- });
414
+ onAnimationStart: function () {
415
+ this.$emit('animation-start');
416
+ },
417
+ onAnimationEnd: function () {
418
+ this.$emit('animation-end');
419
+ },
414
420
  },
415
421
  });
@@ -14,4 +14,6 @@
14
14
  bind:change="onChange"
15
15
  bind:confirm="onConfirm"
16
16
  bind:cancel="onCancel"
17
+ bind:animation-start="onAnimationStart"
18
+ bind:animation-end="onAnimationEnd"
17
19
  />
@@ -44,9 +44,7 @@ var shared_1 = require("./shared");
44
44
  }
45
45
  },
46
46
  } }),
47
- data: {
48
- animating: false,
49
- },
47
+ data: {},
50
48
  beforeCreate: function () {
51
49
  var _this = this;
52
50
  Object.defineProperty(this, 'children', {
@@ -168,20 +166,22 @@ var shared_1 = require("./shared");
168
166
  return Promise.all(stack);
169
167
  },
170
168
  animationStart: function () {
171
- if (this.data.animating)
169
+ if (this.animating)
172
170
  return;
173
- this.setData({
174
- animating: true,
175
- });
171
+ this.animating = true;
176
172
  this.$emit('animation-start');
177
173
  },
178
174
  animationEnd: function () {
179
- if (!this.data.animating)
180
- return;
181
- this.setData({
182
- animating: false,
183
- });
184
- this.$emit('animation-end');
175
+ var _this = this;
176
+ var endTimeout = this.endTimeout;
177
+ if (endTimeout) {
178
+ clearTimeout(endTimeout);
179
+ }
180
+ this.endTimeout = setTimeout(function () {
181
+ _this.$emit('animation-end');
182
+ _this.animating = false;
183
+ _this.endTimeout = null;
184
+ }, 300);
185
185
  },
186
186
  },
187
187
  });
@@ -64,6 +64,8 @@ var DEFAULT_DURATION = 400;
64
64
  type: Array,
65
65
  value: [],
66
66
  observer: function (value) {
67
+ if (!this.data.isInit)
68
+ return;
67
69
  this.updateUint(value);
68
70
  this.updateVisibleOptions(this.data.currentIndex);
69
71
  },
@@ -80,6 +82,8 @@ var DEFAULT_DURATION = 400;
80
82
  type: Number,
81
83
  value: -1,
82
84
  observer: function (index) {
85
+ if (!this.data.isInit)
86
+ return;
83
87
  this.setIndex(index, false, this.data.changeAnimation);
84
88
  },
85
89
  },
@@ -99,6 +103,7 @@ var DEFAULT_DURATION = 400;
99
103
  renderStart: 0,
100
104
  animate: false,
101
105
  playing: false,
106
+ isInit: false,
102
107
  maxText: '',
103
108
  timer: null,
104
109
  preOffsetList: [],
@@ -107,6 +112,9 @@ var DEFAULT_DURATION = 400;
107
112
  var _a = this.data, defaultIndex = _a.defaultIndex, activeIndex = _a.activeIndex, options = _a.options;
108
113
  this.updateUint(options);
109
114
  this.setIndex(activeIndex !== -1 ? activeIndex : defaultIndex, false, this.data.changeAnimation);
115
+ this.setData({
116
+ isInit: true,
117
+ });
110
118
  },
111
119
  methods: {
112
120
  getCount: function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-miniapp/smart-ui",
3
- "version": "2.3.1",
3
+ "version": "2.3.2-beta-1",
4
4
  "author": "MiniApp Team",
5
5
  "license": "MIT",
6
6
  "miniprogram": "lib",