Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add iOS workaround to BoxGeometry #9196

Merged
merged 5 commits into from
Jul 3, 2016
Merged

Add iOS workaround to BoxGeometry #9196

merged 5 commits into from
Jul 3, 2016

Conversation

paulmasson
Copy link
Contributor

Partial fix #9195

@mrdoob
Copy link
Owner

mrdoob commented Jun 23, 2016

Hmm, there needs to be a better solution that this hack I did in the iOS8 days...
Does this still happen in iOS10?

/cc @spite

@mrdoob
Copy link
Owner

mrdoob commented Jul 2, 2016

Found a nicer workaround! c0537d2

@paulmasson
Copy link
Contributor Author

Cool! Only problem is yours is hard-coded for the examples page. How about my updated version for the documentation pages? More flexible.

@mrdoob
Copy link
Owner

mrdoob commented Jul 3, 2016

I like it! How about a little bit more compact?

scene.style.width = getComputedStyle( scene ).width;
scene.style.height = getComputedStyle( scene ).height;
scene.setAttribute( 'scrolling', 'no' );

@paulmasson
Copy link
Contributor Author

Done. Shall I begin adding this fix to the other geometries?

@mrdoob
Copy link
Owner

mrdoob commented Jul 3, 2016

Would the code still work if it was in this form?

<iframe id="scene" src="scenes/geometry-browser.html#BoxGeometry"></iframe>

<script>
window.onload = function() {
    var scene = document.getElementById( 'scene' );
    // iOS iframe auto-resize workaround
    if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {
        scene.style.width = getComputedStyle( scene ).width;
        scene.style.height = getComputedStyle( scene ).height;
        scene.setAttribute( 'scrolling', 'no' );
    }
}
</script>

That way the patch/workaround code is independent/separate from the iframe src.

@paulmasson
Copy link
Contributor Author

Since I was using window.onload, setting the src attribute in the iframe was very inconsistent. Setting the source in the script was also inconsistent as I described in #9195.

I was previously under the impression that onload does not fire for Safari iframes, but it turns out it does. I've updated the workaround again to move the source to the iframe and add an onload function.

Better?

@mrdoob
Copy link
Owner

mrdoob commented Jul 3, 2016

Almost!

I don't think you need to wait for the onload. The style applied to the iframe doesn't depend on the iframe being loaded.

I think you should be able to have the code execute directly. Seems to work fine for the examples page.

@paulmasson
Copy link
Contributor Author

And of course you're right. Another misconception on my part.

@mrdoob
Copy link
Owner

mrdoob commented Jul 3, 2016

Sweet!

@mrdoob mrdoob merged commit febb7f8 into mrdoob:dev Jul 3, 2016
@mrdoob
Copy link
Owner

mrdoob commented Jul 3, 2016

Thanks!

@mrdoob
Copy link
Owner

mrdoob commented Jul 3, 2016

And yes, adding it to the other pages would be great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Documentation pages with iframe unreadable on iOS
2 participants