Skip to content

Commit

Permalink
Merge pull request #44 from HaroldLever/add-dragging-input-options
Browse files Browse the repository at this point in the history
Add dragging input options
  • Loading branch information
SpyrexDE committed Feb 11, 2024
2 parents e888d28 + 61a9ab2 commit b26c259
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion addons/SmoothScroll/SmoothScrollContainer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ var damping_scroll := 0.1
## Softness of damping when "overdragging" with dragging
@export_range(0, 1)
var damping_drag := 0.1
## Allow dragging with mouse or not
@export
var drag_with_mouse = true
## Allow dragging with touch or not
@export
var drag_with_touch = true
## Scrolls to currently focused child element
@export
var follow_focus_ := true
Expand Down Expand Up @@ -217,6 +223,7 @@ func _gui_input(event: InputEvent) -> void:
damping = damping_scroll
MOUSE_BUTTON_LEFT:
if event.pressed:
if !drag_with_mouse: return
content_dragging = true
last_scroll_type = SCROLL_TYPE.DRAG
drag_start_pos = content_node.position
Expand All @@ -226,7 +233,8 @@ func _gui_input(event: InputEvent) -> void:
friction = friction_drag
damping = damping_drag

if event is InputEventScreenDrag or event is InputEventMouseMotion:
if (event is InputEventScreenDrag and drag_with_touch) \
or (event is InputEventMouseMotion and drag_with_mouse):
if content_dragging:
is_scrolling = true
if should_scroll_horizontal():
Expand All @@ -244,6 +252,7 @@ func _gui_input(event: InputEvent) -> void:

if event is InputEventScreenTouch:
if event.pressed:
if !drag_with_touch: return
content_dragging = true
last_scroll_type = SCROLL_TYPE.DRAG
drag_start_pos = content_node.position
Expand Down

0 comments on commit b26c259

Please sign in to comment.