I've updated my question as I think I have a solution to my original problem. I want to convert the $margins
to a global variable that I can use to calculate my $offset
for another function. I need to update the variable after (arrow) keypresses, mouse clicks and possibly mouse wheel actions. Is there a simple solution to this?
Here is my code:
$(document).keydown(function(e){ //keyboard bind
if( e.keyCode == 39 ){//right (->)
if($('.selectstyle').hasClass("selectstyle")){
$margins = -180;
} else ($(".select" ).hasClass("select")){
$margins = 0;
}
}
});
$offset = (-220 + $margins),
The code I've put up is probably not correct for my solution. The site I'm working on is http://lastnighti.co.uk/ I want users to navigate the site primarily with the arrow keys using the serialscroll plugin. The issue I'm having is that if the user highlights an image by pressing the down arrow, and then proceeds to press the right arrow key to proceed to the next image, it is overshot due to serialscroll taking the margins width in to account.
This has been causing me grief for over a week. I have tried queuing and setTimout
functions, but they disrupt the fluidity of the UI. Basically my problem above is to change the $offset
variable to account for when and image is highlighted with the .selectstyle
class. I'd appreciate any solution to the above problem to dynamically control the $offset
.