-
-
Notifications
You must be signed in to change notification settings - Fork 983
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
use window.innerWidth to calcualte width #373
Comments
Interesting idea. |
Welcome a PR if you have a moment to take a look and see if this works. |
Would love to and might still, simply swamped atm. Was thinking of allowing a function as instead of one of the predefined string so that this is extendable to other use cases in the future. Thoughts? |
I've thought about allowing a custom function to be written in the iFrame. This couldn't be passed from the parent, as that would be a major security problem. |
Aren't the size options on the parent? I.e. isn't it the parents job to On Mon, Jun 13, 2016, 8:26 PM David J. Bradshaw [email protected]
|
Yes, but their is an option in the iFrame to override this. Rather than pass a string, could make it an option to pass a function. If you pass a function from the parent page, you create an attack vector for dodgy code. |
Perhaps it should just be settable in the parent? On Mon, Jun 13, 2016 at 10:38 PM David J. Bradshaw [email protected]
|
I had a thought about this and just added the ability to add custom sizing methods on the dev branch. This is really untested, and hopefully I will have some more time to write some tests and an example later this week, but in the meantime you should hopefully be able to do the following in the iFrame now. <script>
window.iFrameResizer = {
widthCalcMethod: function() {
return window.innerWidth;
}
}
</script>
<script src="js/iframeresizer.contentwindow.js"></script> Oh and let me know if it really does work... |
No, Im afraid it doesn't work |
Could post the log output? |
Also tried as non global. I could send you a link, offline, if you'd like. |
Are you setting Also can you add a console.log to the custom sizing method so we're sure it's running. |
tried console.log, got nothing. Not setting that stuff. Should I be? |
Yep, otherwise it only calcs the height. |
hmm... perhaps that was my issue to begin with? |
this is what I;m using, still not resizing properly;
|
WidthCalcMethod can only be set in the iFrame. See above. |
Im a bit confused. This seemed to imply that the options needs to be set on the parent site? |
I think I get it, but - shouldnt the iframe resize based on the parent window size? Why would it do its on detection? |
It's not possible to pass a function from the parent to the iFrame via postMessge |
But why would you? Just figure out the width on the parent, and pass the width to the child? Sorry if im being dumb here, just trying to understand |
The parent window resizing triggers a message to be sent to the iFrame to ask it to work out it's new size. The iFrame then works out it's new size and sends a message back to the parent, which then update the iFrame to the new size. |
Content in the iFrame changing also triggers a size update |
I see. In that case, perhaps my approach in resolving my issue (i.e. that the iframe container has a min-width) is flawed? |
Not sure what the problem is your trying to solve is. Their is an option to set min and max sizes. |
Ive been barking up the wrong tree. Closing. Thanks for your help! |
Im on a page where a parent has a
min-width
set which causes the iframe to size incorrectly. Is there any way to calculate the width based onwindow.innerWidth
?The text was updated successfully, but these errors were encountered: