Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // more stuff
- /*
- where:
- 'self.elements' is the li selector
- 'items_in_screen' is the total elements in the screen
- see the comment to watch the result GIF
- */
- var self = this;
- var l = self.elements.length
- // self.sel
- if(l>items_in_screen)
- {
- var start = self.sel - 2;
- var end = self.sel + 2;
- while(start<0)
- {
- start++;
- end++;
- }
- while(end>l)
- {
- start--;
- end--;
- }
- for(var i=0; i<l; i++)
- {
- if(i>=start && i<=end)
- self.elements[i].style.display = '';
- else
- self.elements[i].style.display = 'none';
- }
- }
- }
- // more stuff
Add Comment
Please, Sign In to add comment