Alex Rivera | Logout

JavaScript how to check drag direction

Asked 2011-06-03T08:15:46.240
13

I am trying to monitor dragStart and dragEvent javascript, in order to conclude its direction, UP or DOWN.

However i could not get any detail in arguments passed by the event -- that help to conclude.

Is there any better way to check drag direction , up or down?

Note: my problem is specifically happening at mojo javascript at webos

Thanks, -iwan

Edit
Report

1 Answer

0

You want to use dragOver. You could do something like this if you're only interested in vertical position:

Javascript:

<script type="text/javascript">
    function getPosY(event) {
      console.log(event.clientY);
    }
</script>

HTML:

<body ondragover="getPosY(event)">

EDIT: Here's a jsfiddle. Make sure your js console is open.

You could have your function compare the clientY values to determine which direction the mouse is moving.

answered 2011-06-03T08:34:02.317

Your Answer