5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/sugarcube-animations/caanimation.rb', line 5
def basic(target, key_path, options={}, &block)
animation = CABasicAnimation.animationWithKeyPath(key_path)
animation.duration = options[:duration] if options[:duration]
animation.delegate = options[:delegate] if options[:delegate]
if options.key?(:from) || options.key?(:to) || options.key?(:by)
add_animation = options.fetch(:add, true)
animation.fromValue = options[:from] if options[:from]
animation.toValue = options[:to] if options[:to]
animation.byValue = options[:by] if options[:by]
else
add_animation = options.fetch(:add, false)
end
if add_animation
target.addAnimation(animation, forKey:key_path)
target.send("#{key_path}=", options[:to])
end
block.call(animation) if block
return animation
end
|