-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Crossfade between Author and Name for mariobar
- Loading branch information
Showing
13 changed files
with
179 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Binary file not shown.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
(function(){ | ||
'use strict'; | ||
|
||
var app = angular.module('dramBarApp'); | ||
app.controller('innerFadeController', innerFadeController); | ||
app.directive('innerFade', innerFadeDirective); | ||
|
||
// innerFadeDirective | ||
// | ||
// Pass in a list of strings and they will cycle every x milliseconds | ||
// with a fadeIn/fadeOut transition. Similar to a slideshow. | ||
// | ||
// The container is sized to the largest string in the given items. | ||
// | ||
// Usage: | ||
// <inner-fade items="ctrl.listOfStrings" interval="8000"></inner-fade> | ||
// | ||
innerFadeDirective.inject = ['$interval', '$timeout']; | ||
function innerFadeDirective($interval, $timeout) { | ||
return { | ||
restrict: 'E', | ||
templateUrl: '/drambar/innerfade.html', | ||
scope: { | ||
items: '<', | ||
interval: '<' | ||
}, | ||
controller: innerFadeController, | ||
controllerAs: 'innerfade', | ||
bindToController: true, | ||
link: function innerFadeLink(scope, element) { | ||
|
||
// on items change | ||
scope.$watchCollection('innerfade.items', function() { | ||
if (scope.innerfade.items) | ||
scope.innerfade.longestItem = scope.innerfade.items.reduce(function (a, b) { return a.length > b.length ? a : b; }); | ||
}); | ||
|
||
// wrap in $timeout to allow DOM to load children | ||
$timeout(function(){ | ||
var children = element.find("p.inner-fade-item"); | ||
var visibleIndex = 0; | ||
var maxIndex = children.length; | ||
|
||
// hide children by default | ||
angular.forEach(jQuery(children), function(value, key) { | ||
var child = angular.element(value); | ||
child.hide(); | ||
}); | ||
|
||
// immediately display first child | ||
jQuery(element).show(); | ||
jQuery(children[0]).fadeTo(500, 1); | ||
|
||
// cycle through all elements - for each interval | ||
$interval(function() { | ||
// Get next element index | ||
var nextIndex = visibleIndex + 1; | ||
if (nextIndex >= maxIndex) | ||
nextIndex = 0; | ||
|
||
// fade out current element | ||
jQuery(children[visibleIndex]).fadeTo(500, 0, function(){ | ||
// display next element | ||
jQuery(children[nextIndex]).fadeTo(500, 1); | ||
}); | ||
|
||
// increment index | ||
visibleIndex = nextIndex; | ||
|
||
}, scope.innerfade.interval); // interval | ||
|
||
}, 100); // timeout | ||
} | ||
} | ||
} | ||
function innerFadeController() {} | ||
})(); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<div class="inner-fade-container"> | ||
|
||
<p class="inner-fade-size" style="opacity:0;"> | ||
{{innerfade.longestItem}} | ||
</p> | ||
<p class="inner-fade-item" ng-repeat="item in innerfade.items track by $index" | ||
style="position: absolute; | ||
left: 0; | ||
right: 0; | ||
top: 9px; | ||
margin-left: auto; | ||
margin-right: auto;"> | ||
{{item}} | ||
</p> | ||
</div> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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