Class: Crimson::LeftResizer
- Defined in:
- lib/crimson/widgets/left_resizer.rb
Instance Attribute Summary
Attributes inherited from Resizer
Attributes inherited from Object
#added_children, #event_handlers, #id, #node, #removed_children, #tag
Attributes inherited from Model
#local, #observers, #revision_number, #revisions
Instance Method Summary collapse
-
#initialize ⇒ LeftResizer
constructor
A new instance of LeftResizer.
- #on_mousemove(data) ⇒ Object
Methods inherited from Resizer
#disable, #enable, #on_mousedown, #on_mouseup
Methods inherited from Object
#==, #add, #breadth_each, #children, #commit_tree!, #eql?, #find_descendant, #hash, #hidden?, #hide, #inspect, #move, #on, #on_event, #parent, #parent=, #postordered_each, #preordered_each, #remove, #root, #show, #shown?, #siblings, #to_s, #un
Methods inherited from Model
#add_observer, #apply_changes!, #changed?, #changes, #commit!, #master, #modify, #new_changes, #notify_observers, #reload!, #remove_observer, #rollback!
Constructor Details
#initialize ⇒ LeftResizer
Returns a new instance of LeftResizer.
7 8 9 10 11 12 13 14 15 |
# File 'lib/crimson/widgets/left_resizer.rb', line 7 def initialize super('ew-resize') style.width = '5px' style.height = '100%' style.position = 'absolute' style.top = 0 style.left = 0 end |
Instance Method Details
#on_mousemove(data) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/crimson/widgets/left_resizer.rb', line 17 def on_mousemove(data) min_width = parent.style.minWidth.delete_suffix('px').to_i new_width = parent.style.width.delete_suffix('px').to_i - data.movementX new_left = parent.style.left.delete_suffix('px').to_i + data.movementX parent.style.width = "#{new_width}px" parent.style.left = "#{new_left}px" unless new_width < min_width parent.commit! end |