Skip to content

Commit

Permalink
SAK-29208 In very big resolutions roster infinite scroll does not work
Browse files Browse the repository at this point in the history
  • Loading branch information
juanjmerono committed Apr 21, 2015
1 parent 0811f21 commit 58f5694
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion roster2/src/webapp/js/roster.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,32 @@
roster.nextPage = 0;
roster.currentState = null;

/**
* Check if there is no scroll rendered and there are more pages
*/
roster.checkScroll = function () {
$(window).off('scroll.roster.rendered');
// Check if body height is lower than window height
if ($("body").height() <= $(window).height()) {
setTimeout(function () {
var renderedMembers = $(".roster-member").size();
if (roster.site.membersTotal > renderedMembers) {
$("body").data("scroll-roster", true);
$(window).on('scroll.roster.rendered', roster.checkScroll);
$(window).trigger('scroll.roster');
}
},100);
}
};

/**
* Renders a handlebars template.
*/
roster.render = function (template, data, outputId) {

var t = Handlebars.templates[template];
document.getElementById(outputId).innerHTML = t(data);
$(window).trigger('scroll.roster.rendered');
};

roster.switchState = function (state, arg, searchQuery) {
Expand Down Expand Up @@ -509,7 +528,8 @@

var wintop = $(window).scrollTop(), docheight = $(document).height(), winheight = $(window).height();

if ((wintop/(docheight-winheight)) > 0.95) {
if ((wintop/(docheight-winheight)) > 0.95 || $("body").data("scroll-roster") === true) {
$("body").data("scroll-roster", false);
$(window).off('scroll.roster');
if (showOfficialPictures) {
roster.renderMembership({ forceOfficialPicture: true, replace: false, enrollmentStatus: enrollmentStatus });
Expand Down Expand Up @@ -707,4 +727,10 @@
error: function () {
}
});

$(document).ready(function () {
// Ensure everything is rendered
setTimeout(function () { roster.checkScroll(); }, 100);
});

}) (jQuery);

0 comments on commit 58f5694

Please sign in to comment.