LTI iframe resize

503 views
Skip to first unread message

Christopher Bennell

unread,
Jun 17, 2016, 12:02:54 PM6/17/16
to Canvas LMS Users
I just noticed that Canvas will now resize an iframe's height to match the height of embedded LTI content. Awesome! 

Is there a way for the embedded tool to re-trigger this resize? I have a few tools that load more content after the page loads, and this changes the height of the document, resulting in the old double-scrollbar. I'm imagining something like .postMessage() to force Canvas to re-calculate embedded content height. 

Thanks.

Becky Kinney

unread,
Jun 17, 2016, 1:34:16 PM6/17/16
to canvas-l...@googlegroups.com
Chris,

That would be awesome. I currently use:

 parent.postMessage(JSON.stringify({subject: 'lti.frameResize', height: "1000px"}), '*'); 

Obviously this works best if you calculate the actual size of your page and then send the proper size.
If there were a way to just trigger the existing algorithm to get the height to match, I'd switch to that. 

Hope you get a definitive answer from Instructure.

Becky Kinney
Academic Technology Services

--

---
You received this message because you are subscribed to the Google Groups "Canvas LMS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to canvas-lms-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ryan Hiebert

unread,
Jun 17, 2016, 3:51:14 PM6/17/16
to canvas-l...@googlegroups.com
I have two cases in my own work, and this makes me question what I thought was the case.

My first use-case, like it seems is yours, is simply to have my content, which extends past the simple view of the launch iframe, be fit into the parent window without any scrolling, so that the main site scrolling is all there is, and there's no double-scrolling. For that use-case I also use `lti.frameResize`, and it works for me. I would also switch if there were a new message so that I no longer needed to send in the exactly size, and Canvas would just figure that out for me.

My second use-case, however, doesn't currently have a solution. I thought it did from updates on an issue on GitHub, but this conversation makes me believe that I was mistaken, and since I didn't try it out for myself, that's not all too surprising. The behavior that my second use-case requires is that the iframe be resized to fill as much of the parent window as is available _without_ causing the parent window to scroll. I need this because my application implements it's own scrolling, so I need for the Canvas launch frame to _not_ scroll. Because my iframe can't find out anything about the dimensions of the page that it's embedded into, it's not possible to use `lti.frameResize`; there's no way for me to know the right number to send.

Ryan
Reply all
Reply to author
Forward
0 new messages