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
- #by(*args) ⇒ Object
-
#into_view(align = true) ⇒ Object
Non-standard.
- #into_view!(align = true) ⇒ Object
- #position ⇒ Object
- #to(*args) ⇒ Object
Instance Attribute Details
#element ⇒ Object (readonly)
Returns the value of attribute element.
6 7 8 |
# File 'opal/browser/dom/element/scroll.rb', line 6 def element @element end |
#height ⇒ Integer (readonly)
Returns the height of the scroll.
142 143 144 |
# File 'opal/browser/dom/element/scroll.rb', line 142 def height `#@scrolling_native.scrollHeight` end |
#width ⇒ Integer (readonly)
Returns the width of the scroll.
148 149 150 |
# File 'opal/browser/dom/element/scroll.rb', line 148 def width `#@scrolling_native.scrollWidth` end |
#x ⇒ Integer (readonly)
Returns the scroll position on the x axis.
130 131 132 |
# File 'opal/browser/dom/element/scroll.rb', line 130 def x position.x end |
#y ⇒ Integer (readonly)
Returns the scroll position on the y axis.
136 137 138 |
# File 'opal/browser/dom/element/scroll.rb', line 136 def y position.y end |
Instance Method Details
#by(x, y) ⇒ Object #by(hash) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'opal/browser/dom/element/scroll.rb', line 85 def by(*args) case args.first when Hash x = args.first[:x] || 0 y = args.first[:y] || 0 else x, y = args end set_by(x, y) self end |
#into_view(align = true) ⇒ Object
Non-standard. Not supported by modern Firefox. Use #into_view!
158 159 160 |
# File 'opal/browser/dom/element/scroll.rb', line 158 def into_view(align = true) `#@scrolling_native.scrollIntoViewIfNeeded(align)` end |
#into_view!(align = true) ⇒ Object
163 164 165 |
# File 'opal/browser/dom/element/scroll.rb', line 163 def into_view!(align = true) `#@scrolling_native.scrollIntoView(align)` end |
#position ⇒ Object
115 116 117 |
# File 'opal/browser/dom/element/scroll.rb', line 115 def position Browser::Position.new(`#@scrolling_native.scrollLeft`, `#@scrolling_native.scrollTop`) end |
#to(x, y) ⇒ Object #to(hash) ⇒ Object #to(symbol) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'opal/browser/dom/element/scroll.rb', line 51 def to(*args) x, y = nil, nil case args.first when Hash x = args.first[:x] y = args.first[:y] when :top y = 0 when :bottom y = 99999999 else x, y = args end set(x, y) if x || y self end |