$(document).ready(function() { autoposition(); swiper(); }); $(window).resize(function() { autoposition(); }); $(window).scroll(function(){ var scrolltop = document.documentelement.scrolltop || window.pageyoffset || document.body.scrolltop; if(scrolltop>1000){ $(".slidetotop").css("display","block"); }else{ $(".slidetotop").css("display","none"); } }) function autoposition(){ var marginleftpra = (1920-document.body.clientwidth)/2; $(".maincontent").css("margin-left",-marginleftpra); var scrolltopmarginright; if(document.body.clientwidth>1220){ scrolltopmarginright = (document.body.clientwidth-1220)/2; }else{ document.body.clientwidth = (document.body.clientwidth-1000)/2; } $(".slidetotop").css("right",scrolltopmarginright); } function swiper(){ var myswiper2 = new swiper ('.pohtowall .swiper-container', { direction: 'horizontal', loop: true, initialslide :0, /*autoplay:500,*/ }) $('.pohtowall .swiper-button-prev').click(function(){ myswiper2.swipeprev(); }) $('.pohtowall .swiper-button-next').click(function(){ myswiper2.swipenext(); }) } $(document).on("click", ".pohtowall .swiper-container .photo", function() { var imgsrc = $(this).find("img").attr("src"); debugger; $(".showphoto").find("img").attr("src",imgsrc); $(".showphoto").find("img").addclass('animated bounceinleft'); $(".showphoto").find("img").one('webkitanimationend mozanimationend msanimationend oanimationend animationend',function(){ $(".showphoto").find("img").removeclass(); }); }); $(document).on("click", ".slidetotop", function() { $('html,body').animate({scrolltop: '0px'}, 400); });