Module: DOM::Window

Extended by:
Events
Defined in:
opal/fron/dom/window.rb

Overview

Window

Instance Attribute Summary

Attributes included from Events

#listeners

Class Method Summary collapse

Methods included from Events

add_listener, delegate, off, old_trigger, on, on!, remove_listeners, trigger

Class Method Details

.hashString

Returns the locations hash

Returns:



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

Parameters:

  • value (String)

    The value



47
48
49
# File 'opal/fron/dom/window.rb', line 47

def self.hash=(value)
  `window.location.hash = #{value}`
end

.heightObject



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_xNumeric

Returns the X scroll position of the window

Returns:



61
62
63
# File 'opal/fron/dom/window.rb', line 61

def self.scroll_x
  `window.scrollX || document.documentElement.scrollTop`
end

.scroll_yNumeric

Returns the Y scroll position of the window

Returns:



54
55
56
# File 'opal/fron/dom/window.rb', line 54

def self.scroll_y
  `window.scrollY || document.documentElement.scrollTop`
end

.stateString

Returns the locations pathname as state

Returns:



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

Parameters:



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

.widthObject



22
23
24
# File 'opal/fron/dom/window.rb', line 22

def self.width
  `window.innerWidth`
end