Class: Walt::Operation::MoveOperation
- Defined in:
- lib/walt/operation/move.rb
Constant Summary collapse
- PROPERTIES =
[:from, :to, :axis]
Instance Method Summary collapse
- #finalize(view, animation) ⇒ Object
-
#initialize(params = {}) ⇒ MoveOperation
constructor
A new instance of MoveOperation.
- #setup(view, animation) ⇒ Object
Methods included from Support::AttrDefault
Constructor Details
#initialize(params = {}) ⇒ MoveOperation
Returns a new instance of MoveOperation.
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/walt/operation/move.rb', line 24 def initialize(params = {}) super if axis = (params[:axis] || params["axis"]) self.axis = axis end params.each do |key, value| if PROPERTIES.include?(key.to_sym) self.send("#{key}=", value) end end end |
Instance Method Details
#finalize(view, animation) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/walt/operation/move.rb', line 67 def finalize(view, animation) origin = view.frame.origin origin.x = (self.to[0] || origin.x) origin.y = (self.to[1] || origin.y) view.frame = [origin, view.frame.size] end |
#setup(view, animation) ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/walt/operation/move.rb', line 58 def setup(view, animation) if self.from origin = view.frame.origin origin.x = (self.from[0] || origin.x) origin.y = (self.from[1] || origin.y) view.frame = [origin, view.frame.size] end end |