# Detect mouse direction

**URL:** <https://forum.kirupa.com/t/detect-mouse-direction/263388>\
**Category:** Uncategorized\
**Created:** [June 15, 2008, 2:12pm UTC](https://forum.kirupa.com/t/detect-mouse-direction/263388 "2008-06-15T14:12:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Captain\_Ahab](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@Captain\_Ahab](https://forum.kirupa.com/u/Captain_Ahab)\
**Post date:** [June 15, 2008, 2:12pm UTC](https://forum.kirupa.com/t/detect-mouse-direction/263388/1 "2008-06-15T14:12:47Z")

</div>

Hi all,  
I have another question please.

Take a look here:  
[http://filippasmedhagensund.com/#/beauty/nord/2/](http://filippasmedhagensund.com/#/beauty/nord/2/)

you’ll see that after you start dragging - if dragged horizontally, unless you release the mouse-click the drag is locked on the horizontal line. Then if you drag vertically, it’s locked on a vertical drag, again untill you release the click.

I tried modifying the “detect mouse direction” tutorial from here, but i couldnt get it.

My question is how do i modify this tutorial so it will only run once (when a drag starts), detect the movement, stop running, and shoot the direction to the dragging function?

Hope I’m clear,  
thanks in advance

Miki.

---

<div class="post-metadata">

**Author:** ![Captain\_Ahab](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@Captain\_Ahab](https://forum.kirupa.com/u/Captain_Ahab)\
**Post date:** [June 15, 2008, 2:54pm UTC](https://forum.kirupa.com/t/detect-mouse-direction/263388/2 "2008-06-15T14:54:15Z")

</div>

Solved 🙂

If it intrests anybody, all I had to do is to add this.unwatch(“xdir”, checkX);  
at every if statement.  
the function will now be triggering again, for a one checl, at the next click.
