Sha256: 5f10a47af688580341b2e5156e119598f59826ae9711ac933e9b73267fa24f31

Contents?: true

Size: 681 Bytes

Versions: 1

Compression:

Stored size: 681 Bytes

Contents

module Browser; module DOM; class Element < Node

class Scroll
  def initialize(element)
    @element = element
    @native  = element.to_n
  end

  def position
    Browser::Position.new(`#@native.scrollLeft`, `#@native.scrollTop`)
  end

  def x
    position.x
  end

  def y
    position.y
  end

  def to(what)
    x   = what[:x] || self.x
    y   = what[:y] || self.y

    `#@native.scrollTop = #{y}`
    `#@native.scrollLeft = #{x}`

    self
  end

  def height
    `#@native.scrollHeight`
  end

  def width
    `#@native.scrollWidth`
  end

  def by(what)
    x = what[:x] || 0
    y = what[:y] || 0

    `#@native.scrollBy(#{x}, #{y})`

    self
  end
end

end; end; end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-browser-0.1.0.beta1 opal/browser/dom/element/scroll.rb