Method: Fidgit::ScrollBar::Handle#initialize

Defined in:
lib/fidgit/elements/scroll_bar.rb

#initialize(options = {}) ⇒ Handle

Returns a new instance of Handle.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fidgit/elements/scroll_bar.rb', line 13

def initialize(options = {})
  super options

  subscribe :begin_drag do |sender, x, y|
    # Store position of the handle when it starts to drag.

    @drag_start_pos = [x - self.x, y - self.y]
  end

  subscribe :update_drag do |sender, x, y|
    parent.parent.handle_dragged_to x - @drag_start_pos[0], y - @drag_start_pos[1]
  end

  subscribe :end_drag do
    @drag_start_pos = nil
  end
end