/* ------------------------------------------ * Filename: jquery.skyscraper.js ------------------------------------------ */ var initSkyscraper = function(isInit){ // get width - not necessary if (window.innerWidth) { theWidth=window.innerWidth; } else if (document.documentElement && document.documentElement.clientWidth) { theWidth = document.documentElement.clientWidth; } else if (document.body) { theWidth = document.body.clientWidth; } // get height - necessary if (window.innerHeight) { theHeight=window.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { theHeight = document.documentElement.clientHeight; } else if (document.body) { theHeight = document.body.clientHeight; } var marginLeft = 470; var layerLeft = document.body.clientWidth / 2 + marginLeft; if(theHeight < 500) { marginTop = 40; // 화면이 작을때 } else { // marginTop = theHeight - 400; marginTop = 337; } var currentTop = parseInt($("#skyscraper").css("top")); var animateTime = 500; if(isInit == 'true'){ currentTop = marginTop; } // $("#skyscraper").attr("style", "position:absolute; top:" + marginTop + "px; left:" + layerLeft + "px;"); $("#skyscraper").attr("style", "position:absolute; top:" + marginTop + "px;"); $(window).scroll(function(){ var position = $(window).scrollTop(); $("#skyscraper").stop().animate({"top":position + currentTop + "px"}, animateTime); }); }