0

I have got a pretty standard slider component which slider UL.

I want to add active classes to only visible elements in viewport. I tried googling but all in vail. Is anyone able to shed some light on this please?

enter image description here

Following is the sliding code:

// get all lists that slider was initialised on
$lists = $(this.container).find('> ul');

// get current left position of list
currentPos = $lists.position().left;

// new left position of list is width of a page times target page number
newLeftPos = currentPos - (530 * (newPageNum-1));
RuntimeException
  • 1,095
  • 2
  • 11
  • 24

1 Answers1

1
if($("li").is(":visible")){
    $(this).addClass('active');
}
Sbml
  • 1,827
  • 1
  • 14
  • 25