1. JavaScript / Говнокод #4045

    +144

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 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();
    			}
    		}
    	}

    наговнокодил

    Запостил: kubynek, 20 Августа 2010

    Комментарии (4) RSS

    Добавить комментарий