@@ -13,6 +13,9 @@ typedef ScrollOptions = {
13
13
14
14
> ControlOptions ,
15
15
16
+ ? units_to_scroll_h : Float ,
17
+ ? units_to_scroll_v : Float
18
+
16
19
} // ScrollOptions
17
20
18
21
@@ -27,6 +30,9 @@ class Scroll extends Control {
27
30
public var onchange : Signal <Void -> Void >;
28
31
public var onhandlevis : Signal <Bool -> Bool -> Void >;
29
32
33
+ public var units_to_scroll_h : Float = 16 ;
34
+ public var units_to_scroll_v : Float = 16 ;
35
+
30
36
var drag_v = false ;
31
37
var drag_y = 0.0 ;
32
38
var percent_v = 0.0 ;
@@ -51,6 +57,9 @@ class Scroll extends Control {
51
57
52
58
def (options .name , ' scroll' );
53
59
def (options .mouse_input , true );
60
+
61
+ units_to_scroll_h = def (options .units_to_scroll_h , 16 );
62
+ units_to_scroll_v = def (options .units_to_scroll_v , 16 );
54
63
55
64
super (_options );
56
65
@@ -216,8 +225,8 @@ class Scroll extends Control {
216
225
217
226
} // update_scroll
218
227
219
- inline function get_step_h () return 0.01 ; // (Math.abs(w - container.w)*0.02)/ w;
220
- inline function get_step_v () return 0.01 ; // (Math.abs(h - container.h)*0.02)/ h;
228
+ inline function get_step_h () return units_to_scroll_h / container .w ;
229
+ inline function get_step_v () return units_to_scroll_v / container .h ;
221
230
222
231
// Control overrides
223
232
@@ -275,11 +284,13 @@ class Scroll extends Control {
275
284
super .mousewheel (e );
276
285
277
286
if (e .x != 0 && visible_h ) {
278
- set_scroll_percent (percent_h + (e .x * get_step_h ()), percent_v );
287
+ var _dir = Helper .sign (e .x );
288
+ set_scroll_percent (percent_h + (_dir * get_step_h ()), percent_v );
279
289
}
280
290
281
291
if (e .y != 0 && visible_v ) {
282
- set_scroll_percent (percent_h , percent_v + (e .y * get_step_v ()));
292
+ var _dir = Helper .sign (e .y );
293
+ set_scroll_percent (percent_h , percent_v + (_dir * get_step_v ()));
283
294
}
284
295
285
296
} // mousewheel
0 commit comments