document.getElementById("clock").addEventListener("click",wheelHandler);
function moveUp(clock, numElements, middlePoint, index) {
var count = middlePoint - index;
var i = numElements - count;
var idCount = 0;
var newClock = document.createElement("div");
for ( ; i < numElements; i++)
{
var node = document.getElementById(i);
var adpNode = document.adoptNode(node);
adpNode.id=idCount++;
newClock.appendChild(adpNode);
}
for ( i=0; i < numElements-count; i++)
{
var node = document.getElementById(i);
var adpNode = document.adoptNode(node);
adpNode.id=idCount++;
newClock.appendChild(adpNode);
}
newClock.id="clock";
return newClock;
}
function moveDown(clock, numElements, middlePoint, index) {
var count = index - middlePoint;
var idCount = 0;
var newClock = document.createElement("div");
for ( i=count; i < numElements; i++)
{
var node = document.getElementById(i);
var adpNode = document.adoptNode(node);
adpNode.id=idCount++;
newClock.appendChild(adpNode);
}
for ( var i = 0; i < count; i++)
{
var node = document.getElementById(i);
// alert(node.innerHTML);
// node.parentNode.removeChild(node);
var adpNode = document.adoptNode(node);
adpNode.id=idCount++;
newClock.appendChild(adpNode);
}
newClock.id="clock";
return newClock;
}
function wheelHandler(e) {
// e.target is our targetted element.
var index = e.target.getAttribute('id');
var middlePoint =4;
var clock = document.getElementById("clock");
var numElements = clock.getAttribute('numElements');
var newClock;
if (index < middlePoint)
{
newClock = moveUp(clock, numElements, middlePoint, index) ;
}
else if (index > middlePoint)
{
newClock =...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.