Rich-Harris / ramjet

Morph DOM elements from one state to another with smooth animations and transitions

Home Page:http://www.rich-harris.co.uk/ramjet/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Transform fails on "Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'."

jbnicolai opened this issue · comments

Using ramjet with the target node having a fixed, rather than inherited, offset I get the following error.

Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.
    wrapNode @ ramjet.js:89
    ramjet.transform @ ramjet.js:399

The offending line being #88.

Since the target node in my case is absolutely positioned to fill the entire screen I can simply fix it for myself using: var offsetParent = node.offsetParent || document.body;, but this is obviously not a good general solution.

Ah, thanks, didn't think of the position: fixed case. The offset parent is only needed so ramjet can account for its top/left margin (which upsets the coordinates otherwise) - if the position is fixed then that's irrelevant anyway, so we presumably need to behave as if there was no margin.

Leaving some breadcrumbs for myself: according to this SO answer an element has no offsetParent if it's not a descendant of <body>, has position: fixed, or it or any ancestor has display: none.

commented

👍

This should be fixed in this PR #38

👍 I am running into this with position: fixed. @sithmel's PR #38 works great!

it is on master now