Class: Dommy::DOMRect
- Inherits:
-
Object
- Object
- Dommy::DOMRect
- Defined in:
- lib/dommy/element.rb
Overview
Stub ‘DOMRect` for `getBoundingClientRect` — no layout engine, so all values are 0. Consumer code that uses these for relative positioning sees zeroed values; absolute layout assertions need the real browser.
Instance Method Summary collapse
- #__js_get__(key) ⇒ Object
-
#initialize(x: 0, y: 0, width: 0, height: 0) ⇒ DOMRect
constructor
A new instance of DOMRect.
- #js_null? ⇒ Boolean
Constructor Details
#initialize(x: 0, y: 0, width: 0, height: 0) ⇒ DOMRect
Returns a new instance of DOMRect.
494 495 496 497 498 499 |
# File 'lib/dommy/element.rb', line 494 def initialize(x: 0, y: 0, width: 0, height: 0) @x = x @y = y @width = width @height = height end |
Instance Method Details
#__js_get__(key) ⇒ Object
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 |
# File 'lib/dommy/element.rb', line 501 def __js_get__(key) case key when "x", "left" @x when "y", "top" @y when "width" @width when "height" @height when "right" @x + @width when "bottom" @y + @height end end |
#js_null? ⇒ Boolean
518 519 520 |
# File 'lib/dommy/element.rb', line 518 def js_null? false end |