Module: UnderOs::UI::Animation
- Included in:
- View
- Defined in:
- lib/under_os/ui/utils/animation.rb
Defined Under Namespace
Classes: Animation
Instance Method Summary collapse
- #animate(style, options = {}, &block) ⇒ Object
- #fade_in(options = {}) ⇒ Object
- #fade_out(options = {}) ⇒ Object
- #highlight(color = :yellow, options = {}) ⇒ Object
Instance Method Details
#animate(style, options = {}, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/under_os/ui/utils/animation.rb', line 3 def animate(style, ={}, &block) if block_given? = style style = nil else [:complete, :curve, :autoreverse, :repeat, :duration, :delay].each do |key| [key] = style.delete(key) if style.has_key?(key) end block = Proc.new{ self.style = style } end Animation.new(self, , &block) self end |
#fade_in(options = {}) ⇒ Object
27 28 29 |
# File 'lib/under_os/ui/utils/animation.rb', line 27 def fade_in(={}) animate({opacity: 1}, ) end |
#fade_out(options = {}) ⇒ Object
31 32 33 |
# File 'lib/under_os/ui/utils/animation.rb', line 31 def fade_out(={}) animate({opacity: 0}, ) end |
#highlight(color = :yellow, options = {}) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/under_os/ui/utils/animation.rb', line 20 def highlight(color=:yellow, ={}) old_color = style.background animate({background: color}, {curve: :ease_out}.merge()) animate({background: old_color}, {curve: :ease_in}.merge()) end |