Skip to main content
13-Aquamarine
Jul 7, 2023 4:46 AM UTC
Question

how to re write this program, if i am click the button then image should blink.

how to re write this program, if i am click the button then image should blink.

$scope.blinkInterval = 0;

$scope.blinkImage = function(id) {
 var current = $scope.view.wdg[id].visible;
 if (current == undefined) { current = true;}
 $scope.setWidgetProp(id, "visible", !current);
}

$scope.startBlink = function() {
 $scope.blinkInterval = $interval($scope.blinkImage, 1000, 0, true, "3DImage-1");
}

$scope.stopBlink = function(id) {
 $interval.cancel($scope.blinkInterval);
}

angular.element(document).ready($scope.startBlink);

 

 

3 replies

16-Pearl
Jul 7, 2023 6:05 PM UTC

If I understand you want to have a button to run on click startBlink();

2023-07-07_12-02-38.jpg

$scope.startBlink

 

You can add in the click JS area of a button widget

 

 startBlink();

 

 

Translate
13-Aquamarine
Jul 10, 2023 7:07 AM UTC

if I use this code, automatically blinking started without button click, I have to control the blink using button.

 

Now My Question is:

How to control the blink using button, how should I write the JS.

 

$scope.blinkInterval = 0;

$scope.blinkImage = function(id) {
 var current = $scope.view.wdg[id].visible;
 if (current == undefined) { current = true;}
 $scope.setWidgetProp(id, "visible", !current);
}

$scope.startBlink = function() {
 $scope.blinkInterval = $interval($scope.blinkImage, 1000, 0, true, "3DImage-1");
}

$scope.stopBlink = function(id) {
 $interval.cancel($scope.blinkInterval);
}

angular.element(document).ready($scope.startBlink);

 

Translate
21-Topaz I
Jul 10, 2023 8:47 AM UTC

so as @sgreywilson  suggested you need to start it by the button.

In your code you have to comment the call in the ready event which is called automatically when view is loaded and ready

//comment this to avoid the automatic start
//angular.element(document).ready($scope.startBlink);

 

Translate