Let me first say I am a complete newb at jQuery, I am having a hard time fixing my current problem. I'm currently working on a project that uses the jQuery ScrollTo plugin. And I am trying to change the axis of the scrollTo function based on my current position on the webpage.
$(document).ready(function() {
var $current_position = thuis;
var $axis = 'xy';
$('.box').stop().scrollTo(thuis, 0);
$(window).resize(function() {
$('.box').stop().scrollTo($current_position, 0);
});
// Scroll function
$('.toc a').click(function() {
var $target = $(this.hash);
if($current_position == bezoekers_info || liniepad_info){
$axis = 'xy';
alert("xy");
} else {
$axis = 'yx';
alert("yx");
}
$('.box').stop().scrollTo($target, 1000, { queue:true, axis: $axis }, {easing: "easeInOutQuart"});
$current_position = $target;
return false;
});
});
The function basically works, but it will not change the axis value (it will stay at 'xy'). Whatever my position is, it will always alert me with "xy". Yet I know $current_position should work, because it does work in the window.resize function. If I change the $axis var at the top to 'yx' it will also work.
What am I missing here, obviously I am doing something wrong with my if / else statement?
$current_position == bezoekers_info || $current_position == liniepad_infootherwise it will always be true ifliniepad_infois set.