

/**
 * @ngdoc function
 * @name domainManagerApp.controller:AboutCtrl
 * @description
 * # AboutCtrl
 * Controller of the domainManagerApp
 */
angular.module('goApp.test', ['ngFx', 'ngAnimate', 'goApp.data'])
  .controller('TestController',['$scope', '$rootScope', '$famous', '$timeline', '$location', '$route', '$timeout', 'Data', '$mixpanel', function ($scope,  $rootScope, $famous, $timeline, $location, $route, $timeout, Data, $mixpanel) {

    'use strict';

    var link = $location.url();
    $scope.pageData = Data.getPageData(link);
    $rootScope.$on('data:loaded', function(data) {
      if(!$scope.$$phase) {
        $scope.$apply(function(){
          $scope.pageData = Data.getPageData(link);
          $mixpanel.track('Page View', { "Page": $scope.pageData.link });
        });
      }
    });

    // FadeIn
    $timeout(function(){
      $scope.showView = true;
    },100);

    $scope.fadeOut = function() {
      $scope.showView = false;
      $timeout(function(){
        $location.path("/");
      },500);
    };


    // Moving Cube
    var Transitionable = $famous['famous/transitions/Transitionable'];
    var Easing = $famous['famous/transitions/Easing'];

    $scope.t = new Transitionable(0);

    $scope.translation = $timeline([
      [0, [500, 400, 100], Easing.inOutQuad],
      [0.25, [400, 200, 100], Easing.inOutQuad],
      [0.5, [300, 300, 100], Easing.inOutQuad],
      [0.75, [200, 500, 100], Easing.inOutQuad],
      [1, [100, 100, 100], Easing.inOutQuad],
    ]);

    $scope.startAnimations = function(){
      $scope.t.delay((1000), function(){ // we will delay each animation based on index
          $scope.t.set(1, {duration: 3400}, function(){
            // Animation Completion Callback
          });
      });
    };

    //$scope.startAnimations();



    $scope.pageData = Data.getPageData();
    $scope.startAnimations();

  }]);
