Scrolling events inside the Facebook canvas app

I am looking to use LazyLoad technology for images and endless scrolling to upload new content to my page. Both of these features use a feature $(window).scrollTop()that does not work inside the Facebook canvas application. I know what I can use FB.Canvas.getPageInfo()to get the current scrollTop value, but I ran into some performance issues, my code looks like this:

var oldScroll = 0;       // current scroll 
var newScroll = null;    // new scroll (fetched from FB.Canvas)

// Override the normal function to work within fb
// !!This seems to kill the browser
$.fn.scrollTop = function() {
    return FB.Canvas.getPageInfo().scrollTop;  
};

// poll to check for any changes in scroll
setInterval(function() {
    newScroll = FB.Canvas.getPageInfo().scrollTop; 

    if(oldScroll != newScroll) {     // have we scrolled at all?
        oldScroll = newScroll;
        $(window).trigger($.Event('scroll'));   // fire a scroll event to keep the rest of the application that is listening
    }
}, 1000);

Everything seems to be in order, unless I redefine the scrollTop function, but as soon as I make my browser it will crash soon.

Am I completely wrong about this? Has someone already created a way to do this inside an FB canvas? Greetings.

+5
2

, (div # xscroll, pos: abs, L) Facebook + setInterval:

function wininfo() {
    FB.Canvas.getPageInfo(
        function(info) {
            $('#xscroll').height(info.clientHeight+info.offsetTop+info.scrollTop).trigger('scroll');
        }
    );
};

#xscroll LazyLoad:

$(".img").lazyload({threshold:400,effect:"fadeIn",skip_invisible:true,container:'#xscroll'});

, FB.Canvas.getPageInfo, - 2000, - . script - Safari , ...

+2

scrollTop()? , jQuery, , , facebook. - javascript scrollTop(), , ?

, - setInterval(), , , , .. , - , .

+1

All Articles