Skip to main content
13-Aquamarine
July 7, 2023
Question

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

  • July 7, 2023
  • 1 reply
  • 1461 views

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);

 

 

1 reply

16-Pearl
July 7, 2023

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();

 

 

13-Aquamarine
July 10, 2023

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);

 

21-Topaz I
July 10, 2023

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);