Skip to content

Instantly share code, notes, and snippets.

@stefanledin
Created February 3, 2012 07:08
Show Gist options
  • Select an option

  • Save stefanledin/1728636 to your computer and use it in GitHub Desktop.

Select an option

Save stefanledin/1728636 to your computer and use it in GitHub Desktop.
sl_siteSlider
<!DOCTYPE html>
<html lang="sv">
<head>
<meta charset="utf-8">
<title>SiteSlider™</title>
<style type="text/css">
body {
margin: 0;
padding: 0;
background-color: #BADA55;
}
#wrapper {
width:500px;
margin: 20px auto;
background-color: #333;
}
#slide {
background-color: #000;
z-index: 2;
position: absolute;
left: 0;
bottom:0;
height: 0;
}
#slide h1 {
color: #fff;
text-align:center;
}
</style>
</head>
<body>
<div id="wrapper">
<ul>
<li><a href="http://google.se" title="Google">Meny 1</a></li>
<li><a href="http://bing.com" title="Bing">Meny 2</a></li>
</ul>
</div>
<div id="slide">
<h1></h1>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
var sl_siteSlider = {
init : function () {
this.resizeWindow();
this.setWidth();
this.slideUp();
},
siteWidth : $(window).width(),
siteHeight : $(window).height(),
resizeWindow : function () {
$(window).resize(function () {
sl_siteSlider.siteWidth = $(window).width();
sl_siteSlider.siteHeight = $(window).height();
sl_siteSlider.setWidth();
console.log(sl_siteSlider.siteWidth);
});
},
setWidth : function () {
$('#slide').css({
width : this.siteWidth+'px',
});
},
slideUp : function(e) {
$('#wrapper a').click(function (e) {
e.preventDefault();
var clickedLink = $(this).attr('href');
$('#slide h1').text($(this).attr('href'));
$('#slide').animate({
height : sl_siteSlider.siteHeight
}, 2000, function () {
window.location = clickedLink;
});
});
}
};
// Kör igång
sl_siteSlider.init();
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment