2

I would like to change the ng-mouse enter event so only if the user hoovered for more then a second on the spot the event will fire seems like ng-model-options="{ debounce: 1000 }" is not working for this event

Any ideas ?

2 Answers 2

2
<button ng-mouseenter="myEvent()" ng-mouseleave="myEvent2()" > </button>


$scope.flag=false;
$scope.myEvent = function() {
$scope.flag=true;
  $timeOut(function(){


    if($scope.flag)
    {
      // do your logic here

    }
  }, 1000);
}

$scope.myEvent2 = function() {
    $scope.flag=false;
}

here you can set a timeout on the mouseenter, and check if the flag is made false by the mouse leave, this logic will only execute if the user has not done mouseleave for 1 sec.

Sign up to request clarification or add additional context in comments.

Comments

0

You can not set event fire time using ng-model. You will have to set delay in your event event only. For e.g.

<button ng-mouseenter="myEvent()"> </button>

$scope.myEvent = function() {
  $timeOut(function(){
    // do your function logic here.
  }, 1000);
}

2 Comments

this will also fire even if the user hovered for less than a second
The reason i want it is not to fire the applay chain every time a mouse enter event has happen - only if the user has hovered for while then he deserves it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.