Module: Plushie::Command::Scroll

Defined in:
lib/plushie/command/scroll.rb

Overview

Scroll commands: absolute, relative, and snap positioning.

All functions support window-qualified paths ("window#widget").

Examples:

Command::Scroll.snap_to("main#content", 0.0, 0.0)
Command.snap_to("content", 0.0, 0.0)  # also works via delegation

Class Method Summary collapse

Class Method Details

.scroll_by(widget_id, x, y) ⇒ Cmd

Scroll by a relative delta.

Parameters:

  • widget_id (String)
  • x (Numeric)

    horizontal delta

  • y (Numeric)

    vertical delta

Returns:



46
47
48
# File 'lib/plushie/command/scroll.rb', line 46

def scroll_by(widget_id, x, y)
  Command.widget_command(widget_id, "scroll_by", {x: x, y: y})
end

.scroll_to(widget_id, x, y) ⇒ Cmd

Scroll to an absolute offset.

Parameters:

  • widget_id (String)
  • x (Numeric)

    horizontal offset in pixels

  • y (Numeric)

    vertical offset in pixels

Returns:



21
22
23
# File 'lib/plushie/command/scroll.rb', line 21

def scroll_to(widget_id, x, y)
  Command.widget_command(widget_id, "scroll_to", {x: x, y: y})
end

.snap_to(widget_id, x, y) ⇒ Cmd

Snap to a relative position (0.0 to 1.0).

Parameters:

  • widget_id (String)
  • x (Float)

    horizontal relative position

  • y (Float)

    vertical relative position

Returns:



30
31
32
# File 'lib/plushie/command/scroll.rb', line 30

def snap_to(widget_id, x, y)
  Command.widget_command(widget_id, "snap_to", {x: x, y: y})
end

.snap_to_end(widget_id) ⇒ Cmd

Snap to the end of scrollable content.

Parameters:

  • widget_id (String)

Returns:



37
38
39
# File 'lib/plushie/command/scroll.rb', line 37

def snap_to_end(widget_id)
  Command.widget_command(widget_id, "snap_to_end")
end