Skip to content

Commit

Permalink
add current state to elements on init
Browse files Browse the repository at this point in the history
  • Loading branch information
homerjam committed Jan 8, 2015
1 parent c5d00d4 commit 54ae37a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
22 changes: 19 additions & 3 deletions angular-gsapify-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,22 @@
];
})

.animation('.gsapify-router', ['$rootScope', 'gsapifyRouter',
function($rootScope, gsapifyRouter) {
.animation('.gsapify-router', ['$rootScope', '$state', '$document', 'gsapifyRouter',
function($rootScope, $state, $document, gsapifyRouter) {
var watchInitialState = $rootScope.$watch(function() {
return $state.current.name;
}, function(name) {
if (name !== '') {
watchInitialState();

var elements = $document[0].querySelectorAll('.gsapify-router');

angular.forEach(elements, function(el) {
el.setAttribute('data-state', name);
});
}
});

return {
enter: function(element, done) {
$rootScope.$broadcast('gsapifyRouter:enterStart', element);
Expand All @@ -241,7 +255,9 @@
});

return function(cancelled) {
if (cancelled) {}
if (cancelled) {
element.remove();
}
};
},
leave: function(element, done) {
Expand Down
6 changes: 3 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-gsapify-router",
"version": "0.0.16",
"version": "0.0.17",
"description": "Angular UI-Router animation directive allowing configuration of state transitions using GSAP",
"main": "angular-gsapify-router.js",
"ignore": [
Expand All @@ -9,8 +9,8 @@
"!README.md"
],
"dependencies": {
"angular": "~1.2.0",
"angular-animate": "~1.2.0",
"angular": ">=1.2.0",
"angular-animate": ">=1.2.0",
"gsap": "~1.13.0",
"angular-ui-router": "~0.2.11"
},
Expand Down

0 comments on commit 54ae37a

Please sign in to comment.