Skip to content

Instantly share code, notes, and snippets.

@timruffles
Created May 25, 2011 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timruffles/991258 to your computer and use it in GitHub Desktop.
Save timruffles/991258 to your computer and use it in GitHub Desktop.
rotater
<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>
@md2perpe
Copy link

if(!this.list) = $(selector);

Syntax error!?

@timruffles
Copy link
Author

hehe sorry I was just transferring this to a colleague :D

updated with a working test page

@timruffles
Copy link
Author

maybe i should add demo code disclaimers in future :) ... hope it helps anyways

@md2perpe
Copy link

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