Skip to content

Commit

Permalink
useNativeScrollers toolkit option
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed May 20, 2024
1 parent 78e52e3 commit 3f3245b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
9 changes: 7 additions & 2 deletions haxe/ui/backend/ComponentImpl.hx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class ComponentImpl extends ComponentBase {
}

private override function get_isNativeScroller():Bool {
return false;
return Platform.instance.useNativeScrollers;
}

private function recursiveReady() {
Expand Down Expand Up @@ -136,7 +136,9 @@ class ComponentImpl extends ComponentBase {

element.scrollTop = 0;
element.scrollLeft = 0;
//element.style.overflow = "hidden";
if (Platform.instance.useNativeScrollers) {
element.style.overflow = "auto";
}
element.classList.add("haxeui-component");
elementToComponent.set(element, cast(this, Component));

Expand Down Expand Up @@ -255,6 +257,9 @@ class ComponentImpl extends ComponentBase {
}

private override function handleClipRect(value:Rectangle) {
if (Platform.instance.useNativeScrollers) {
return;
}
var c:Component = cast(this, Component);
var parent:Component = c.parentComponent;
value.toInts();
Expand Down
11 changes: 11 additions & 0 deletions haxe/ui/backend/PlatformImpl.hx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ class PlatformImpl extends PlatformBase {
return Browser.window.performance.now();
}

public var useNativeScrollers(get, null):Bool;
private function get_useNativeScrollers():Bool @:privateAccess {
if (Screen.instance._options == null) {
return false;
}
if (Screen.instance._options.throttleMouseWheelPlatforms == null) {
return false;
}
return Screen.instance._options.useNativeScrollers;
}

public var throttleMouseWheelPlatforms(get, null):Array<String>;
private function get_throttleMouseWheelPlatforms():Array<String> @:privateAccess {
if (Screen.instance._options == null) {
Expand Down
1 change: 1 addition & 0 deletions haxe/ui/backend/ToolkitOptions.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import js.html.Element;

typedef ToolkitOptions = {
?container:Element,
?useNativeScrollers:Bool,
?throttleMouseWheelPlatforms:Array<String>,
?throttleMouseWheelTimestampDelta:Null<Float>
}

0 comments on commit 3f3245b

Please sign in to comment.