1/** 2 * Creating a slider 3 * 4 **/ 5var $ = jQuery.noConflict(); 6$(function(){ 7 var pos = 0; 8 var prev = 0; 9 var next = 0; 10 var hidden = 0; 11 $('.slide-prev').on('click', function(){ 12 // console.log($(this).parent().find('.slide')); 13 slide($(this).parent().find('.slides'), 0); 14 }); 15 16 $('.slide-next').on('click', function(){ 17 // console.log($(this).parent().find('.slide')); 18 slide($(this).parent().find('.slides'), 1); 19 }); 20 21 var getClilds = function(parent){ 22 // console.log(parent.children()); 23 // console.log(parent.children().length); 24 return parent.children().length; 25 } 26 27 var slide = function (parent, step){ 28 var totalItms = getClilds(parent); 29 var parentWidth = parent.parent().outerWidth(); 30 var sliderWidth = parent.width(); 31 var itemWidth = parseInt(parent.children().first().width()); 32 itemWidth = itemWidth + parseInt(parent.children().first().css('margin-left')) + parseInt(parent.children().first().css('margin-right')) + parseInt(parent.children().first().css('padding-left')) + parseInt(parent.children().first().css('padding-right')); 33 pos = parseInt(parent.css('left')); 34 35 if(pos == 0 || isNaN(pos)){ 36 prev = 0 ; 37 }else{ 38 prev = Math.abs(Math.round(pos / itemWidth)); 39 } 40 var showing = Math.round(parentWidth / itemWidth); 41 hidden = (totalItms - showing); 42 43console.log(itemWidth); 44console.log(prev); 45 // if(sliderWidth > ((pos*-1) + (itemWidth*showing)) && pos <= 0){ 46 if(prev <= hidden-1 && step == 1){ 47 ++prev; 48 // pos = pos - itemWid 49 }else if(prev > 0 && 0===step){ 50 --prev; 51 // pos = pos + itemWidth; 52 } 53 pos = prev * itemWidth; 54 pos = pos * -1; 55console.log(pos); 56 parent.css('left', pos+'px'); 57 } 58});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.