Setting treshold when using Mika Tuupola's Viewport Selectors

Setting treshold when using Mika Tuupola's Viewport Selectors

I'm currently working in a portfolio site with horizontal navigation (http://espaun256.prompt-dev.com/moving/), and I'm using Mika Tuupola's Viewport Selectors (http://www.appelsiini.net/projects/viewport) to set the element closest to the center of the screen.

So far I have this:

  1. $('#wrap').bind('scrollstop', function(){ var inview = $('article.post:in-viewport').get().length, center = Math.round(inview/2)-1; $('article.post:in-viewport:eq('+center+')').addClass('activo'); });

Even if I'm close to get what I'm looking for, I know that there must be better and cleaner ways to do it...

... for example setting left and right screen tresholds using the same Viewport Selectors plugin ... any help figuring out how to set up tresholds would be very much appreciated.