Module: AnimateIt::Easing
- Defined in:
- lib/animate_it/easing.rb
Class Method Summary collapse
- .ease_in(progress) ⇒ Object
- .ease_in_out(progress) ⇒ Object
- .ease_out(progress) ⇒ Object
- .linear(progress) ⇒ Object
- .resolve(easing) ⇒ Object
Class Method Details
.ease_in(progress) ⇒ Object
26 27 28 |
# File 'lib/animate_it/easing.rb', line 26 def ease_in(progress) progress * progress end |
.ease_in_out(progress) ⇒ Object
34 35 36 37 38 |
# File 'lib/animate_it/easing.rb', line 34 def ease_in_out(progress) return 2 * progress * progress if progress < 0.5 1 - ((((-2 * progress) + 2)**2) / 2.0) end |
.ease_out(progress) ⇒ Object
30 31 32 |
# File 'lib/animate_it/easing.rb', line 30 def ease_out(progress) 1 - ((1 - progress) * (1 - progress)) end |
.linear(progress) ⇒ Object
22 23 24 |
# File 'lib/animate_it/easing.rb', line 22 def linear(progress) progress end |
.resolve(easing) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/animate_it/easing.rb', line 5 def resolve(easing) return easing if easing.respond_to?(:call) case easing when nil, :linear method(:linear) when :ease_in method(:ease_in) when :ease_out method(:ease_out) when :ease_in_out method(:ease_in_out) else raise ArgumentError, "Unknown easing: #{easing.inspect}" end end |