Class: Plushie::Animation::Transition
- Inherits:
-
Data
- Object
- Data
- Plushie::Animation::Transition
- Defined in:
- lib/plushie/animation/transition.rb
Overview
Renderer-side timed transition descriptor.
Declares animation intent in the view. The renderer handles interpolation locally with zero wire traffic during animation.
Instance Attribute Summary collapse
-
#auto_reverse ⇒ Object
readonly
Returns the value of attribute auto_reverse.
-
#delay ⇒ Object
readonly
Returns the value of attribute delay.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#easing ⇒ Object
readonly
Returns the value of attribute easing.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#on_complete ⇒ Object
readonly
Returns the value of attribute on_complete.
-
#repeat ⇒ Object
readonly
Returns the value of attribute repeat.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Class Method Summary collapse
-
.build(duration, **opts) ⇒ Transition
Create a transition with duration as a positional argument.
-
.loop(duration, cycles: nil, reverse: true, **opts) ⇒ Transition
Create a looping transition.
Instance Method Summary collapse
-
#initialize(to:, duration: nil, easing: :ease_in_out, delay: 0, from: nil, repeat: nil, auto_reverse: false, on_complete: nil) ⇒ Transition
constructor
A new instance of Transition.
-
#to_wire ⇒ Hash
Wire-ready descriptor map.
Constructor Details
#initialize(to:, duration: nil, easing: :ease_in_out, delay: 0, from: nil, repeat: nil, auto_reverse: false, on_complete: nil) ⇒ Transition
Returns a new instance of Transition.
39 40 41 42 43 44 |
# File 'lib/plushie/animation/transition.rb', line 39 def initialize( to:, duration: nil, easing: :ease_in_out, delay: 0, from: nil, repeat: nil, auto_reverse: false, on_complete: nil ) super end |
Instance Attribute Details
#auto_reverse ⇒ Object (readonly)
Returns the value of attribute auto_reverse
27 28 29 |
# File 'lib/plushie/animation/transition.rb', line 27 def auto_reverse @auto_reverse end |
#delay ⇒ Object (readonly)
Returns the value of attribute delay
27 28 29 |
# File 'lib/plushie/animation/transition.rb', line 27 def delay @delay end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration
27 28 29 |
# File 'lib/plushie/animation/transition.rb', line 27 def duration @duration end |
#easing ⇒ Object (readonly)
Returns the value of attribute easing
27 28 29 |
# File 'lib/plushie/animation/transition.rb', line 27 def easing @easing end |
#from ⇒ Object (readonly)
Returns the value of attribute from
27 28 29 |
# File 'lib/plushie/animation/transition.rb', line 27 def from @from end |
#on_complete ⇒ Object (readonly)
Returns the value of attribute on_complete
27 28 29 |
# File 'lib/plushie/animation/transition.rb', line 27 def on_complete @on_complete end |
#repeat ⇒ Object (readonly)
Returns the value of attribute repeat
27 28 29 |
# File 'lib/plushie/animation/transition.rb', line 27 def repeat @repeat end |
#to ⇒ Object (readonly)
Returns the value of attribute to
27 28 29 |
# File 'lib/plushie/animation/transition.rb', line 27 def to @to end |
Class Method Details
.build(duration, **opts) ⇒ Transition
Create a transition with duration as a positional argument.
64 65 66 67 68 69 |
# File 'lib/plushie/animation/transition.rb', line 64 def self.build(duration, **opts) raise ArgumentError, "duration must be an Integer" unless duration.is_a?(Integer) raise ArgumentError, "transition requires a :to value" unless opts.key?(:to) new(duration: duration, **opts) end |
.loop(duration, cycles: nil, reverse: true, **opts) ⇒ Transition
Create a looping transition.
78 79 80 81 82 83 |
# File 'lib/plushie/animation/transition.rb', line 78 def self.loop(duration, cycles: nil, reverse: true, **opts) build(duration, repeat: cycles || :forever, auto_reverse: reverse, **opts) end |
Instance Method Details
#to_wire ⇒ Hash
Returns wire-ready descriptor map.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/plushie/animation/transition.rb', line 47 def to_wire h = {type: "transition", to: to} h[:duration] = duration if duration h[:easing] = easing.to_s unless easing == :ease_in_out h[:delay] = delay unless delay == 0 h[:from] = from unless from.nil? h[:repeat] = (repeat == :forever) ? -1 : repeat if repeat h[:auto_reverse] = auto_reverse if auto_reverse h[:on_complete] = on_complete.to_s if on_complete h end |