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

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, options={}, &block)
  if block_given?
    options = style
    style   = nil
  else
    [:complete, :curve, :autoreverse, :repeat, :duration, :delay].each do |key|
      options[key] = style.delete(key) if style.has_key?(key)
    end

    block   = Proc.new{ self.style = style }
  end

  Animation.new(self, options, &block)

  self
end

#fade_in(options = {}) ⇒ Object



27
28
29
# File 'lib/under_os/ui/utils/animation.rb', line 27

def fade_in(options={})
  animate({opacity: 1}, options)
end

#fade_out(options = {}) ⇒ Object



31
32
33
# File 'lib/under_os/ui/utils/animation.rb', line 31

def fade_out(options={})
  animate({opacity: 0}, options)
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, options={})
  old_color = style.background

  animate({background: color},     {curve: :ease_out}.merge(options))
  animate({background: old_color}, {curve: :ease_in}.merge(options))
end