martymarkenson of Ninjas
9/18/2017 - 5:59 PM

This is a function which will toggle the visibility of a resource depending on what step in the play all sequence an animation is in

This is a function which will toggle the visibility of a resource depending on what step in the play all sequence an animation is in

$scope.showImages = function() {
  //calls StepImages function every 250ms
  interval = setInterval($scope.stepImages, 250);
}

$scope.stepImages = function() {
  console.log("Current Step: "+ $scope.app.view['Home'].wdg[__nameOfWidget__]['currentStep']);
    //replace __nameOfWidget__ with name of widget which contains sequence
  if ($scope.app.view['Home'].wdg[__nameOfWidget__]['currentStep']==1) {
      //replace __nameOfWidget1__ with widget you want to show for first step
      //shows first image and hides last image (for case that last image still up from previous play)
      $scope.view.wdg[__nameOfWidget1__]['visible']=true;
      $scope.view.wdg[__nameOfWidget4__]['visible']=false;
    }
    else if ($scope.app.view['Home'].wdg['pipingModel']['currentStep']==2) {
    //hides widget1 shown in first step and shows widget2 in second step
      $scope.view.wdg[__nameOfWidget1__]['visible']=false;
      $scope.view.wdg[__nameOfWidget2__]['visible']=true;
    }
    else if ($scope.app.view['Home'].wdg['pipingModel']['currentStep']==3) {
    //hides widget2 from second step and shows widget3 in third step
      $scope.view.wdg[__nameOfWidget2__]['visible']=false;
      $scope.view.wdg[__nameOfWidget3__]['visible']=true;
    }
    else if ($scope.app.view['Home'].wdg['pipingModel']['currentStep']==4) {
    //hides widget3 from third step and shows widget4 in fourth step then stop stepImages() from being called every 250ms
      $scope.view.wdg[__nameOfWidget3__]['visible']=false;
      $scope.view.wdg[__nameOfWidget4__]['visible']=true;
      clearInterval(interval);
    }
    $scope.$applyAsync();
}