Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[bug 842882] Fix lazyloading on mobile wiki

  • Loading branch information...
commit e8abc3ad6ff72fda4855e4ef53a54bb45e201ab9 1 parent 7bf4ac9
R&D rehandalal authored
Showing with 8 additions and 6 deletions.
  1. +7 −5 media/js/libs/jquery.lazyload.js
  2. +1 −1  media/js/mobile/wiki.js
12 media/js/libs/jquery.lazyload.js
View
@@ -10,16 +10,17 @@
var opts = $.extend($.fn.lazyload.defaults, options);
var elements = this;
var didScroll = false;
+ var boundElem = opts['bindTo']
loaded = elements.length;
- $(window).bind('scroll', function(e){
+ $(boundElem).bind('scroll', function(e){
didScroll = true;
});
loadAboveTheFoldImages(elements, opts, null);
// Safari doesn't load images until scroll, sometimes
- $(window).trigger('scroll');
+ $(boundElem).trigger('scroll');
var prevHash = window.location.hash;
@@ -28,7 +29,7 @@
var intv = setInterval(function() {
if(loaded <= 0) {
- $(window).unbind('scroll');
+ $(boundElem).unbind('scroll');
clearInterval(intv);
return;
}
@@ -49,7 +50,7 @@
return this;
};
- $.fn.lazyload.defaults = {threshold: 750};
+ $.fn.lazyload.defaults = {threshold: 750, bindTo: window};
function resetHashPosition() {
if(window.location.hash) {
@@ -59,7 +60,8 @@
}
function aboveTheFold(element, options){
- var fold = $(window).height() + $(window).scrollTop();
+ var boundElem = options['bindTo'];
+ var fold = $(boundElem).height() + $(boundElem).scrollTop();
return fold >= $(element).offset().top - (options['threshold']);
};
2  media/js/mobile/wiki.js
View
@@ -84,5 +84,5 @@
});
}
- $('img.lazy').lazyload();
+ $('img.lazy').lazyload({bindTo: $('#page > .scrollable')});
})(jQuery);
Please sign in to comment.
Something went wrong with that request. Please try again.