Skip to content

Commit

Permalink
Fix resizing when lazy loading
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Aug 26, 2014
1 parent a1a759e commit 8a14aeb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions imp/js/imp.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,16 @@ var IMP_JS = {
{
var range_top, range_bottom,
mb = $('messageBody'),
doc = this.iframeDoc(iframe);
doc = this.iframeDoc(iframe),
resize = this.iframeResize.bindAsEventListener(this, iframe);

range_top = mb.scrollTop + mb.cumulativeOffset().top - iframe.cumulativeOffset().top;
range_bottom = range_top + mb.getHeight();

Prototype.Selector.select('IMG[data-src]', doc).each(function(img) {
var co = Element.cumulativeOffset(img);
if (co.top > range_top && co.top < range_bottom) {
src = Element.readAttribute(img, 'data-src');
img.onload = resize;
Element.writeAttribute(img, 'src', Element.readAttribute(img, 'data-src'));
Element.writeAttribute(img, 'data-src', null);
}
Expand Down

0 comments on commit 8a14aeb

Please sign in to comment.