Jump to content

playground drag and drop example question


satguru
 Share

Recommended Posts

In the playground "drag and drop" example,  in function "onPointerDown()" the camera is detached from the canvas using following code

if (startingPoint) { // we need to disconnect camera from canvas
                setTimeout(function () {
                    camera.detachControl(canvas);
                }, 0);
                //    camera.detachControl(canvas);
}

 

If I remove the setTimeout() and do "detachControl" directly the code works fine on chrome and firefox but fails in IE

In IE the camera becomes a free look camera :o

Whats the significance of the "setTimeout()" function?

Link to comment
Share on other sites

A very simple explanation (it can get more complex :) ) - setTimeout with a value of 0(ms) tells the JS engine to execute the given function after it has ended with its current tasks. It adds this function to be executed and doesn't execute it immediately. 

I guess that since this function executes native js events unregistration, some engines might have a problem running it. But i don't really know why IE doesn't work. It is just an assumption.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...