O'Reilly logo

PhoneGap By Example by Andrey Kovalenko

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling the pointer move event

When we move the pointer, we perform the following tasks:

  • Pointer is down
  • Select a bubble in the global variable
  • Check whether the bubble can be moved into this position
  • Swap two neighbor bubbles

The ready slideBubble handler looks like this:

function slideBubble(pointer, x, y, fromClick) { if (window.selectedBubble && pointer.isDown) { var cursorBubblePosX = getBubblePos(x); var cursorBubblePosY = getBubblePos(y); if (checkIfBubbleCanBeMovedHere( window.selectedBubbleStartPos.x, window.selectedBubbleStartPos.y, cursorBubblePosX, cursorBubblePosY)) { if (cursorBubblePosX !== window.selectedBubble.posX || cursorBubblePosY !== window.selectedBubble.posY) { bubbles.bringToTop(window.selectedBubble); tempShiftedBubble = getBubble(cursorBubblePosX, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required