@tuya-miniapp/smart-ui 2.8.1-beta-11 → 2.8.1-beta-12
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.
- package/dist/slider/index.js +30 -0
- package/lib/slider/index.js +33 -0
- package/package.json +2 -2
package/dist/slider/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { SmartComponent } from '../common/component';
|
|
|
2
2
|
import { touch } from '../mixins/touch';
|
|
3
3
|
import { canIUseModel } from '../common/version';
|
|
4
4
|
import { getRect, addUnit, nextTick, addNumber, clamp } from '../common/utils';
|
|
5
|
+
import ty from '../common/ty';
|
|
5
6
|
const DRAG_STATUS = {
|
|
6
7
|
START: 'start',
|
|
7
8
|
MOVING: 'moving',
|
|
@@ -46,6 +47,10 @@ SmartComponent({
|
|
|
46
47
|
created() {
|
|
47
48
|
this.updateValue(this.data.value);
|
|
48
49
|
},
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
lastMinValue: null,
|
|
52
|
+
// @ts-ignore
|
|
53
|
+
lastMaxValue: null,
|
|
49
54
|
methods: {
|
|
50
55
|
onTouchStart(event) {
|
|
51
56
|
if (this.data.disabled)
|
|
@@ -156,6 +161,31 @@ SmartComponent({
|
|
|
156
161
|
${drag ? 'transition: none;' : ''}
|
|
157
162
|
`,
|
|
158
163
|
});
|
|
164
|
+
if (Array.isArray(value)) {
|
|
165
|
+
const nextMinValue = value[0];
|
|
166
|
+
const nextMaxValue = value[1];
|
|
167
|
+
if (this.lastMinValue !== null) {
|
|
168
|
+
if (this.lastMinValue !== nextMinValue) {
|
|
169
|
+
const isMin = value[0] === this.data.min;
|
|
170
|
+
if (isMin) {
|
|
171
|
+
ty.selectionVibrate();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (this.lastMaxValue !== null) {
|
|
176
|
+
if (this.lastMaxValue !== nextMaxValue) {
|
|
177
|
+
const isMax = value[1] === this.data.max;
|
|
178
|
+
if (isMax) {
|
|
179
|
+
ty.vibrateShort({ type: 'medium' });
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
this.lastMinValue = nextMinValue;
|
|
184
|
+
this.lastMaxValue = nextMaxValue;
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
// 单值模式不需要震动
|
|
188
|
+
}
|
|
159
189
|
if (drag) {
|
|
160
190
|
this.$emit('drag', { value });
|
|
161
191
|
}
|
package/lib/slider/index.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
var component_1 = require("../common/component");
|
|
4
7
|
var touch_1 = require("../mixins/touch");
|
|
5
8
|
var version_1 = require("../common/version");
|
|
6
9
|
var utils_1 = require("../common/utils");
|
|
10
|
+
var ty_1 = __importDefault(require("../common/ty"));
|
|
7
11
|
var DRAG_STATUS = {
|
|
8
12
|
START: 'start',
|
|
9
13
|
MOVING: 'moving',
|
|
@@ -48,6 +52,10 @@ var DRAG_STATUS = {
|
|
|
48
52
|
created: function () {
|
|
49
53
|
this.updateValue(this.data.value);
|
|
50
54
|
},
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
lastMinValue: null,
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
lastMaxValue: null,
|
|
51
59
|
methods: {
|
|
52
60
|
onTouchStart: function (event) {
|
|
53
61
|
var _this = this;
|
|
@@ -155,6 +163,31 @@ var DRAG_STATUS = {
|
|
|
155
163
|
wrapperStyle: "\n background: ".concat(this.data.inactiveColor || this.data.inActiveColor || '', ";\n ").concat(vertical ? 'width' : 'height', ": ").concat((0, utils_1.addUnit)(this.data.barHeight) || '', ";\n "),
|
|
156
164
|
barStyle: "\n ".concat(mainAxis, ": ").concat(this.calcMainAxis(), ";\n left: ").concat(vertical ? 0 : this.calcOffset(), ";\n top: ").concat(vertical ? this.calcOffset() : 0, ";\n ").concat(drag ? 'transition: none;' : '', "\n "),
|
|
157
165
|
});
|
|
166
|
+
if (Array.isArray(value)) {
|
|
167
|
+
var nextMinValue = value[0];
|
|
168
|
+
var nextMaxValue = value[1];
|
|
169
|
+
if (this.lastMinValue !== null) {
|
|
170
|
+
if (this.lastMinValue !== nextMinValue) {
|
|
171
|
+
var isMin = value[0] === this.data.min;
|
|
172
|
+
if (isMin) {
|
|
173
|
+
ty_1.default.selectionVibrate();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (this.lastMaxValue !== null) {
|
|
178
|
+
if (this.lastMaxValue !== nextMaxValue) {
|
|
179
|
+
var isMax = value[1] === this.data.max;
|
|
180
|
+
if (isMax) {
|
|
181
|
+
ty_1.default.vibrateShort({ type: 'medium' });
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
this.lastMinValue = nextMinValue;
|
|
186
|
+
this.lastMaxValue = nextMaxValue;
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
// 单值模式不需要震动
|
|
190
|
+
}
|
|
158
191
|
if (drag) {
|
|
159
192
|
this.$emit('drag', { value: value });
|
|
160
193
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuya-miniapp/smart-ui",
|
|
3
|
-
"version": "2.8.1-beta-
|
|
3
|
+
"version": "2.8.1-beta-12",
|
|
4
4
|
"author": "MiniApp Team",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"miniprogram": "lib",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"iOS >= 9"
|
|
88
88
|
],
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@ray-js/components-ty-slider": "^0.3.8
|
|
90
|
+
"@ray-js/components-ty-slider": "^0.3.8",
|
|
91
91
|
"@tuya-miniapp/icons": "^2.3.0"
|
|
92
92
|
},
|
|
93
93
|
"maintainers": [
|