Question

Since I started this new webshop for a friend to launch, which still in progress, I'm using the so called "jQuery fixedScroll"..

Project online: http://www.merkversterkers.com/klanten/fragma/index.php?p=shop

Everything is fine until this.. When I'm using the scrollplugin, it defines the height of the page, which a good thing..

After pressing the "filter" button the height must be predefined causing a div that will expand, and I'm unable to do that, because the document defines the height when it's loaded..

like the "$(document).ready" function

scrollfunction

$('#scart').scrollToFixed({
   marginTop: $('.topbar').outerHeight() + 30,
   limit: get_limit(),
   zIndex: 999
});

get_limit functon

function get_limit(){
    var products_row = 4;

    var topbar = $(".topbar").height() + 30 
    var filterbar = $(".filterbar").height();
    var products = products_row * 206;

    if( $(".filterexpanded").css('display') == "block" ){
        var expanded = $(".filterexpanded").height(); 
    } else {
        var expanded = 0;
    }   

    var cartheight = $("#scart").height();

    var limit = topbar + filterbar + expanded + products + 130 - cartheight;

    return limit;
}

Can someone give me throw of some code I could try? I would really appreciate all the help..

Was it helpful?

Solution

Without reading the question you should change this:

limit: get_limit(),

To this:

limit: get_limit,

OTHER TIPS

When you are trying to set a function as a value in an object you should not use the parentheses. When you do, you are basically evaluating the function and it's value will be returned instead of the actual function.

var myObject = {
    myFunction: funkyFunk()
};

function funkyFunc(){
    var funkierFunction(){
        // You COULD do this
    };
    return funkierFunction;
}

But this is what you need...

var myObject = {
    myFunction: funkyFunk
};

function funkyFunc(){
    // You probably want this though    
}

An (untested) idea after looking at the plugin's source:

var scrollToFixedObj = $('#scart').data("ScrollToFixed");
scrollToFixedObj.options.marginTop = get_limit();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top