Created
November 11, 2013 03:31
-
-
Save osulyanov/7407359 to your computer and use it in GitHub Desktop.
Scroll AJAX page load
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Подгрузка страниц при скроллинге | |
var thisWork = 1; | |
function getNextP() { | |
if( !$('div').is('#products') ) | |
return false; | |
if(thisWork == 1) { | |
nextPageNum = $("#products").data('page') + 1; | |
if(nextPageNum>$("#products").data('pages')) | |
return false; | |
thisWork = 0; | |
show_or_hide_products_load(true); | |
$.get('/catalog'+location.search+'&PAGEN_1='+nextPageNum, function(data){ | |
$("#products .clear").before(data); | |
$("#products").data('page', nextPageNum); | |
thisWork = 1; | |
catalog_init(); | |
show_or_hide_products_load(false); | |
}); | |
} | |
} | |
// JavaScript Document | |
$(function(){ | |
// Подгрузка страниц при скроллинге | |
var scrH = $(window).height(); | |
var scrHP = $(".wrap").height(); | |
$(window).scroll(function(){ | |
var scro = $(this).scrollTop(); | |
var scrHP = $(".wrap").height(); | |
var scrH2 = 0; | |
scrH2 = scrH + scro; | |
var leftH = scrHP - scrH2; | |
if(leftH < 900){ | |
getNextP(); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment