Skip to main content
1-Visitor
January 19, 2021
Solved

Disable toggle until all steps finished playing

  • January 19, 2021
  • 1 reply
  • 1746 views

Hi, 

 

I have a toggle to change from one view to another view(e.g View A to View B). I need to disable the toggle from the start of the sequence being played in View A. When all steps in view A has finished playing, then the toggle is visible to be clicked to change to view B. 

 

How can I solve this issue?

Best answer by sebben

Hi,

 

you can call a function like this from the Play Stopped event of your model:

 

$scope.showToggle= function(){
 if($scope.view.wdg['model']['steps'] == $scope.view.wdg['model']['currentStep']){
 $scope.view.wdg["toggle-1"].visible = true
 }
 else{
 $scope.view.wdg["toggle-1"].visible = false
 }
}

 

I hope that helps.

1 reply

sebben14-AlexandriteAnswer
14-Alexandrite
January 19, 2021

Hi,

 

you can call a function like this from the Play Stopped event of your model:

 

$scope.showToggle= function(){
 if($scope.view.wdg['model']['steps'] == $scope.view.wdg['model']['currentStep']){
 $scope.view.wdg["toggle-1"].visible = true
 }
 else{
 $scope.view.wdg["toggle-1"].visible = false
 }
}

 

I hope that helps.

AS161-VisitorAuthor
1-Visitor
January 20, 2021

I have tried the code, but it didn't work. Can I know the steps to call the function correctly. Sorry for any inconvenience. I'm still new to Vuforia Studio. 

14-Alexandrite
January 20, 2021

Make sure the studio id of the model is "model" and the toggle is "toggle-1" or change it in the code so it matches your id's.  Enter in the JS field of the Play Stopped event showToggle(); Note that the  code will hide the toggle after the first step finished.  If you want to hide it when the first step starts you need to write another function and call it from the Play Started event:

$scope.hideToggle= function(){
 if($scope.view.wdg['model']['steps'] != $scope.view.wdg['model']['currentStep']){
 $scope.view.wdg["toggle-1"].visible = false
 }
}