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 iframeHeight and iframeWidth properties to pageInfo #314

Merged
merged 2 commits into from
Feb 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ Returns the ID of the iFrame that the page is contained in.

Ask the containing page for its positioning coordinates. You need to provide a callback which receives an object with the following properties:

* **iframeHeight** The height of the iframe in pixels
* **iframeWidth** The width of the iframe in pixels
* **clientHeight** The height of the viewport in pixels
* **clientWidth** The width of the viewport in pixels
* **offsetLeft** The number of pixels between the left edge of the containing page and the left edge of the iframe
Expand Down
4 changes: 2 additions & 2 deletions js/iframeResizer.contentWindow.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions js/iframeResizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@
iFramePosition = messageData.iframe.getBoundingClientRect();

return JSON.stringify({
iframeHeight: iFramePosition.height,
iframeWidth: iFramePosition.width,
clientHeight: Math.max(document.documentElement.clientHeight, window.innerHeight || 0),
clientWidth: Math.max(document.documentElement.clientWidth, window.innerWidth || 0),
offsetTop: parseInt(iFramePosition.top - bodyPosition.top, 10),
Expand Down
2 changes: 1 addition & 1 deletion js/iframeResizer.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions js/iframeResizer.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion spec/childSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ define(['iframeResizerContent','jquery'], function(mockMsgListener,$) {

it('getPageInfo', function(done) {
win.parentIFrame.getPageInfo(function(pageInfo){
expect(pageInfo.iframeHeight).toBe(500);
expect(pageInfo.iframeWidth).toBe(300);
expect(pageInfo.clientHeight).toBe(645);
expect(pageInfo.clientWidth).toBe(1295);
expect(pageInfo.offsetLeft).toBe(20);
Expand All @@ -104,7 +106,7 @@ define(['iframeResizerContent','jquery'], function(mockMsgListener,$) {
done();
});
expect(msgObject.source.postMessage).toHaveBeenCalledWith('[iFrameSizer]parentIFrameTests:0:0:pageInfo', '*');
mockMsgListener(createMsg('pageInfo:{"clientHeight":645,"clientWidth":1295,"offsetLeft":20,"offsetTop":85,"scrollLeft":0,"scrollTop":0}'));
mockMsgListener(createMsg('pageInfo:{"iframeHeight":500,"iframeWidth":300,"clientHeight":645,"clientWidth":1295,"offsetLeft":20,"offsetTop":85,"scrollLeft":0,"scrollTop":0}'));
});

it('getPageInfoStop', function() {
Expand Down
2 changes: 2 additions & 0 deletions src/iframeResizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@
iFramePosition = messageData.iframe.getBoundingClientRect();

return JSON.stringify({
iframeHeight: iFramePosition.height,
iframeWidth: iFramePosition.width,
clientHeight: Math.max(document.documentElement.clientHeight, window.innerHeight || 0),
clientWidth: Math.max(document.documentElement.clientWidth, window.innerWidth || 0),
offsetTop: parseInt(iFramePosition.top - bodyPosition.top, 10),
Expand Down