Famous / famous-angular

Bring structure to your Famo.us apps with the power of AngularJS. Famo.us/Angular integrates seamlessly with existing Angular and Famo.us apps.
https://famo.us/angular
Mozilla Public License 2.0
1.92k stars 275 forks source link

fa-animate-enter/fa-animate-leave causing issues with ui-router #265

Closed tato123 closed 9 years ago

tato123 commented 10 years ago

This may just require updating the documentation, however I've noticed that when combining famo.us angular with ui-router and utilizing the animation enter and leave directives in the case of a parent with multiple child views (assuming a singular named ui-view for children), $done must be used and invoked on any transitionables, otherwise ui-router appears to append the content (all child views as you navigate will get get added together to the parent view rather than overriding the named ui-view).

Example

Root Page

<div ui-view="child" fa-animate-enter="enter($done)" fa-animate-leave="leave($leave)"></div>

Child 1

<fa-app>
   ... content page 1
</fa-app>

Child 2

<fa-app>
   ... content page 2
</fa-app>

Child 1 & Child 2 Controller

....
$scope.enter = function($done)
{
   o.set(1, {duration:250}, $done); // correct

}

$scope.leave = function($done)
{
   o.set(0, {duration:250}, $done); // correct
   o.set(1, {duration:250}); // incorrect, will cause this page to blead into next page
}

UI Router

           .state('root',
            {
                url: '/rootpage',
                 templateUrl: 'root.html',
                 controller: 'RootCtrl'
            })
            // list view
            .state('root.child1',
            {
                url: '/grid',
                views:
                {
                    'child' : {
                        templateUrl: 'child1.html',
                        controller: "Child1Ctrl"
                    }
                }

            })
            // grid view
            .state('root.child2',
            {
                url: '/list',
                views:
                {
                    "child" : {
                        templateUrl: 'child2.html',
                        controller: 'Child2Ctrl'
                    }
                }

            })
jordanpapaleo commented 9 years ago

Hi @tato123

Thank you for being committed to making this project better. While famous-angular may use ui-router in its examples it does not provide support for it. If you would like to see documentation for ui-router, I would encourage you to create it and submit a PR to the project.

Thanks again,

Jordan