Skip to content

Commit

Permalink
Added deltaHeight back in... as it was the simplest solution to the p…
Browse files Browse the repository at this point in the history
…roblem

- Tried https://github.com/house9/jquery-iframe-auto-height but it only works onload and there is no api to allow for refiring a resize event
- Tried using `document.scrollHeight` but it was too flaky in returning correct values and could cause the iframe to resize by 1px every timer tick
  • Loading branch information
johnmartin committed Oct 3, 2012
1 parent dc46a41 commit 3a3fc1f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ckan/public/base/javascript/modules/data-viewer.js
Expand Up @@ -4,7 +4,8 @@ this.ckan.module('data-viewer', function (jQuery) {
return {
options: {
timeout: 200,
minHeight: 400
minHeight: 400,
padding: 30
},

initialize: function () {
Expand All @@ -28,10 +29,12 @@ this.ckan.module('data-viewer', function (jQuery) {
},

_recalibrate: function() {
// save reference to this to use in timeout
var height = this.el.contents().find('body').outerHeight();
var height = this.el.contents().find('body').outerHeight(true);
height = Math.max(height, this.options.minHeight);
this.el.css('height', height);
var deltaHeight = height - (this.el.height() - this.options.padding);
if (deltaHeight > 1 || deltaHeight < -10) {
this.el.css('height', height + this.options.padding);
}
},

// firefox caches iframes so force it to get fresh content
Expand Down

0 comments on commit 3a3fc1f

Please sign in to comment.