Class: Browser::DOM::Element::Scroll
- Defined in:
- opal/browser/dom/element/scroll.rb
Overview
TODO:
Consider using the new interfaces which allow for optional smooth transitions.
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.
8 9 10 |
# File 'opal/browser/dom/element/scroll.rb', line 8 def element @element end |
#height ⇒ Integer (readonly)
Returns the height of the scroll.
144 145 146 |
# File 'opal/browser/dom/element/scroll.rb', line 144 def height `#@scrolling_native.scrollHeight` end |
#width ⇒ Integer (readonly)
Returns the width of the scroll.
150 151 152 |
# File 'opal/browser/dom/element/scroll.rb', line 150 def width `#@scrolling_native.scrollWidth` end |
#x ⇒ Integer (readonly)
Returns the scroll position on the x axis.
132 133 134 |
# File 'opal/browser/dom/element/scroll.rb', line 132 def x position.x end |
#y ⇒ Integer (readonly)
Returns the scroll position on the y axis.
138 139 140 |
# File 'opal/browser/dom/element/scroll.rb', line 138 def y position.y end |
Instance Method Details
#by(x, y) ⇒ Object #by(hash) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'opal/browser/dom/element/scroll.rb', line 87 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!
160 161 162 |
# File 'opal/browser/dom/element/scroll.rb', line 160 def into_view(align = true) `#@scrolling_native.scrollIntoViewIfNeeded(align)` end |
#into_view!(align = true) ⇒ Object
165 166 167 |
# File 'opal/browser/dom/element/scroll.rb', line 165 def into_view!(align = true) `#@scrolling_native.scrollIntoView(align)` end |
#position ⇒ Object
117 118 119 |
# File 'opal/browser/dom/element/scroll.rb', line 117 def position Browser::Position.new(`#@scrolling_native.scrollLeft`, `#@scrolling_native.scrollTop`) end |
#to(x, y) ⇒ Object #to(hash) ⇒ Object #to(symbol) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'opal/browser/dom/element/scroll.rb', line 53 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 |