Class: Zui::Animation
- Inherits:
-
Object
- Object
- Zui::Animation
- Defined in:
- lib/zui/animation.rb
Constant Summary collapse
- EASINGS =
%w[linear in_quad out_quad in_out_quad in_cubic out_cubic in_out_cubic in_back out_back in_out_back in_elastic out_elastic in_out_elastic in_bounce out_bounce in_out_bounce].freeze
Instance Attribute Summary collapse
-
#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.
Instance Method Summary collapse
-
#initialize(duration: 200, easing: :in_out_quad, delay: 0) ⇒ Animation
constructor
A new instance of Animation.
- #to_h ⇒ Object
Constructor Details
#initialize(duration: 200, easing: :in_out_quad, delay: 0) ⇒ Animation
Returns a new instance of Animation.
11 12 13 14 15 16 17 18 |
# File 'lib/zui/animation.rb', line 11 def initialize(duration: 200, easing: :in_out_quad, delay: 0) @duration = Integer(duration) @delay = Integer(delay) @easing = easing.to_s raise ArgumentError, "animation duration must be between 0 and 60 seconds" unless (0..60_000).cover?(@duration) raise ArgumentError, "animation delay must be between 0 and 60 seconds" unless (0..60_000).cover?(@delay) raise ArgumentError, "unsupported easing: #{@easing}" unless EASINGS.include?(@easing) end |
Instance Attribute Details
#delay ⇒ Object (readonly)
Returns the value of attribute delay.
9 10 11 |
# File 'lib/zui/animation.rb', line 9 def delay @delay end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
9 10 11 |
# File 'lib/zui/animation.rb', line 9 def duration @duration end |
#easing ⇒ Object (readonly)
Returns the value of attribute easing.
9 10 11 |
# File 'lib/zui/animation.rb', line 9 def easing @easing end |
Instance Method Details
#to_h ⇒ Object
20 21 22 |
# File 'lib/zui/animation.rb', line 20 def to_h { "duration" => duration, "easing" => easing, "delay" => delay } end |