I have a issue finding the center of the screen. I have jQuery code:
arr[i].css('left')=='560px';
which will animate the html obj(arr[i]) when it’s in the center of the screen.
I have posted my sample, if you can have a look at this link: http://kashi.9f.com/Carousel/index.html
On hitting the left and right key the objects starts moving onto the respective sides. My objective is to highlight the ‘letter’ which is at center of the screen. Some times when I hit left/right key, the html obj at ‘560px’ don’t always animate. It will be either the next or the previous item other than item at ‘560px’ which gets animated.
Please can anybody help me how I can make this work so that only the center obj animates.
If you need, you can take a look at the js (script.js) and css (style.css) file which is in the same directory as that of html.
The problem is that you’re checking the element’s coordinates left position before jQuery has finished moving it. Add your function as a callback to animate.
http://api.jquery.com/animate/