.container-item-1
{
top : -24px;
font-size: 8px;
position: absolute;
transition : top .15s
}
.container-item-2
{
top : 0px;
font-size: 16px;
position: absolute;
transition : top .15s
}
.container-item-3
{
top : 24px;
font-size: 24px;
position: absolute;
transition : top .15s
}
.container-item-4
{
top : 58px;
font-size: 32px;
position: absolute;
transition : top .15s
}
.container-item-5
{
top : 98px;
position: absolute;
font-size: 24px;
transition : top .15s
}
.container-item-6
{
font-size: 16px;
top :130px;
position: absolute;
transition : top .15s
}
.container-item-7
{
font-size: 8px;
top :146px;
position: absolute;
transition : top .15s
}
.container
{
overflow: hidden;
height: 146px;
position: relative;
outline : 0;
}
.card
{
width: 168px;
text-align : center;
height : 20px;
}
JavaScript
/** This is high-level function.
* It must react to delta being more/less than zero.
*/
function handle(delta) {
var middlePoint =3;
var clock = document.getElementById("clock");
var numElements = clock.getAttribute('numElements');
var scrollDelta = parseInt(delta)
var newClock;
console.log("mouse delta " + scrollDelta);
if (scrollDelta < 0)
{
console.log("mouse down" + delta);
moveUp(clock, numElements, middlePoint, 2)
}
else
{
console.log("mouse up" + delta);
moveDown(clock, numElements, middlePoint, 4) ;
}
}
/** Event handler for mouse wheel event.
*/
function wheel(event){
console.log("wheel event ");
var delta = 0;
if (!event) /* For IE. */
event = window.event;
if (event.wheelDelta) { /* IE/Opera. */
delta = event.wheelDelta/120;
} else if (event.detail) { /** Mozilla case. */
/** In Mozilla, sign of delta is different than in IE.
* Also, delta is multiple of 3.
*/
delta = -event.detail/3;
}
/** If delta is nonzero, handle it.
* Basically, delta is now positive if wheel was scrolled up,
* and negative, if wheel was scrolled down.
*/
if (delta)
handle(delta);
/** Prevent default actions caused by mouse wheel.
* That might be ugly, but we handle scrolls somehow
* anyway, so don't bother here..
*/
if (event.preventDefault)
event.preventDefault();
// event.cancel();
event.returnValue = false;
}
/** Initialization code.
* If you use your own event management code, change it as required.
*/
if (window.addEventListener)
/** DOMMouseScroll is for mozilla. */
rootElement.addEventListener('DOMMouseScroll', wheel, false);
/** IE/Opera. */
rootElement.onmousewheel =...
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.