Created
May 25, 2011 16:07
-
-
Save timruffles/991258 to your computer and use it in GitHub Desktop.
rotater
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript" charset="utf-8"></script> | |
</head> | |
<body> | |
<h3 class="title">Picklive buzz</h3> | |
<script type="text/javascript"> | |
var rotater = function(selector) { | |
var item, lastItem; | |
return function() { | |
if(!this.list) this.list = $(selector); | |
if(!this.index) this.index = 0; | |
lastItem = item; | |
item = this.list.eq(this.index); | |
this.index++; | |
if(this.index == this.list.length) this.index = 0; | |
return [item,lastItem]; | |
} | |
}, | |
effectRotater = function(selector,effectFn) { | |
var plainRotater = this.rotater(selector); | |
return function() { | |
var itemLast = plainRotater(); | |
effectFn(itemLast[0],itemLast[1]) | |
} | |
}, | |
effectFn = function(newEle,oldEle) { | |
// your code goes here | |
$(newEle).slideDown() | |
$(oldEle).slideUp() | |
}; | |
setInterval(effectRotater('.aaa',effectFn),2000) | |
</script> | |
<div class="aaa"> | |
<blockquote> | |
“It’s certainly going to make every game a bit more interesting” | |
</blockquote> | |
<img src="/images/logo_stuff_black.gif"> | |
</div> | |
<div class="aaa"> | |
<blockquote> | |
“A whole new realm of entertainment” | |
</blockquote> | |
<img src="/images/logo_bbc_black.gif"> | |
</div> | |
<div class="aaa"> | |
<blockquote> | |
“Picklive will even add spice to a no score draw” | |
</blockquote> | |
<img src="/images/logo_yahoo_black.gif"> | |
</div> | |
</body> | |
</html> |
hehe sorry I was just transferring this to a colleague :D
updated with a working test page
maybe i should add demo code disclaimers in future :) ... hope it helps anyways
I didn't test the code; just read it. Found your gist through the list of last created public gists.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Syntax error!?