Class: Walt::Operation::ScaleOperation
- Defined in:
- lib/walt/operation/scale.rb
Constant Summary collapse
- PROPERTIES =
[:from, :to]
Instance Method Summary collapse
- #finalize(view, animation) ⇒ Object
-
#initialize(params = {}) ⇒ ScaleOperation
constructor
A new instance of ScaleOperation.
Methods inherited from Base
Methods included from Support::AttrDefault
Constructor Details
#initialize(params = {}) ⇒ ScaleOperation
Returns a new instance of ScaleOperation.
16 17 18 19 20 21 22 23 24 |
# File 'lib/walt/operation/scale.rb', line 16 def initialize(params = {}) super 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
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/walt/operation/scale.rb', line 26 def finalize(view, animation) scale = CABasicAnimation.animationWithKeyPath("transform.scale") from = self.from || view.instance_variable_get("@__last_scale") || 1.0 scale.fromValue = NSNumber.numberWithFloat(from) scale.toValue = NSNumber.numberWithFloat(self.to) view.instance_variable_set("@__last_scale", scale.toValue.to_f) scale.duration = animation.duration scale.removedOnCompletion = false scale.fillMode = KCAFillModeForwards view.layer.addAnimation(scale, forKey:nil) end |