Reputation: 3958
I'm working on the following code, and a bit stumped why I'm getting an error in my debugger. apparently in the line that starts with var skillsLimit = ...
the class .top
of var skillsOffset
is undefined. Am I setting the var for skillsOffset
incorrectly here?
// Set Pie graph to position fixed during a specified range
var $window = $(window);
var windowHeight = $(window).height();
var pos = $window.scrollTop(); //position of the scrollbar
var $this = $(this);
$window.bind('scroll', function(){ //when the user is scrolling...
var pos = $window.scrollTop(); //position of the scrollbar
var skillsOffset = $('#skills').offset();
var skillsLimit = $('#skills').skillsOffset.top + $('#skills').outerHeight();
if ( pos > skillsOffset ) {
$('.chartwell-pies').css({ 'position' : 'fixed' });
}
});
Upvotes: 1
Views: 11040
Reputation: 28867
Remove the $('#skills')
from the assignment to skillsLimit
, you've already got the object in the line above:
var pos = $window.scrollTop(); //position of the scrollbar
var skillsOffset = $('#skills').offset();
var skillsLimit = skillsOffset.top + $('#skills').outerHeight();
Upvotes: 3