Module: DOM::Window
- Extended by:
- Events
- Defined in:
- opal/fron/dom/window.rb
Overview
Window
Instance Attribute Summary
Attributes included from Events
Class Method Summary collapse
-
.hash ⇒ String
Returns the locations hash.
-
.hash=(value) ⇒ Object
Sets the locations hash with the given value.
- .height ⇒ Object
- .replace_state(url) ⇒ Object
-
.scroll_x ⇒ Numeric
Returns the X scroll position of the window.
-
.scroll_y ⇒ Numeric
Returns the Y scroll position of the window.
-
.state ⇒ String
Returns the locations pathname as state.
-
.state=(url) ⇒ Object
Sets the url via pushState.
- .width ⇒ Object
Methods included from Events
add_listener, delegate, off, old_trigger, on, on!, remove_listeners, trigger
Class Method Details
.hash ⇒ String
Returns the locations hash
40 41 42 |
# File 'opal/fron/dom/window.rb', line 40 def self.hash `window.location.hash.slice(1)` end |
.hash=(value) ⇒ Object
Sets the locations hash with the given value
47 48 49 |
# File 'opal/fron/dom/window.rb', line 47 def self.hash=(value) `window.location.hash = #{value}` end |
.height ⇒ Object
26 27 28 |
# File 'opal/fron/dom/window.rb', line 26 def self.height `window.innerHeight` end |
.replace_state(url) ⇒ Object
16 17 18 19 20 |
# File 'opal/fron/dom/window.rb', line 16 def self.replace_state(url) return if url == state `window.history.replaceState({},'',#{url})` timeout { trigger 'popstate' } end |
.scroll_x ⇒ Numeric
Returns the X scroll position of the window
61 62 63 |
# File 'opal/fron/dom/window.rb', line 61 def self.scroll_x `window.scrollX || document.documentElement.scrollTop` end |
.scroll_y ⇒ Numeric
Returns the Y scroll position of the window
54 55 56 |
# File 'opal/fron/dom/window.rb', line 54 def self.scroll_y `window.scrollY || document.documentElement.scrollTop` end |
.state ⇒ String
Returns the locations pathname as state
33 34 35 |
# File 'opal/fron/dom/window.rb', line 33 def self.state `window.location.pathname` end |
.state=(url) ⇒ Object
Sets the url via pushState
10 11 12 13 14 |
# File 'opal/fron/dom/window.rb', line 10 def self.state=(url) return if url == state `window.history.pushState({},'',#{url})` timeout { trigger 'popstate' } end |
.width ⇒ Object
22 23 24 |
# File 'opal/fron/dom/window.rb', line 22 def self.width `window.innerWidth` end |