- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
Draggable.prototype.move = function(event){
var event = Runic.event.getEvent(event),
mLeft = (this.direction == 'both' || this.direction == 'horizontal') ? (Runic.event.getEventX(event) - this.mdiffX) : this.element.offsetLeft,
mTop = (this.direction == 'both' || this.direction == 'vertical') ? (Runic.event.getEventY(event) - this.mdiffY) : this.element.offsetTop,
//get cursor position
curx = Runic.event.getEventX(event),
cury = Runic.event.getEventY(event);
if (this.box) {
if (this.direction == 'horizontal' || this.direction == 'both') {
if (curx > this.fromX && curx < this.toX) {
this.element.style.left = mLeft + 'px';
} else if (curx <= this.fromX && this.direction) {
if (this.boxCSSPosition == 'relative' || this.boxCSSPosition=='absolute') {
this.element.style.left = 0 + 'px'
this.element.style.right = 'auto'
} else {
this.element.style.left = this.box.offsetLeft + 'px'
}
} else if (curx >= this.toX) {
if (this.boxCSSPosition == 'relative' || this.boxCSSPosition=='absolute') {
this.element.style.right = 0 + 'px'
this.element.style.left = 'auto'
} else {
this.element.style.left = this.box.offsetLeft + this.box.clientWidth - this.element.clientWidth + 'px'
}
}
}
if (this.direction == 'vertical' || this.direction == 'both') {
if (cury > this.fromY && cury < this.toY) {
this.element.style.top = mTop + 'px';
} else if (cury <= this.fromY) {
if (this.boxCSSPosition == 'relative' || this.boxCSSPosition=='absolute') {
this.element.style.top = 0 + 'px';
this.element.style.bottom = 'auto'
} else {
this.element.style.top = this.box.offsetTop + 'px'
}
} else if (cury >= this.toY) {
if (this.boxCSSPosition == 'relative' || this.boxCSSPosition=='absolute') {
this.element.style.bottom = 0 + 'px';
this.element.style.top = 'auto'
} else {
this.element.style.top = this.box.offsetTop + this.box.clientHeight - this.element.clientHeight + 'px'
}
}
}
} else {
this.element.style.left = mLeft + 'px';
this.element.style.top = mTop + 'px';
}
//run callback funciton
if (this.onDrag != undefined && typeof this.onDrag.func == 'function') {
if (this.onDragCount < this.onDrag.count || this.onDrag.count == 0) {
this.onDragCount++;
this.onDrag.func();
}
}
}