@tuya-miniapp/smart-ui 2.8.1-beta-13 → 2.8.1-beta-14

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.
@@ -58,6 +58,10 @@ SmartComponent({
58
58
  type: Number,
59
59
  value: 0,
60
60
  },
61
+ lockMaxDrag: {
62
+ type: Boolean,
63
+ value: false,
64
+ },
61
65
  midDragHeight: {
62
66
  type: Number,
63
67
  value: 0,
@@ -27,7 +27,7 @@
27
27
  <view
28
28
  id="{{curInstanceId}}"
29
29
  bind:touchstart="{{computed.onDragStart(curInstanceId)}}"
30
- catch:touchmove="{{computed.onDrag(curInstanceId)}}"
30
+ catch:touchmove="{{computed.onDrag(curInstanceId, { maxDragHeight, lockMaxDrag })}}"
31
31
  bind:touchend="{{computed.onDragEnd(curInstanceId, { maxDragHeight, minDragHeight, windowHeight, midDragHeight, closeDragHeight })}}"
32
32
  tick="{{ts}}"
33
33
  change:tick="{{computed.init(curInstanceId, currentHeight)}}"
@@ -58,7 +58,7 @@ function getEndY(params) {
58
58
  }
59
59
  }
60
60
 
61
- function onDrag(instanceId) {
61
+ function onDrag(instanceId, data) {
62
62
  return function (e, ownerInstance) {
63
63
  var delta = e.touches[0].pageY - state[instanceId].startY;
64
64
  var contentNode = getContentNode(ownerInstance, instanceId);
@@ -67,6 +67,10 @@ function onDrag(instanceId) {
67
67
  state[instanceId].delta = delta;
68
68
 
69
69
  var newHeight = originHeight - delta;
70
+ if (data.lockMaxDrag && data.maxDragHeight) {
71
+ newHeight = Math.min(newHeight, data.maxDragHeight);
72
+ }
73
+
70
74
  state[instanceId].newHeight = newHeight;
71
75
 
72
76
  contentNode.setStyle({
@@ -110,7 +114,7 @@ function onDragEnd(instanceId, data) {
110
114
  closeDragHeight: closeDragHeight,
111
115
  });
112
116
  var endHeight = endYRes.value;
113
- var position = endYRes.position
117
+ var position = endYRes.position;
114
118
  var contentNode = getContentNode(ownerInstance, instanceId);
115
119
  contentNode.setStyle({
116
120
  height: endHeight + 'px',
@@ -120,7 +124,7 @@ function onDragEnd(instanceId, data) {
120
124
  contentNode.setStyle({
121
125
  transition: 'none',
122
126
  });
123
- ownerInstance.triggerEvent('drag-position', position)
127
+ ownerInstance.triggerEvent('drag-position', position);
124
128
  }, 300);
125
129
  }
126
130
  };
@@ -63,6 +63,10 @@ var idListRef = {
63
63
  type: Number,
64
64
  value: 0,
65
65
  },
66
+ lockMaxDrag: {
67
+ type: Boolean,
68
+ value: false,
69
+ },
66
70
  midDragHeight: {
67
71
  type: Number,
68
72
  value: 0,
@@ -27,7 +27,7 @@
27
27
  <view
28
28
  id="{{curInstanceId}}"
29
29
  bind:touchstart="{{computed.onDragStart(curInstanceId)}}"
30
- catch:touchmove="{{computed.onDrag(curInstanceId)}}"
30
+ catch:touchmove="{{computed.onDrag(curInstanceId, { maxDragHeight, lockMaxDrag })}}"
31
31
  bind:touchend="{{computed.onDragEnd(curInstanceId, { maxDragHeight, minDragHeight, windowHeight, midDragHeight, closeDragHeight })}}"
32
32
  tick="{{ts}}"
33
33
  change:tick="{{computed.init(curInstanceId, currentHeight)}}"
@@ -58,7 +58,7 @@ function getEndY(params) {
58
58
  }
59
59
  }
60
60
 
61
- function onDrag(instanceId) {
61
+ function onDrag(instanceId, data) {
62
62
  return function (e, ownerInstance) {
63
63
  var delta = e.touches[0].pageY - state[instanceId].startY;
64
64
  var contentNode = getContentNode(ownerInstance, instanceId);
@@ -67,6 +67,10 @@ function onDrag(instanceId) {
67
67
  state[instanceId].delta = delta;
68
68
 
69
69
  var newHeight = originHeight - delta;
70
+ if (data.lockMaxDrag && data.maxDragHeight) {
71
+ newHeight = Math.min(newHeight, data.maxDragHeight);
72
+ }
73
+
70
74
  state[instanceId].newHeight = newHeight;
71
75
 
72
76
  contentNode.setStyle({
@@ -110,7 +114,7 @@ function onDragEnd(instanceId, data) {
110
114
  closeDragHeight: closeDragHeight,
111
115
  });
112
116
  var endHeight = endYRes.value;
113
- var position = endYRes.position
117
+ var position = endYRes.position;
114
118
  var contentNode = getContentNode(ownerInstance, instanceId);
115
119
  contentNode.setStyle({
116
120
  height: endHeight + 'px',
@@ -120,7 +124,7 @@ function onDragEnd(instanceId, data) {
120
124
  contentNode.setStyle({
121
125
  transition: 'none',
122
126
  });
123
- ownerInstance.triggerEvent('drag-position', position)
127
+ ownerInstance.triggerEvent('drag-position', position);
124
128
  }, 300);
125
129
  }
126
130
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-miniapp/smart-ui",
3
- "version": "2.8.1-beta-13",
3
+ "version": "2.8.1-beta-14",
4
4
  "author": "MiniApp Team",
5
5
  "license": "MIT",
6
6
  "miniprogram": "lib",