in the same js file, there are two written methods: aPermib. It can be run when the c method is called, but only the second d method is executed if both methods c _ ab d call the above method at the same time. What to do, whether to make a packet into a packet or put it in another js file.
these two are operation methods
function a(first) { //
first.onmousedown = function (e) { //onclickmouseover,onmousedown
e.preventDefault && e.preventDefault(); // !!!
var x = e.clientX - first.offsetLeft;
var y = e.clientY - first.offsetTop;
document.onmousemove = function (e) {
first.style.left = e.clientX - x + "px";
first.style.top = e.clientY - y + "px";
};
document.onmouseup = function () {
document.onmousemove = null;
document.onmouseup=null;
}
}
};
//Collision detection,,firstsecondmethod;
function b(first,second,method) {
//
/* var first=document.getElementById("-sharp");//
var second=document.getElementById("-sharp");//*/
first.onmousemove=function () { //first
var t1 = first.offsetTop,
l1 = first.offsetLeft,
r1 = first.offsetLeft + first.offsetWidth,
b1 = first.offsetTop + first.offsetHeight;
var t2 = second.offsetTop,
l2 = second.offsetLeft,
r2 = second.offsetLeft + second.offsetWidth,
b2 = second.offsetTop + second.offsetHeight;
var noConflict=b1<t2 || l1>r2 || t1>b2 || r1<l2;//
if(!noConflict){ //;
// return true;
method.f(); //json;
// method(); //;
}
}
}
two calls
function c() {
var method={ //json
name:"method",
f:function () { //firstsecond;
//
}
move(first);
CD(first,second,method);
}
function d(){
var method={
name:"method",
f:function () {
//
}
}
move(first);
CD(first,second,method);
}
cdfirst,second,method