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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

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

Rakesh_kumar_S
13-Aquamarine

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 3

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

 

 

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

 

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

 

Announcements

Top Tags