Sha256: 315716953eb240b4accde582e35cef7c4c99e10a0655ac1da79b12c99354d1f3

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

#
# mimicking the mootools demo for Fx.Slide
# http://demos.mootools.net/Fx.Slide
#
Shoes.app do
  def stop_anim
    @anim.stop
    @anim = nil
  end

  def slide_anim(&blk)
    stop_anim if @anim
    @anim = animate 30, &blk
  end

  def slide_out(slot)
    slide_anim do |i|
      slot.height = 150 - (i * 3)
      slot.contents[0].top = -i * 3
      if slot.height.zero?
        stop_anim
        slot.hide
      end
    end
  end

  def slide_in(slot)
    slot.show
    slide_anim do |i|
      slot.height = i * 6
      slot.contents[0].top = slot.height - 150
      stop_anim if slot.height == 150
    end
  end

  background white
  stack margin: 10 do
    para link("slide out") { slide_out @lipsum }, " | ",
         link("slide in") { slide_in @lipsum }
    @lipsum = stack width: 1.0, height: 150 do
      stack do
        background "#ddd"
        border "#eee", strokewidth: 5
        para "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed " \
               "do eiusmod tempor incididunt ut labore et dolore magna " \
               "aliqua. Ut enim ad minim veniam, quis nostrud exercitation " \
               "ullamco laboris nisi ut aliquip ex ea commodo consequat. " \
               "Duis aute irure dolor in reprehenderit in voluptate velit " \
               "esse cillum dolore eu fugiat nulla pariatur. Excepteur sint " \
               "occaecat cupidatat non proident, sunt in culpa qui officia " \
               "deserunt mollit anim id est laborum.",
             margin: 10
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoes-4.0.0.rc1 samples/simple_slide.rb