odd
odd

Reputation: 449

Passing a var from one function into another

Hi please could someone point me into the right direction, i need to pass height into my window scroll function

$(window).scroll(function() {       
    var scrolled = $(window).scrollTop();

    //Content
    if(scrolled >= 0 && scrolled < 342) {
             $('#intro h2, #intro .down').stop().animate({ opacity: 1 }, {queue: true, duration:250, easing:"easeOutQuad"});
        } else if (scrolled >= 342 && scrolled < 560) {
             $('#intro h2, #intro .down').stop().animate({ opacity: 0 }, {queue: true, duration:250, easing:"easeOutQuad"});
        } else if (scrolled >= 560) {
             $('#intro h2, #intro .down').stop().css({ opacity: 0 });
        }




        //Navigation
        if(scrolled >= 0 && scrolled < 342) {
             $('#header h1 a:link').stop().css({ width: 101 });
             $('#header li .service').stop().css({ background: 'none', color: '#ccc'}, {queue: true, duration:50, easing:"easeOutQuad"});
        } else if (scrolled >= 342 && scrolled < 560) {
             $('#header h1 a:link').stop().css({ width: 42 });
             $('#header li .service').stop().css({background: '#54C2D9', color: '#fff'}, {queue: true, duration:50, easing:"easeOutQuad"});
        } else if (scrolled >= 560) {
             $('#header h1 a:link ').stop().css({ width: 42 });
        }



console.log(scrolled);  
});

function jqUpdateSize(){
    // Get the dimensions of the viewport
    var height = $(window).height();

    $('#intro').css({height: height});

    console.log(height);// Display the height
};
$(document).ready(jqUpdateSize);    // When the page first loads
$(window).resize(jqUpdateSize);     // When the browser changes size

Upvotes: 0

Views: 67

Answers (2)

Starkers
Starkers

Reputation: 10541

You need to return height at the end of function jqUpdateSize

Upvotes: 1

EnterJQ
EnterJQ

Reputation: 1014

Make your variable global then you can use ,something like below

window.height = "This is global!";

Upvotes: 2

Related Questions