The following is working fine, however is it possible to access the variable 'scrolled' value inside 'onEnter'?
$(document).ready(function () {
var $window = $(window);
function update() {
var scrolled = $window.scrollTop();
return scrolled;
};
$('.color').each(function (i, scrolled) {
var position = $(this).position();
$(this).scrollspy({
min: position.top,
max: position.top + $(this).height(),
onEnter: function (element, position, scrolled) {
var scrolled = $window.scrollTop();
$window.bind('scroll', update);
console.log(scrolled);
if (element.id === 'one' || element.id === 'two') {
$('.slidingPannel').animate({
'background-position-x': '100%'
}, 100);
} else {
$('.slidingPannel').animate({
'background-position-x': '125%'
}, 100);
}
},
onLeave: function (element, position) {
if (console) console.log('leaving ' + element.id);
}
});
});
});