IE8 and Position.clone (prototype 1.4) and Element.clonePosition (prototype 1.6)

217 views
Skip to first unread message

ced

unread,
Mar 24, 2009, 11:08:32 AM3/24/09
to Prototype & script.aculo.us
I had a problem cloning position with prototype 1.4 and 1.6 in ie8
don't know exactly why it behaves like this.. but that's my solution:
hope it could be useful:

In 1.4 I changed this

if (Element.getStyle(target,'position') == 'absolute') {
parent = Position.offsetParent(target);
delta = Position.page(parent);
}

with this:

if (Element.getStyle(target,'position') == 'absolute') {
parent = Position.offsetParent(target);
delta = (navigator.appVersion.indexOf('MSIE 8')>0)?Position.page
(source):Position.page(parent);
}

if (navigator.appVersion.indexOf('MSIE 8')>0){
delta[0]-=source.offsetLeft;
delta[1]-=source.offsetTop;
}


the solution is identical for 1.6 but instead of Position.page(parent)
I used page.viewportOffset() as it was

Rod

unread,
Mar 24, 2009, 5:26:31 PM3/24/09
to Prototype & script.aculo.us

Is your target element visible? I hit this same problem with IE8 in
our app for elements that were created with display:none;, IE8 seems
to think they don't have the right offsetParent. To fix, I simply made
them visible before calling clonePosition and the parent delta was
included correctly in the positioning.

Have been meaning to put something in Lighthouse about this when I
have time, I couldn't see anything that already addresses this
problem. I'm not sure what the cleanest solution is because if the
element is visible then it appears to behaves correctly.

-- Rod

ced

unread,
Mar 25, 2009, 4:34:45 AM3/25/09
to Prototype & script.aculo.us
yes, target is hidden:
I'm using Autocompleter.selectbox (a scriptaculus plugin)
http://www.glanzani.com.ar/select/
I had to change Autocompleter behaviur to solve this issue, but I
preferred to solve the problem where it happens (as it's wrong how it
is calculated in ie8 the delta, not the fact that the target is
hidden)

could you test that if target isn't hidden my solution fails?
If it's so I think it would be needed to change the if inserting
target display hidden as a condition

ced

Rod

unread,
Mar 25, 2009, 8:50:16 PM3/25/09
to Prototype & script.aculo.us

See
https://prototype.lighthouseapp.com/projects/8886-prototype/tickets/618-getoffsetparent-returns-body-for-new-hidden-elements-in-ie8-final

I've posted an HTML example there that shows the difference between
shown and hidden elements.

I'm not sure what the real solution is to this.

-- Rod


On Mar 25, 7:34 pm, ced <catcal...@gmail.com> wrote:
> yes, target is hidden:
> I'm using Autocompleter.selectbox (a scriptaculus plugin)http://www.glanzani.com.ar/select/
Reply all
Reply to author
Forward
0 new messages