Skip to content

Commit 88e1564

Browse files
committed
fix:slider
1 parent 72b1543 commit 88e1564

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

packages/form-diagram/src/slider.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ function initRect(pen: formPen) {
9797
const scaleX = pen.calculative.worldRect.width / pen.sliderWidth;
9898
const scaleY = pen.calculative.worldRect.height / pen.sliderHeight;
9999
const textScale = Math.min(scaleX, scaleY);
100-
pen.fontSize = pen._fontSize * textScale;
101-
102-
const barWidth = pen.calculative.worldRect.width - pen._textWidth * textScale;
103-
pen.textLeft = barWidth + 10 * textScale;
104-
pen.calculative.textLeft = pen.textLeft;
100+
// pen.fontSize = pen._fontSize * textScale;
101+
const scale = pen.calculative.canvas.store.data.scale;
102+
const barWidth = pen.calculative.worldRect.width - 3 * pen.calculative.fontSize;// pen._textWidth * textScale;
103+
// pen.textLeft = barWidth + 10 * textScale;
104+
// pen.calculative.textLeft = pen.textLeft;
105105

106106
pen.calculative.barRect = {
107107
x: 0,
@@ -138,8 +138,16 @@ function mouseDown(pen: formPen, e: Point) {
138138
if (pos > pen.calculative.barRect.width) {
139139
return;
140140
}
141-
142-
let value = Math.round((pos / pen.calculative.barRect.width) * 100);
141+
let value = 0;
142+
let _value = (pos / pen.calculative.barRect.width) * 100;
143+
if(_value < 1){
144+
value= 0
145+
}else if(_value > 99){
146+
value = 100;
147+
}else{
148+
value = Math.round(_value);
149+
}
150+
// let value = Math.round((pos / pen.calculative.barRect.width) * 100);
143151
if (value < pen.min || value > pen.max) {
144152
return;
145153
}

0 commit comments

Comments
 (0)