Sha256: a6e10dacb1008ed6f3d59654da044f0b3b0926c5fd08e4a53a37a9475ac21288

Contents?: true

Size: 923 Bytes

Versions: 59

Compression:

Stored size: 923 Bytes

Contents

class CALayer

  def basic_animation(key_path, options={})
    animation = CAAnimation.basic(key_path, options)

    should_add = options.fetch(:add, true)
    if should_add
      if should_add.is_a?(NSString)
        name = should_add
      else
        name = key_path
      end

      self.addAnimation(animation, forKey: name)
    end

    if options.key?(:to)
      self.setValue(options[:to], forKeyPath: key_path)
    end

    return animation
  end

  def keyframe_animation(key_path, options={})
    animation = CAAnimation.keyframe(key_path, options)

    should_add = options.fetch(:add, true)
    if should_add
      if should_add.is_a?(NSString)
        name = should_add
      else
        name = key_path
      end
      self.addAnimation(animation, forKey: name)
    end

    if options.key?(:values)
      self.setValue(options[:values].last, forKeyPath: key_path)
    end

    return animation
  end

end

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
sugarcube-4.0.0 lib/cocoa/sugarcube-animations/calayer.rb
sugarcube-3.5.0 lib/cocoa/sugarcube-animations/calayer.rb
sugarcube-3.4.2 lib/cocoa/sugarcube-animations/calayer.rb
sugarcube-3.4.1 lib/cocoa/sugarcube-animations/calayer.rb
sugarcube-3.4.0 lib/cocoa/sugarcube-animations/calayer.rb
sugarcube-3.3.7 lib/cocoa/sugarcube-animations/calayer.rb
sugarcube-3.3.6 lib/cocoa/sugarcube-animations/calayer.rb
sugarcube-3.3.5 lib/cocoa/sugarcube-animations/calayer.rb
sugarcube-3.3.4 lib/cocoa/sugarcube-animations/calayer.rb
sugarcube-3.3.3 lib/cocoa/sugarcube-animations/calayer.rb
sugarcube-3.3.2 lib/cocoa/sugarcube-animations/calayer.rb
sugarcube-3.3.1 lib/cocoa/sugarcube-animations/calayer.rb
sugarcube-3.3.0 lib/cocoa/sugarcube-animations/calayer.rb
sugarcube-3.2.0 lib/cocoa/sugarcube-animations/calayer.rb
sugarcube-3.1.1 lib/cocoa/sugarcube-animations/calayer.rb
sugarcube-3.1.0 lib/cocoa/sugarcube-animations/calayer.rb
sugarcube-3.0.8 lib/cocoa/sugarcube-animations/calayer.rb
sugarcube-3.0.7 lib/cocoa/sugarcube-animations/calayer.rb
sugarcube-3.0.6 lib/cocoa/sugarcube-animations/calayer.rb
sugarcube-3.0.5 lib/cocoa/sugarcube-animations/calayer.rb