Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigo committed Feb 15, 2014
0 parents commit dd51db3
Show file tree
Hide file tree
Showing 6 changed files with 195 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
.DS_STORE
tvcredits.sublime-project
tvcredits.sublime-workspace
49 changes: 49 additions & 0 deletions demo.html
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="tvcredits.jquery.min.js"></script>
<meta charset=utf-8 />
<link href="style.css" rel="stylesheet">
<title>Demo</title>
</head>
<body>
<div id="highlights">
<ul>
<li>Mussum ipsum cacilds, vidis litro abertis. Consetis adipiscings elitis.</li>
<li>Pra lá , depois divoltis porris, paradis. Paisis, filhis, espiritis santis.</li>
<li>Mé faiz elementum girarzis, nisi eros vermeio, in elementis mé pra quem é amistosis quis leo.</li>
<li>Manduma pindureta quium dia nois paga.</li>
<li>Sapien in monti palavris qui num significa nadis i pareci latim. </li>
<li>Interessantiss quisso pudia ce receita de bolis, mais bolis eu num gostis.</li>
</ul>
</div>


<div id="credits">
<ul>
<li>Lorene Nichols</li>
<li>Ed Figueroa</li>
<li>Sue Klein</li>
<li>Sharon Warren</li>
<li>Marta Maldonado</li>
<li>Manuel Flowers</li>
<li>Lila Chambers</li>
<li>Yolanda Haynes</li>
<li>Alfonso Lynch</li>
<li>Janie Reese</li>
</ul>
</div>

</body>
<script>
$("#highlights").tvCredits({
direction: 'left',
speed: 50000,
});
$("#credits").tvCredits({
height: 100,
speed: 9000
});
</script>
</html>
17 changes: 17 additions & 0 deletions style.css
@@ -0,0 +1,17 @@
#highlights {
border: #000 1px solid;
overflow: hidden;
width: 50%;
margin: 0 auto;
}

#credits {
border: #000 1px solid;
overflow: hidden;
width: 50%;
margin: 50px auto;
}

#credits ul {
list-style: none;
}
94 changes: 94 additions & 0 deletions tvcredits.jquery.js
@@ -0,0 +1,94 @@
$.fn.tvCredits = function (options) {
return this.each(function () {

var defaults = {
direction: 'up',
complete : function () {
},
speed : 25000,
height : 350
}

var settings = $.extend(defaults, options)
, element = $(this)
, list = element.find("ul")
, children = list.children()
, speed = settings.speed
, loop = 0
, animation;

var start = function (loop, containerWidth) {

if (settings.direction == 'left') {

// reset margins
list.css('margin-top', 0);
list.css('margin-bottom', 0);

if (loop == 0) {

// change elements to be displayed inline
element.css('display', 'block');
list.css('display', 'inline-block');
children.css('display', 'inline');

// recalculate element width
containerWidth = 0;
children.each(function () {
containerWidth += $(this).innerWidth();
});
containerWidth += containerWidth;
var currentWidth = list.innerWidth();
if (currentWidth < containerWidth) {
list.css('width', containerWidth + 'px');
}
}

// reset margin-left
list.css("margin-left", '100%');

animation = {"margin-left": '-' + containerWidth + 'px' }

loop++;

} else {

var elementHeight = settings.height;
element.css('height', settings.height + 'px');

list.css('margin-top', elementHeight - (elementHeight * 0.2) +'px');
list.css('margin-bottom', '-' + elementHeight + 'px');

if (loop == 0) {
// reset display
element.css('display', 'table');
list.css('display', 'block');
children.css('display', 'block');

list.css('margin-left', 0);
list.css('width', '90%');
}

// recalculate element height
var containerHeight = 0;
children.each(function () {
containerHeight += $(this).height();
});

list.css('height', elementHeight);

animation = {"margin-top": '-' + (containerHeight * 2) + 'px'};

loop++;
}

list.animate(animation, speed, 'linear', function () {
settings.complete();
start(loop, containerWidth);
});
}

start(loop, null);

});
}
31 changes: 31 additions & 0 deletions tvcredits.jquery.json
@@ -0,0 +1,31 @@
{
"name": "tvcredits",
"title": "TV Credits",
"description": "Horizontal and vertical scroll jQuery plugin. It can be used as a horizontal ticker or a vertical TV credits scroll style.",
"keywords": [
"scroll",
"animation",
"ticker"
],
"version": "0.0.1",
"author": {
"name": "Rodrigo dos Santos",
"url": "http://blog.dossantos.com.au"
},
"maintainers": [
{
"name": "Rodrigo dos Santos",
"url": "http://blog.dossantos.com.au"
}
],
"licenses": [
{
"type": "BSD",
"url": "http://www.opensource.org/licenses/bsd-license.php"
}
],

"dependencies": {
"jquery": ">=1.9"
}
}
1 change: 1 addition & 0 deletions tvcredits.jquery.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dd51db3

Please sign in to comment.