Class: Browser::DOM::Element::Scroll
- Defined in:
- opal/browser/dom/element/scroll.rb
Instance Attribute Summary collapse
-
#element ⇒ Object
readonly
Returns the value of attribute element.
-
#height ⇒ Integer
readonly
The height of the scroll.
-
#width ⇒ Integer
readonly
The width of the scroll.
-
#x ⇒ Integer
readonly
The scroll position on the x axis.
-
#y ⇒ Integer
readonly
The scroll position on the y axis.
Instance Method Summary collapse
Instance Attribute Details
#element ⇒ Object (readonly)
Returns the value of attribute element.
4 5 6 |
# File 'opal/browser/dom/element/scroll.rb', line 4 def element @element end |
#height ⇒ Integer (readonly)
Returns the height of the scroll.
83 84 85 |
# File 'opal/browser/dom/element/scroll.rb', line 83 def height `#@native.scrollHeight` end |
#width ⇒ Integer (readonly)
Returns the width of the scroll.
89 90 91 |
# File 'opal/browser/dom/element/scroll.rb', line 89 def width `#@native.scrollWidth` end |
#x ⇒ Integer (readonly)
Returns the scroll position on the x axis.
71 72 73 |
# File 'opal/browser/dom/element/scroll.rb', line 71 def x position.x end |
#y ⇒ Integer (readonly)
Returns the scroll position on the y axis.
77 78 79 |
# File 'opal/browser/dom/element/scroll.rb', line 77 def y position.y end |
Instance Method Details
#by(x, y) ⇒ Object #by(hash) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'opal/browser/dom/element/scroll.rb', line 108 def by(*args) if Hash === args.first x = args.first[:x] || 0 y = args.first[:y] || 0 else x, y = args end `#@native.scrollBy(#{x}, #{y})` self end |
#position ⇒ Object
25 26 27 |
# File 'opal/browser/dom/element/scroll.rb', line 25 def position Browser::Position.new(`#@native.scrollLeft`, `#@native.scrollTop`) end |
#to(x, y) ⇒ Object #to(hash) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'opal/browser/dom/element/scroll.rb', line 60 def to(*args) if Hash === args.first x = args.first[:x] || self.x y = args.first[:y] || self.y else x, y = args end `#@native.scrollTop = #{y}` `#@native.scrollLeft = #{x}` end |
#to!(align = true) ⇒ Object
131 132 133 |
# File 'opal/browser/dom/element/scroll.rb', line 131 def to!(align = true) `#@native.scrollIntoView(align)` end |