Last active
December 10, 2015 19:28
-
-
Save eogas/4481392 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var readyToGo = false; | |
function scroll() { | |
content = $(".contentText"); | |
stopmargin = $(".sTicker").width() - | |
(($(".sTicker-brand").width() + $(".sTicker-category").width()) * 1.3); | |
finalWidth = content.width() - stopmargin; | |
speed = finalWidth * 8; | |
if ($(".contentText").width() > stopmargin) { | |
console.log("insideRoll"); | |
$(".contentText").delay(1000); | |
$(".contentText").animate({ | |
right: finalWidth | |
}, speed, 'swing', function () { | |
activeCounterClear(); | |
}); | |
} else { | |
console.log("outsideRoll"); | |
setTimeout(function () {}, 4000); | |
} | |
} | |
function reset() { | |
$(".contentText").css('right', 0); | |
} | |
newText = "Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, " + | |
"there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the"; | |
function changeText(newText) { | |
$('.contentText').text(newText); | |
} | |
function swapContent(newText) { | |
$(".contentText").slideUp(); | |
$(".contentText").text(newText); | |
$(".contentText").slideDown(400, scroll()); | |
} | |
function activeCounterClear() { | |
$('.counterBlock-active').hide("puff", {}, 1000, rollTicker(i - 1)); | |
} | |
function nextCounterActive() { | |
$('.counterBlock:visible').last().toggleClass('counterBlock-active', 300) | |
} | |
var stories = []; | |
stories[0] = "Story 0 Far far away, behind the word mountains, far from the countries Vokalia"; | |
stories[1] = "Story 1 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo " + | |
"ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes,"; | |
stories[2] = "Story 2 But I must explain to you how all this mistaken idea of denouncing pleasure " + | |
"and praising pain was born and I will give you a complete account of the system, and expound " + | |
"the actual teachings of the great explorer of"; | |
stories[4] = "Story 4 One morning, when Gregor Samsa woke from troubled dreams, he"; | |
stories[3] = "Story 3 The quick, brown fox jumps over a lazy dog. DJs flock by when MTV ax quiz " + | |
"prog. Junk MTV quiz graced by fox whelps. Bawds jog, flick quartz, vex nymphs. Waltz, bad " + | |
"nymph, for quick jigs vex! Fox nymphs grab quick-jived waltz. Brick quiz whangs jumpy veldt " + | |
"fox. Bright vixens"; | |
function refreshCounter() { | |
$(".counter").empty(); | |
console.log("Refreshing Counter"); | |
counterLength = stories.length; | |
if (counterLength > 9) { | |
counterLength = 9; | |
} | |
makeCounterBlocks(counterLength); | |
function makeCounterBlocks(num) { | |
console.log("Making Counter Blocks"); | |
$(".counter").append("<span class='counterBlock'></span>"); | |
if (num > 1) { | |
makeCounterBlocks(num - 1); | |
} | |
} | |
} | |
var i; | |
function runTicker() { | |
refreshCounter(); | |
readyToGo = true; | |
i = stories.length - 1 | |
rollTicker(i); | |
} | |
/* | |
*################################## | |
*HAVING TROUBLE WITH THIS FUNCTION# | |
*################################## | |
**/ | |
function rollTicker(i) { | |
$('.counterBlock:visible').last().toggleClass('counterBlock-active', 300, function () { | |
$(".contentText").slideUp(400, function () { | |
$(".contentText").css('right', 0); | |
console.log("inputting story number " + i); | |
$(".contentText").text(stories[i]); | |
}); | |
$(".contentText").slideDown(400, function () { | |
content = $(".contentText"); | |
stopmargin = $(".sTicker").width() - | |
(($(".sTicker-brand").width() + $(".sTicker-category").width()) * 1.3); | |
finalWidth = content.width() - stopmargin; | |
speed = finalWidth * 8; | |
if ($(".contentText").width() > stopmargin) { | |
console.log("insideRoll"); | |
$(".contentText").delay(1000); | |
$(".contentText").animate({ | |
right: finalWidth | |
}, speed, 'swing', function () { | |
readyToGo = true; | |
$('.counterBlock-active').hide("puff", {}, 1000, function () { | |
if (i > 0) { | |
rollTicker(i - 1); | |
} else { | |
runTicker(); | |
} | |
}); | |
}); | |
} else { | |
console.log("outsideRoll"); | |
setTimeout(function () { | |
readyToGo = true; | |
$('.counterBlock-active').hide("puff", {}, 1000, function () { | |
if (i > 0) { | |
rollTicker(i - 1); | |
} else { | |
runTicker(); | |
} | |
}); | |
}, 4000); | |
} | |
}); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment