Changeset 7770

Show
Ignore:
Timestamp:
03/22/07 23:13:40 (22 months ago)
Author:
elazutkin
Message:

dnd2: added correct before/after calculations

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/dnd2/source.js

    r7769 r7770  
    44dojo.require("dojo.event.*"); 
    55dojo.require("dojo.html.style"); 
     6dojo.require("dojo.html.layout"); 
    67 
    78dojo.require("dojo.dnd2.selector"); 
     
    4243        this.mouse_down = false; 
    4344        this.target_anchor = null; 
     45        this.target_box = null; 
    4446        this.before = true; 
    4547        // states 
     
    6466                        // calculate before/after 
    6567                        var before = false; 
    66                         /* 
    67                         THIS IS A PLACEHOLDER! 
    68                          
    6968                        if(this.current){ 
     69                                if(!this.target_box){ 
     70                                        this.target_box = { 
     71                                                xy: dojo.html.getAbsolutePosition(this.current, true), 
     72                                                wh: dojo.html.getBorderBox(this.current) 
     73                                        }; 
     74                                } 
    7075                                if(this.horizontal){ 
    71                                         before = (e.clientX - this.current.clientLeft) < (this.current.offsetWidth / 2); 
     76                                        before = (e.pageX - this.target_box.xy.x) < (this.target_box.wh.width / 2); 
    7277                                }else{ 
    73                                         before = (e.clientY - this.current.clientTop)  < (this.current.offsetHeight / 2); 
    74                                 } 
    75                         } 
    76                         */ 
     78                                        before = (e.pageY - this.target_box.xy.y) < (this.target_box.wh.height / 2); 
     79                                } 
     80                        } 
    7781                        if(this.current != this.target_anchor || before != this.before){ 
    7882                                this.markTargetAnchor(before); 
     
    189193                } 
    190194                this.target_anchor = this.current; 
     195                this.target_box = null; 
    191196                this.before = before; 
    192197                if(this.target_anchor){ 
     
    198203                this.removeItemClass(this.target_anchor, this.before ? "Before" : "After"); 
    199204                this.target_anchor = null; 
     205                this.target_box = null; 
    200206                this.before = true; 
    201207        },