Scenic Scrollable v0.1.0 Scenic.Scrollable.Drag View Source
Module for handling the drag controllability for Scenic.Scrollable
components.
Link to this section Summary
Types
Atom representing what state the drag functionality is currently in. The drag state can be 'idle' or 'dragging'
Atom representing a mouse button
Data structure with settings that dictate the behaviour of the drag controllability.
It consists of a list with Scenic.Scrollable.Drag.mouse_button/0
s which specify the buttons with which the user can drag the Scenic.Scrollable
component.
By default, drag functionality is disabled
The state containing the necessary information to enable the drag functionality
Shorthand for Scenic.Math.vector_2/0
.
Consists of a tuple containing the x and y numeric values
Functions
Increases the current scroll speed, intended to be called when the user stops dragging. The increase in speed is intended to make the drag experience more smooth
Find out if the user is currently dragging the Scenic.Scrollable
component
Update the Scenic.Scrollable.Drag.t/0
based on the pressed mouse button, mouse position, and the position of the scrollable content
Update the Scenic.Scrollable.Drag.t/0
based on the new cursor position the user has moved to
Update the Scenic.Scrollable.Drag.t/0
based on the released mouse button and mouse position
Initialize the Scenic.Scrollable.Drag.t/0
state by passing in the Scenic.Scrollable.Drag.settings/0
settings object.
When nil is passed, the default settings will be used
Get the position of the users cursor during the previous update.
Returns an OptionEx.t/0
containing the coordinate, or :none if the user was not dragging during the previous update
Calculate the new scroll position based on the current drag state.
The result will be wrapped in an OptionEx.t/0
, resulting in :none if the user currently is not scrolling
Link to this section Types
drag_state()
View Source
drag_state() :: :idle | :dragging
drag_state() :: :idle | :dragging
Atom representing what state the drag functionality is currently in. The drag state can be 'idle' or 'dragging'.
mouse_button()
View Source
mouse_button() :: :left | :right | :middle
mouse_button() :: :left | :right | :middle
Atom representing a mouse button.
settings()
View Source
settings() :: %{optional(:mouse_buttons) => [mouse_button()]}
settings() :: %{optional(:mouse_buttons) => [mouse_button()]}
Data structure with settings that dictate the behaviour of the drag controllability.
It consists of a list with Scenic.Scrollable.Drag.mouse_button/0
s which specify the buttons with which the user can drag the Scenic.Scrollable
component.
By default, drag functionality is disabled.
t()
View Source
t() :: %Scenic.Scrollable.Drag{
current: :none | {:some, v2()},
drag_start: :none | {:some, v2()},
drag_start_content_position: :none | {:some, v2()},
drag_state: drag_state(),
enabled_buttons: [mouse_button()]
}
t() :: %Scenic.Scrollable.Drag{ current: :none | {:some, v2()}, drag_start: :none | {:some, v2()}, drag_start_content_position: :none | {:some, v2()}, drag_state: drag_state(), enabled_buttons: [mouse_button()] }
The state containing the necessary information to enable the drag functionality.
v2()
View Source
v2() :: Scenic.Math.vector_2()
v2() :: Scenic.Math.vector_2()
Shorthand for Scenic.Math.vector_2/0
.
Consists of a tuple containing the x and y numeric values.
Link to this section Functions
amplify_speed(_, speed) View Source
Increases the current scroll speed, intended to be called when the user stops dragging. The increase in speed is intended to make the drag experience more smooth.
dragging?(map) View Source
Find out if the user is currently dragging the Scenic.Scrollable
component.
handle_mouse_click(state, button, point, content_position)
View Source
handle_mouse_click(t(), mouse_button(), v2(), v2()) :: t()
handle_mouse_click(t(), mouse_button(), v2(), v2()) :: t()
Update the Scenic.Scrollable.Drag.t/0
based on the pressed mouse button, mouse position, and the position of the scrollable content.
handle_mouse_move(state, point) View Source
Update the Scenic.Scrollable.Drag.t/0
based on the new cursor position the user has moved to.
handle_mouse_release(state, button, point)
View Source
handle_mouse_release(t(), mouse_button(), v2()) :: t()
handle_mouse_release(t(), mouse_button(), v2()) :: t()
Update the Scenic.Scrollable.Drag.t/0
based on the released mouse button and mouse position.
init(settings) View Source
Initialize the Scenic.Scrollable.Drag.t/0
state by passing in the Scenic.Scrollable.Drag.settings/0
settings object.
When nil is passed, the default settings will be used.
last_position(map) View Source
Get the position of the users cursor during the previous update.
Returns an OptionEx.t/0
containing the coordinate, or :none if the user was not dragging during the previous update.
new_position(arg1) View Source
Calculate the new scroll position based on the current drag state.
The result will be wrapped in an OptionEx.t/0
, resulting in :none if the user currently is not scrolling.