fix js slider

This commit is contained in:
Marion Muszynski 2016-09-28 15:05:05 +02:00
parent da5a017c06
commit e7d82a7a30

View File

@ -45,20 +45,25 @@ $(document).ready(function(){
var frame = $('#privatesales_similarproduct .slider_sales_product_footer'); var frame = $('#privatesales_similarproduct .slider_sales_product_footer');
var list_items = frame.find('ul'); var list_items = frame.find('ul');
var nb_items = list_items.find('li').length; var nb_items = list_items.find('li').length;
if (nb_items>3) { if (nb_items>3) {
// adjust css // adjust css
frame.css({ frame.css({
'overflow': 'hidden', 'overflow': 'hidden',
'margin-left':'40px', 'margin-left':'51px',
'width':'800px' 'width':'800px',
});
list_items.css({
'padding-left':'10px',
}); });
list_items.find('li').css({ list_items.find('li').css({
'width':'267px' 'width':'252px',
'margin-left':'0px',
});
list_items.find('li').find('.similar_product').css({
'width':'auto',
}); });
// prepare parameters // prepare parameters
var animation_options = { var animation_options = {
'duration':500, 'duration':500,
@ -76,12 +81,12 @@ $(document).ready(function(){
// outWidth is supposed to include margin... However sometimes only margin width is return... // outWidth is supposed to include margin... However sometimes only margin width is return...
if (item.outerWidth(true) < item.outerWidth(false)) { if (item.outerWidth(true) < item.outerWidth(false)) {
item_width = item.outerWidth(false); item_width = item.outerWidth(false);
margin_width = item.outerWidth(true); margin_width = item.outerWidth(true);
item_width += margin_width; item_width += margin_width;
} }
else { else {
item_width = item.outerWidth(true); item_width = item.outerWidth(true);
margin_width = 0; margin_width = 0;
} }
@ -94,7 +99,7 @@ $(document).ready(function(){
frame.find('.ico_prev') frame.find('.ico_prev')
.css({ .css({
'position':'absolute', 'position':'absolute',
'left':'-10px', 'left':'0px',
'top':'100px', 'top':'100px',
'z-index':'10' 'z-index':'10'
}) })
@ -103,7 +108,7 @@ $(document).ready(function(){
}) })
.click(function(ev){ .click(function(ev){
if (state_scroll.cpt_item>0) { if (state_scroll.cpt_item>0) {
list_items.animate({'left':'+='+item_width*state_scroll.step}, animation_options); list_items.animate({'left':'+='+(10+item_width*state_scroll.step)}, animation_options);
state_scroll.cpt_item -= state_scroll.step; state_scroll.cpt_item -= state_scroll.step;
} }
}); });
@ -111,7 +116,7 @@ $(document).ready(function(){
frame.find('.ico_next') frame.find('.ico_next')
.css({ .css({
'position':'absolute', 'position':'absolute',
'right':'10px', 'right':'0px',
'top':'100px', 'top':'100px',
'z-index':'10' 'z-index':'10'
}) })
@ -119,8 +124,9 @@ $(document).ready(function(){
$(ev.target).css('cursor', 'pointer'); $(ev.target).css('cursor', 'pointer');
}) })
.click(function(ev){ .click(function(ev){
console.log(item_width*state_scroll.step);
if (state_scroll.cpt_item<(state_scroll.nb_items-state_scroll.step)) { if (state_scroll.cpt_item<(state_scroll.nb_items-state_scroll.step)) {
list_items.animate({'left':'-='+item_width*state_scroll.step}, animation_options); list_items.animate({'left':'-='+(10+item_width*state_scroll.step)}, animation_options);
state_scroll.cpt_item += state_scroll.step; state_scroll.cpt_item += state_scroll.step;
} }
}); });