Module: Situated::Viewport
Instance Method Summary collapse
-
#coordinates ⇒ Object
call-seq: viewport.position -> hash returns the coordinates of the viewport in pixesl as integers within a hash with the keys :top :left :bottom :right :height :width.
-
#position ⇒ Object
call-seq: viewport.position -> hash returns the position of the viewport, which is always => 0, :y => 0.
- #scroll ⇒ Object
- #scroll_size ⇒ Object
- #size ⇒ Object
Methods included from PositionAndSize
#height, #left, #scroll_height, #scroll_left, #scroll_top, #scroll_width, #top, #width
Instance Method Details
#coordinates ⇒ Object
call-seq:
viewport.position -> hash
returns the coordinates of the viewport in pixesl as integers within a hash with the keys :top :left :bottom :right :height :width
For example, a viewport that is 500px wide and 800px tall will return viewport.coordinates {:top => 0,
:left => 0,
:bottom => 800,
:right => 500,
:height => 800,
:width => 500 }
289 290 291 292 |
# File 'lib/source/redshift/situated.rb', line 289 def coordinates size = self.size return {:top => 0, :left => 0, :bottom => size[:y], :right => size[:x], :height => size[:y], :width => size[:x]} end |
#position ⇒ Object
call-seq:
viewport.position -> hash
returns the position of the viewport, which is always => 0, :y => 0
265 266 267 |
# File 'lib/source/redshift/situated.rb', line 265 def position return {:x => 0, :y => 0} end |
#scroll ⇒ Object
249 250 251 252 253 |
# File 'lib/source/redshift/situated.rb', line 249 def scroll win = self.window doc = Situated::Utilities.native_compat_element(self) return {:x => `#{win}.__native__.pageXOffset` || `#{doc}.__native__.scrollLeft`, :y => `#{win}.__native__pageYOffset` || `#{doc}.__native__.scrollTop`} end |
#scroll_size ⇒ Object
255 256 257 258 259 |
# File 'lib/source/redshift/situated.rb', line 255 def scroll_size doc = Situated::Utilities.native_compat_element(self) min = self.size return {:x => `Math.max(#{doc}.__native__.scrollWidth, #{min[:x]})`, :y => `Math.max(#{doc}.__native__.scrollHeight,#{ min[:y]})`} end |
#size ⇒ Object
242 243 244 245 246 247 |
# File 'lib/source/redshift/situated.rb', line 242 def size win = self.window return {:x => `#{win}.__native__.innerWidth`, :y => `#{win}.__native__.innerHeight`} if (presto? || webkit?) doc = Situated::Utilities.native_compat_element(self) return {:x => `#{doc}.__native__.clientWidth`, :y => `#{doc}.__native__.clientHeight`} end |