Class: Dommy::KeyframeEffect
- Inherits:
-
Object
- Object
- Dommy::KeyframeEffect
- Defined in:
- lib/dommy/animation.rb
Overview
‘KeyframeEffect` — wraps a target element + keyframes + timing. Dommy doesn’t interpolate values (no layout / render); the effect is just a record of what the animation describes.
Instance Attribute Summary collapse
-
#keyframes ⇒ Object
readonly
Returns the value of attribute keyframes.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #__js_call__(method, args) ⇒ Object
- #__js_get__(key) ⇒ Object
- #duration_ms ⇒ Object
- #get_timing ⇒ Object (also: #getTiming)
-
#initialize(target, keyframes, options = nil) ⇒ KeyframeEffect
constructor
A new instance of KeyframeEffect.
- #update_timing(timing) ⇒ Object (also: #updateTiming)
Constructor Details
#initialize(target, keyframes, options = nil) ⇒ KeyframeEffect
Returns a new instance of KeyframeEffect.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dommy/animation.rb', line 12 def initialize(target, keyframes, = nil) @target = target @keyframes = case keyframes when nil [] when Array keyframes else [keyframes] end @timing = normalize_timing() end |
Instance Attribute Details
#keyframes ⇒ Object (readonly)
Returns the value of attribute keyframes.
10 11 12 |
# File 'lib/dommy/animation.rb', line 10 def keyframes @keyframes end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
10 11 12 |
# File 'lib/dommy/animation.rb', line 10 def target @target end |
Instance Method Details
#__js_call__(method, args) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/dommy/animation.rb', line 51 def __js_call__(method, args) case method when "getTiming" get_timing when "updateTiming" update_timing(args[0] || {}) end end |
#__js_get__(key) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/dommy/animation.rb', line 44 def __js_get__(key) case key when "target" @target end end |
#duration_ms ⇒ Object
39 40 41 42 |
# File 'lib/dommy/animation.rb', line 39 def duration_ms d = @timing["duration"] d.is_a?(Numeric) ? d.to_i : 0 end |
#get_timing ⇒ Object Also known as: getTiming
26 27 28 |
# File 'lib/dommy/animation.rb', line 26 def get_timing @timing.dup end |
#update_timing(timing) ⇒ Object Also known as: updateTiming
32 33 34 35 |
# File 'lib/dommy/animation.rb', line 32 def update_timing(timing) @timing.merge!(timing.transform_keys(&:to_s)) nil end |