Sha256: cce432c7fc5daab7874928becd969f300a8ad241203d8568e847edc96cb302aa

Contents?: true

Size: 883 Bytes

Versions: 25

Compression:

Stored size: 883 Bytes

Contents

class CAAnimation

  class << self

    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

  end

end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
sugarcube-1.5.9 lib/sugarcube-animations/caanimation.rb
sugarcube-1.5.8 lib/sugarcube-animations/caanimation.rb
sugarcube-1.5.7 lib/sugarcube-animations/caanimation.rb
sugarcube-1.5.6 lib/sugarcube-animations/caanimation.rb
sugarcube-1.5.5 lib/sugarcube-animations/caanimation.rb
sugarcube-1.5.4 lib/sugarcube-animations/caanimation.rb
sugarcube-1.5.3 lib/sugarcube-animations/caanimation.rb
sugarcube-1.5.2 lib/sugarcube-animations/caanimation.rb
sugarcube-1.5.1 lib/sugarcube-animations/caanimation.rb
sugarcube-1.5.0 lib/sugarcube-animations/caanimation.rb
sugarcube-1.4.6 lib/sugarcube-animations/caanimation.rb
sugarcube-1.4.5 lib/sugarcube-animations/caanimation.rb
sugarcube-1.4.4 lib/sugarcube-animations/caanimation.rb
sugarcube-1.4.3 lib/sugarcube-animations/caanimation.rb
sugarcube-1.4.2 lib/sugarcube-animations/caanimation.rb
sugarcube-1.4.1 lib/sugarcube-animations/caanimation.rb
sugarcube-1.4.0 lib/sugarcube-animations/caanimation.rb
sugarcube-1.3.11 lib/sugarcube-animations/caanimation.rb
sugarcube-1.3.10 lib/sugarcube-animations/caanimation.rb
sugarcube-1.3.9 lib/sugarcube-animations/caanimation.rb