Changes

Jump to: navigation, search

Implementing the Mouse Lock API in Firefox

711 bytes added, 17:00, 30 November 2011
Demos, Docs, Other
# Proper IDL documentation for navigator.pointer (see example in https://mxr.mozilla.org/mozilla-central/source/dom/interfaces/html/nsIDOMHTMLElement.idl#103), MouseLockable and its methods, MouseLockLost event, etc.
# Write a JavaScript library to somehow combine element.mozRequestFullScreen() and navigator.pointer.lock(). It would be good to hide the complexities of doing fullscreen then locking in a single API call. - nm486
 
<pre>
var canvas = document.getElementById('canvas');
 
// Will put element into fullscreen then try to do mouse lock
var lock = acquireMouseLock({
element: canvas,
onLock: function() {
// OPTIONAL
// fullscreen + mouse lock are now setup for element
},
onUnlock: function() {
// OPTIONAL
// the user or browser took us out of fullscreen/mouse lock
},
onError: function() {
// OPTIONAL
// there was an error getting fullscreen/mouse lock
},
onMovemennt: function(e) {
// OPTIONAL
// movementX and movementY for mousemove are passed in
var deltaX = e.movementX;
var deltaY = e.movementY;
}
});
 
...
lock.islocked; // true or false
lock.unlock();
</pre>
 
# Mouse lock specification fix requests
# Convert Rescue Fox to use Mouse Lock, see https://github.com/mozilla/rescuefox

Navigation menu