jquery - Trying to make image carousel responsive -
im beginner js. have image carousel worked fine. when tried make responsive, won't scroll anymore , responsive thing doesnt work either.
heres js code:
$(document).ready(function() { var viewport = $( window ).width(); if ( viewport > 1024 ) { $(".imagecarouselwrap").css("width","904"); $(".carouselinner").css("width","834"); } else if ( 769 <= viewport >= 1023 ) { $(".imagecarouselwrap").css("width","765"); $(".carouselinner").css("width","695"); } else if ( 481 <= viewport >= 768 ) { $(".imagecarouselwrap").css("width","348"); $(".carouselinner").css("width","278"); } else ( 320 <= viewport >= 480 ) { $(".imagecarouselwrap").css("width","209"); $(".carouselinner").css("width","139"); } $("#inner_ul li:first").before($("#inner_ul li:last")); $("#rightarrow img").click(function(){ var elemlaius = $("#inner_ul li").outerwidth(); var vasaktaane = parseint($("#inner_ul").css("left")) - elemlaius; $("#inner_ul:not(:animated)").animate({"left" : vasaktaane},500,function(){ $("#inner_ul li:last").after($("#inner_ul li:first")); $("#inner_ul").css({"left" : "-139px"}); }); }); $("#leftarrow img").click(function(){ var elemlaius = $("#inner_ul li").outerwidth(); var vasaktaane = parseint($("#inner_ul").css("left")) + elemlaius; $("#inner_ul:not(:animated)").animate({"left" : vasaktaane},500,function(){ $("#inner_ul li:first").before($("#inner_ul li:last")); $("#inner_ul").css({"left" : "-139px"}); }); }); });
please me.
my added part:
var viewport = $( window ).width(); if ( viewport > 1024 ) { $(".imagecarouselwrap").css("width","904"); $(".carouselinner").css("width","834"); } else if ( 769 <= viewport >= 1023 ) { $(".imagecarouselwrap").css("width","765"); $(".carouselinner").css("width","695"); } else if ( 481 <= viewport >= 768 ) { $(".imagecarouselwrap").css("width","348"); $(".carouselinner").css("width","278"); } else ( 320 <= viewport >= 480 ) { $(".imagecarouselwrap").css("width","209"); $(".carouselinner").css("width","139"); }
it change element width settings if watch smaller window, wont job. use http://quirktools.com/screenfly watch smaller windows
this part should else if, not else
else ( 320 <= viewport >= 480 ) { $(".imagecarouselwrap").css("width","209"); $(".carouselinner").css("width","139"); }
else if ( 320 <= viewport >= 480 ) { $(".imagecarouselwrap").css("width","209"); $(".carouselinner").css("width","139"); }
Comments
Post a Comment