81 lines
1.4 KiB
JavaScript
Executable File
81 lines
1.4 KiB
JavaScript
Executable File
/*
|
|
Les different element dragable auront une interface getStr, getArray, etc pour chaque type. Cela
|
|
permettra lors du deposer du cycle glisser deposer a l'objet recepteur de choisir le type le plus
|
|
adapté avec des priorité de selection dudit type.
|
|
*/
|
|
|
|
function dragable( elem ) { // elem : HTMLElement
|
|
|
|
this.elem = elem;
|
|
this.source = null;
|
|
|
|
function beginDrag(source) {
|
|
|
|
this.source = source;
|
|
}
|
|
|
|
/*function isOver(mousex, mousey) {
|
|
var ret = false;
|
|
var nodes = this.elem.childNodes
|
|
for( var i in nodes ) {
|
|
if (nodes[i] != this.source) {
|
|
|
|
nodes[i].
|
|
}
|
|
}
|
|
}*/
|
|
|
|
function endDrag() {
|
|
}
|
|
|
|
function update() {
|
|
}
|
|
|
|
function onmove() {
|
|
}
|
|
}
|
|
|
|
|
|
function dsMouse(elem) {
|
|
|
|
this.elem = elem;
|
|
this.x = 0;
|
|
this.y = 0;
|
|
this.lastX = 0;
|
|
this.lastY = 0;
|
|
|
|
var self = this;
|
|
|
|
this.begin = function(e) {
|
|
|
|
this.x = e.clientX;
|
|
this.y = e.clientY;
|
|
this.lastX = e.clientX;
|
|
this.lastY = e.clientY;
|
|
this.elem.removeEventListener('click', anon_begin, false);
|
|
}
|
|
|
|
this.onmove = function(e) {
|
|
|
|
this.x = this.x + e.clientX - this.lastX;
|
|
this.y = this.y + e.clientY - this.lastY;
|
|
this.lastX = e.clientX;
|
|
this.lastY = e.clientY;
|
|
return true;
|
|
}
|
|
|
|
|
|
function anon_begin(e) {
|
|
|
|
return self.begin(e);
|
|
}
|
|
|
|
function anon_onmove(e) {
|
|
|
|
return self.onmove(e);
|
|
}
|
|
|
|
|
|
elem.addEventListener('click', anon_begin, false);
|
|
elem.addEventListener('mousemove', anon_onmove, false);
|
|
} |