mirror of
https://github.com/lovasoa/whitebophir
synced 2024-11-10 06:24:17 +00:00
Added a simple hand tool to move more easily in the board.
This commit is contained in:
parent
47a8445d0c
commit
e70204f5e2
1 changed files with 58 additions and 0 deletions
58
client-data/tools/hand/hand.js
Normal file
58
client-data/tools/hand/hand.js
Normal file
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
* WHITEBOPHIR
|
||||
*********************************************************
|
||||
* @licstart The following is the entire license notice for the
|
||||
* JavaScript code in this page.
|
||||
*
|
||||
* Copyright (C) 2013 Ophir LOJKINE
|
||||
*
|
||||
*
|
||||
* The JavaScript code in this page is free software: you can
|
||||
* redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GNU GPL) as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version. The code is distributed WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
|
||||
*
|
||||
* As additional permission under GNU GPL version 3 section 7, you
|
||||
* may distribute non-source (e.g., minimized or compacted) forms of
|
||||
* that code without the copy of the GNU GPL normally required by
|
||||
* section 4, provided you include this license notice and a URL
|
||||
* through which recipients can access the Corresponding Source.
|
||||
*
|
||||
* @licend
|
||||
*/
|
||||
|
||||
(function(){ //Code isolation
|
||||
|
||||
var orig = {x:0,y:0};
|
||||
var pressed = false;
|
||||
function press(x,y,evt) {
|
||||
pressed=true;
|
||||
orig.x=scrollX+evt.clientX;
|
||||
orig.y=scrollY+evt.clientY;
|
||||
evt.preventDefault();
|
||||
return false;
|
||||
}
|
||||
function move(x,y,evt) {
|
||||
if (pressed) {
|
||||
window.scrollTo(orig.x-evt.clientX, orig.y-evt.clientY);
|
||||
}
|
||||
evt.preventDefault();
|
||||
return false;
|
||||
}
|
||||
function release() {
|
||||
pressed=false;
|
||||
}
|
||||
|
||||
Tools.add({ //The new tool
|
||||
"name" : "Hand",
|
||||
"listeners" : {
|
||||
"press" : press,
|
||||
"move" : move,
|
||||
"release" : release
|
||||
},
|
||||
});
|
||||
|
||||
})(); //End of code isolation
|
Loading…
Reference in a new issue