1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
var divs = document.getElementById('goods_gallery').childNodes;
var moving_item = null;
for (var i = 0; i < divs.length; i++) {
var div = divs[i];
div.onselectstart = function() {return false;}
div.onmousedown = function() {
moving_item = this;
return false;
}
div.onmousemove = function(evt) {
evt = evt || event;
if (moving_item && moving_item != this) {
var pos = getPosition(this);
var maxleft = pos.left + this.clientWidth / 2;
if (evt.screenX < maxleft) {
this.parentNode.insertBefore(moving_item, this);
} else {
if (this.nextSibling)
if (this.nextSibling != moving_item) this.parentNode.insertBefore(moving_item, this.nextSibling);
else
this.parentNode.appendChild(moving_item);
}
}
}
div.onmouseup = function() {
moving_item = null;
}
}
|