BONUS : "ROULETTE" EXAMPLE, USING CALLBACKS & METHODS
var state = 'stopped';
var speed;
var add;
var nt_example3 = $('#nt-example3').newsTicker({
row_height: 80,
max_rows: 1,
duration: 0,
speed: 10,
autostart: 0,
pauseOnHover: 0,
hasMoved: function() {
if (speed > 700) {
$('#nt-example3').newsTicker("stop");
console.log('stop')
$('#nt-example3-button').text("RESULT: " + $('#nt-example3 li:first').text().toUpperCase());
setTimeout(function() {
$('#nt-example3-button').text("START");
state = 'stopped';
},2500);
}
else if (state == 'stopping') {
add = add * 1.4;
speed = speed + add;
console.log(speed)
$('#nt-example3').newsTicker('updateOption', "duration", speed + 25);
$('#nt-example3').newsTicker('updateOption', "speed", speed);
}
}
});
$('#nt-example3-button').click(function(){
if (state == 'stopped') {
state = 'turning';
speed = 1;
add = 1;
$('#nt-example3').newsTicker('updateOption', "duration", 0);
$('#nt-example3').newsTicker('updateOption', "speed", speed);
nt_example3.newsTicker('start');
$(this).text("STOP");
}
else if (state == 'turning') {
state = 'stopping';
$(this).text("WAITING...");
}
});