Book Image

PhoneGap By Example

Book Image

PhoneGap By Example

Overview of this book

Table of Contents (17 chapters)
PhoneGap By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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, cursorBubblePosY);                
              ...