Class: Crimson::TopResizer
- Defined in:
- lib/crimson/widgets/top_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 ⇒ TopResizer
constructor
A new instance of TopResizer.
- #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 ⇒ TopResizer
Returns a new instance of TopResizer.
7 8 9 10 11 12 13 14 15 |
# File 'lib/crimson/widgets/top_resizer.rb', line 7 def initialize super('ns-resize') style.width = '100%' style.height = '5px' 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/top_resizer.rb', line 17 def on_mousemove(data) min_height = parent.style.minHeight.delete_suffix('px').to_i new_height = parent.style.height.delete_suffix('px').to_i - data.movementY new_top = parent.style.top.delete_suffix('px').to_i + data.movementY parent.style.height = "#{new_height}px" parent.style.top = "#{new_top}px" unless new_height < min_height parent.commit! end |