cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Call function based on visability of an image

rireland-bowcot
11-Garnet

Call function based on visability of an image

I'd like to call the function below base on the visibility of an image but i am unaware of how to do this. Could someone help please? 

$scope.intro = function() {
	var labelText = $scope.view.wdg['checkstart'].text;      
	var spokenText = labelText.substr(labelText.indexOf(" ") + 1);
	$scope.app.speech.synthesizeSpeech({ 'text': spokenText });	
}

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions

It depends on what you mean by "visability".

 

If you mean "when the visability parameter is set to true", then yes, you can do that using $scope.$watch, something like this:

$scope.$watch('view.wdg["image-1"].visible', function (val) {
    if (val) {
        $scope.intro();
    }
}

However, if you mean "when the user moves their device around so the image enters their field of view", then I think the answer is no. I don't think there's a way to detect whether an object is in the viewport or not. (I would be happy to be proven wrong, if there is a way to do this!) I also don't know of a way to get the location of the camera relative to the 3D view origin, so you can't try to derive it that way.

View solution in original post

1 REPLY 1

It depends on what you mean by "visability".

 

If you mean "when the visability parameter is set to true", then yes, you can do that using $scope.$watch, something like this:

$scope.$watch('view.wdg["image-1"].visible', function (val) {
    if (val) {
        $scope.intro();
    }
}

However, if you mean "when the user moves their device around so the image enters their field of view", then I think the answer is no. I don't think there's a way to detect whether an object is in the viewport or not. (I would be happy to be proven wrong, if there is a way to do this!) I also don't know of a way to get the location of the camera relative to the 3D view origin, so you can't try to derive it that way.

Top Tags