Răsfoiți Sursa

bugfix when used in another scene

ncannasse 11 ani în urmă
părinte
comite
a118db98c3
1 a modificat fișierele cu 7 adăugiri și 6 ștergeri
  1. 7 6
      h2d/comp/Value.hx

+ 7 - 6
h2d/comp/Value.hx

@@ -7,7 +7,7 @@ class Value extends Interactive {
 	public var maxValue : Float = 1e10;
 	public var value(default, set) : Float;
 	public var increment : Float;
-	
+
 	public function new(?parent) {
 		super("value", parent);
 		text = new Input(this);
@@ -27,11 +27,12 @@ class Value extends Interactive {
 			if( text.hasClass(":focus") )
 				return;
 			var startVal = value;
+			var startX = e1.relX;
 			text.input.startDrag(function(e) {
 				if( e.kind == ERelease )
 					text.input.stopDrag();
 				else {
-					var dx = Math.round(e.relX - e1.relX);
+					var dx = Math.round(e.relX - startX);
 					var v = startVal + dx * increment;
 					if( v < minValue ) v = minValue;
 					if( v > maxValue ) v = maxValue;
@@ -51,12 +52,12 @@ class Value extends Interactive {
 		value = 0;
 		increment = 0.1;
 	}
-	
+
 	function set_value(v:Float) {
 		if( text != null ) text.value = ""+hxd.Math.fmt(v);
 		return value = v;
 	}
-	
+
 	override function resize( ctx : Context ) {
 		if( ctx.measure ) {
 			text.resize(ctx);
@@ -65,8 +66,8 @@ class Value extends Interactive {
 		}
 		super.resize(ctx);
 	}
-	
+
 	public dynamic function onChange( value : Float ) {
 	}
-	
+
 }