@tuya-miniapp/smart-ui 0.0.1-beta-3 → 0.0.1-beta-4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- @import '../common/index.css';.van-picker-column{color:var(--picker-option-text-color,var(--app-B6-N3,rgba(0,0,0,.5)));font-size:var(--picker-option-font-size,16px);position:relative;text-align:center}.van-picker-column__item{padding:0 5px}.van-picker-column__item--selected{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-weight:var(--font-weight-bold,500)}.van-picker-column__item--disabled{opacity:var(--picker-option-disabled-opacity,.3)}.van-picker-column__unit{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:50%;position:absolute;top:50%;transform:translate(100%,-50%)}.van-picker-column__max-text{font-weight:var(--font-weight-bold,500);opacity:0}
1
+ @import '../common/index.css';.van-picker-column{color:var(--picker-option-text-color,var(--app-B6-N3,rgba(0,0,0,.5)));font-size:var(--picker-option-font-size,16px);position:relative;text-align:center}.van-picker-column__item{padding:0 5px}.van-picker-column__item--selected{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-weight:var(--font-weight-bold,500)}.van-picker-column__item--disabled{opacity:var(--picker-option-disabled-opacity,.3)}.van-picker-column__unit{align-items:center;display:flex;justify-content:center;position:absolute;top:50%;transform:translateY(-50%);width:100%}.van-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)}.van-picker-column__unit_hidden{opacity:0}.van-picker-column__max-text{font-weight:var(--font-weight-bold,500);opacity:0}
@@ -128,7 +128,11 @@ VantComponent({
128
128
  const optionsV = options.slice(renderStart, renderEnd);
129
129
  return this.set({ optionsV, renderStart, renderNum });
130
130
  }
131
- return this.set({ optionsV: options });
131
+ return this.set({
132
+ optionsV: options,
133
+ renderStart: 0,
134
+ renderNum: options.length,
135
+ });
132
136
  },
133
137
  adjustIndex(index) {
134
138
  const { data } = this;
@@ -8,10 +8,8 @@
8
8
  catch:touchmove="onTouchMove"
9
9
  bind:touchend="onTouchEnd"
10
10
  bind:touchcancel="onTouchEnd"
11
- maxtext="{{ maxText }}"
12
- change:maxtext="{{ computed.unitStyle }}"
13
11
  >
14
- <view style="{{ computed.wrapperStyle({ offset, itemHeight, visibleItemCount, animate, duration, renderStart }) }}"
12
+ <view style="{{ computed.wrapperStyle({ offset, itemHeight, visibleItemCount, animate, duration, renderStart, unit }) }}"
15
13
  bind:transitionend="onTransitionEnd"
16
14
  id="options">
17
15
  <view
@@ -24,9 +22,10 @@
24
22
  bindtap="onClickItem"
25
23
  >{{ computed.optionText(option, valueKey) }}</view>
26
24
  </view>
27
- <view wx:if="{{unit}}" >
25
+ <view wx:if="{{unit}}" class="van-picker-column__unit" style="height: {{ itemHeight }}px">
26
+ <view class="van-picker-column__unit_text van-picker-column__unit_hidden" >{{unit}}</view>
28
27
  <text class="van-picker-column__max-text">{{ maxText }}</text>
29
- <view class="van-picker-column__unit" >{{unit}}</view>
28
+ <view class="van-picker-column__unit_text" >{{unit}}</view>
30
29
  </view>
31
30
 
32
31
  </view>
@@ -17,19 +17,6 @@ function rootStyle(data) {
17
17
  });
18
18
  }
19
19
 
20
- function unitStyle(value, oldValue, ownerInstance) {
21
- var maxTextDom = ownerInstance.selectComponent('.van-picker-column__max-text');
22
- var optionsDom = ownerInstance.selectComponent('#options');
23
- var unitDom = ownerInstance.selectComponent('.van-picker-column__unit');
24
- if (unitDom && maxTextDom) {
25
- var maxWidth = maxTextDom.getBoundingClientRect().width;
26
- optionsDom.setStyle({ 'text-indent': '-8rpx' });
27
- unitDom.setStyle({
28
- transform: 'translate(' + maxWidth / 2 + 'px,-50%)',
29
- });
30
- }
31
- }
32
-
33
20
  function wrapperStyle(data) {
34
21
  var offset =
35
22
  data.offset + (data.itemHeight * (data.visibleItemCount - 1)) / 2;
@@ -40,12 +27,14 @@ function wrapperStyle(data) {
40
27
  offset = addUnit(offset);
41
28
  if (data.animate) {
42
29
  return style({
30
+ 'text-indent': data.unit ? '-8rpx' : '0',
43
31
  transition: 'transform ' + data.duration + 'ms',
44
32
  'line-height': addUnit(data.itemHeight),
45
33
  transform: 'translate3d(0, ' + offset + ', 0)',
46
34
  });
47
35
  }
48
36
  return style({
37
+ 'text-indent': data.unit ? '-8rpx' : '0',
49
38
  'line-height': addUnit(data.itemHeight),
50
39
  transform: 'translate3d(0, ' + offset + ', 0)',
51
40
  });
@@ -55,5 +44,4 @@ module.exports = {
55
44
  optionText: optionText,
56
45
  rootStyle: rootStyle,
57
46
  wrapperStyle: wrapperStyle,
58
- unitStyle: unitStyle,
59
47
  };
@@ -1 +1 @@
1
- @import '../common/index.wxss';.van-picker-column{color:var(--picker-option-text-color,var(--app-B6-N3,rgba(0,0,0,.5)));font-size:var(--picker-option-font-size,16px);position:relative;text-align:center}.van-picker-column__item{padding:0 5px}.van-picker-column__item--selected{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-weight:var(--font-weight-bold,500)}.van-picker-column__item--disabled{opacity:var(--picker-option-disabled-opacity,.3)}.van-picker-column__unit{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:50%;position:absolute;top:50%;transform:translate(100%,-50%)}.van-picker-column__max-text{font-weight:var(--font-weight-bold,500);opacity:0}
1
+ @import '../common/index.wxss';.van-picker-column{color:var(--picker-option-text-color,var(--app-B6-N3,rgba(0,0,0,.5)));font-size:var(--picker-option-font-size,16px);position:relative;text-align:center}.van-picker-column__item{padding:0 5px}.van-picker-column__item--selected{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-weight:var(--font-weight-bold,500)}.van-picker-column__item--disabled{opacity:var(--picker-option-disabled-opacity,.3)}.van-picker-column__unit{align-items:center;display:flex;justify-content:center;position:absolute;top:50%;transform:translateY(-50%);width:100%}.van-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)}.van-picker-column__unit_hidden{opacity:0}.van-picker-column__max-text{font-weight:var(--font-weight-bold,500);opacity:0}
@@ -1 +1 @@
1
- @import '../common/index.css';.van-picker-column{color:var(--picker-option-text-color,var(--app-B6-N3,rgba(0,0,0,.5)));font-size:var(--picker-option-font-size,16px);position:relative;text-align:center}.van-picker-column__item{padding:0 5px}.van-picker-column__item--selected{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-weight:var(--font-weight-bold,500)}.van-picker-column__item--disabled{opacity:var(--picker-option-disabled-opacity,.3)}.van-picker-column__unit{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:50%;position:absolute;top:50%;transform:translate(100%,-50%)}.van-picker-column__max-text{font-weight:var(--font-weight-bold,500);opacity:0}
1
+ @import '../common/index.css';.van-picker-column{color:var(--picker-option-text-color,var(--app-B6-N3,rgba(0,0,0,.5)));font-size:var(--picker-option-font-size,16px);position:relative;text-align:center}.van-picker-column__item{padding:0 5px}.van-picker-column__item--selected{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-weight:var(--font-weight-bold,500)}.van-picker-column__item--disabled{opacity:var(--picker-option-disabled-opacity,.3)}.van-picker-column__unit{align-items:center;display:flex;justify-content:center;position:absolute;top:50%;transform:translateY(-50%);width:100%}.van-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)}.van-picker-column__unit_hidden{opacity:0}.van-picker-column__max-text{font-weight:var(--font-weight-bold,500);opacity:0}
@@ -130,7 +130,11 @@ var DEFAULT_DURATION = 200;
130
130
  var optionsV = options.slice(renderStart, renderEnd);
131
131
  return this.set({ optionsV: optionsV, renderStart: renderStart, renderNum: renderNum });
132
132
  }
133
- return this.set({ optionsV: options });
133
+ return this.set({
134
+ optionsV: options,
135
+ renderStart: 0,
136
+ renderNum: options.length,
137
+ });
134
138
  },
135
139
  adjustIndex: function (index) {
136
140
  var data = this.data;
@@ -8,10 +8,8 @@
8
8
  catch:touchmove="onTouchMove"
9
9
  bind:touchend="onTouchEnd"
10
10
  bind:touchcancel="onTouchEnd"
11
- maxtext="{{ maxText }}"
12
- change:maxtext="{{ computed.unitStyle }}"
13
11
  >
14
- <view style="{{ computed.wrapperStyle({ offset, itemHeight, visibleItemCount, animate, duration, renderStart }) }}"
12
+ <view style="{{ computed.wrapperStyle({ offset, itemHeight, visibleItemCount, animate, duration, renderStart, unit }) }}"
15
13
  bind:transitionend="onTransitionEnd"
16
14
  id="options">
17
15
  <view
@@ -24,9 +22,10 @@
24
22
  bindtap="onClickItem"
25
23
  >{{ computed.optionText(option, valueKey) }}</view>
26
24
  </view>
27
- <view wx:if="{{unit}}" >
25
+ <view wx:if="{{unit}}" class="van-picker-column__unit" style="height: {{ itemHeight }}px">
26
+ <view class="van-picker-column__unit_text van-picker-column__unit_hidden" >{{unit}}</view>
28
27
  <text class="van-picker-column__max-text">{{ maxText }}</text>
29
- <view class="van-picker-column__unit" >{{unit}}</view>
28
+ <view class="van-picker-column__unit_text" >{{unit}}</view>
30
29
  </view>
31
30
 
32
31
  </view>
@@ -17,19 +17,6 @@ function rootStyle(data) {
17
17
  });
18
18
  }
19
19
 
20
- function unitStyle(value, oldValue, ownerInstance) {
21
- var maxTextDom = ownerInstance.selectComponent('.van-picker-column__max-text');
22
- var optionsDom = ownerInstance.selectComponent('#options');
23
- var unitDom = ownerInstance.selectComponent('.van-picker-column__unit');
24
- if (unitDom && maxTextDom) {
25
- var maxWidth = maxTextDom.getBoundingClientRect().width;
26
- optionsDom.setStyle({ 'text-indent': '-8rpx' });
27
- unitDom.setStyle({
28
- transform: 'translate(' + maxWidth / 2 + 'px,-50%)',
29
- });
30
- }
31
- }
32
-
33
20
  function wrapperStyle(data) {
34
21
  var offset =
35
22
  data.offset + (data.itemHeight * (data.visibleItemCount - 1)) / 2;
@@ -40,12 +27,14 @@ function wrapperStyle(data) {
40
27
  offset = addUnit(offset);
41
28
  if (data.animate) {
42
29
  return style({
30
+ 'text-indent': data.unit ? '-8rpx' : '0',
43
31
  transition: 'transform ' + data.duration + 'ms',
44
32
  'line-height': addUnit(data.itemHeight),
45
33
  transform: 'translate3d(0, ' + offset + ', 0)',
46
34
  });
47
35
  }
48
36
  return style({
37
+ 'text-indent': data.unit ? '-8rpx' : '0',
49
38
  'line-height': addUnit(data.itemHeight),
50
39
  transform: 'translate3d(0, ' + offset + ', 0)',
51
40
  });
@@ -55,5 +44,4 @@ module.exports = {
55
44
  optionText: optionText,
56
45
  rootStyle: rootStyle,
57
46
  wrapperStyle: wrapperStyle,
58
- unitStyle: unitStyle,
59
47
  };
@@ -1 +1 @@
1
- @import '../common/index.wxss';.van-picker-column{color:var(--picker-option-text-color,var(--app-B6-N3,rgba(0,0,0,.5)));font-size:var(--picker-option-font-size,16px);position:relative;text-align:center}.van-picker-column__item{padding:0 5px}.van-picker-column__item--selected{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-weight:var(--font-weight-bold,500)}.van-picker-column__item--disabled{opacity:var(--picker-option-disabled-opacity,.3)}.van-picker-column__unit{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:50%;position:absolute;top:50%;transform:translate(100%,-50%)}.van-picker-column__max-text{font-weight:var(--font-weight-bold,500);opacity:0}
1
+ @import '../common/index.wxss';.van-picker-column{color:var(--picker-option-text-color,var(--app-B6-N3,rgba(0,0,0,.5)));font-size:var(--picker-option-font-size,16px);position:relative;text-align:center}.van-picker-column__item{padding:0 5px}.van-picker-column__item--selected{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-weight:var(--font-weight-bold,500)}.van-picker-column__item--disabled{opacity:var(--picker-option-disabled-opacity,.3)}.van-picker-column__unit{align-items:center;display:flex;justify-content:center;position:absolute;top:50%;transform:translateY(-50%);width:100%}.van-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)}.van-picker-column__unit_hidden{opacity:0}.van-picker-column__max-text{font-weight:var(--font-weight-bold,500);opacity:0}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-miniapp/smart-ui",
3
- "version": "0.0.1-beta-3",
3
+ "version": "0.0.1-beta-4",
4
4
  "author": "MiniApp Team",
5
5
  "license": "MIT",
6
6
  "miniprogram": "lib",