alum
3 Mar 2007, 10:35 AM
I mean .. when I have a v-scrollbar in browser . I scroll it to the part what i want .may be the value of document.documentElement.scrollTop is 1000 now . then I click the button to show a dialog , I can see that the dialog aways at the top of document . but i need it be shown at the middle of right now position .
when i check the code i find some answer .It's a method in class: BasicDialog:
constrainXY
i insert some code ,i bold it .like this :
----------------------------
var x = this.xy[0], y = this.xy[1];
var w = this.size.width, h = this.size.height;
var vw = this.viewSize[0], vh = this.viewSize[1];
var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft || 0;
var scrollY = document.documentElement.scrollTop || document.body.scrollTop || 0;
var moved = false;
if(x-scrollX + w > vw){
x = vw - w;
moved = true;
}
if(y-scrollY + h > vh){
y = vh - h;
moved = true;
}
-------------- code mark cannot work fine with bold mark -----------------
in the method getCenterXY , you did that (you use a flag to make sure if offsetScroll)
so .may be you design that for some reasons I don't know .may be that's not a bug . but it make me in puzzle . give me some tips , Jack .. ^O^
fixedcenter is only work when the show button is a single object in a document.
that 's all i hacked :(
constrainXY : function(){
if(this.constraintoviewport !== false){
if(!this.viewSize){
this.viewSize = [YAHOO.util.Dom.getViewportWidth(), YAHOO.util.Dom.getViewportHeight()];
}
var x = this.xy[0], y = this.xy[1];
var w = this.size.width, h = this.size.height;
var vw = this.viewSize[0], vh = this.viewSize[1];
var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft || 0;
var scrollY = document.documentElement.scrollTop || document.body.scrollTop || 0;
var moved = false;
if(x-scrollX + w > vw){
x = vw - w +scrollX;
moved = true;
}
if(y-scrollY + h > vh){
y = vh - h +scrollY;
moved = true;
}
if(x-scrollX < 0){
x = scrollX;
moved = true;
}
if(y-scrollY < 0){
y = scrollY;
moved = true;
}
//alert(moved+":"+y);
if(moved){
this.xy = [x, y];
if(this.isVisible()){
this.el.setLocation(x, y);
this.adjustAssets();
}
}
}
},
It's still has problem when i drag the dialog
when i check the code i find some answer .It's a method in class: BasicDialog:
constrainXY
i insert some code ,i bold it .like this :
----------------------------
var x = this.xy[0], y = this.xy[1];
var w = this.size.width, h = this.size.height;
var vw = this.viewSize[0], vh = this.viewSize[1];
var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft || 0;
var scrollY = document.documentElement.scrollTop || document.body.scrollTop || 0;
var moved = false;
if(x-scrollX + w > vw){
x = vw - w;
moved = true;
}
if(y-scrollY + h > vh){
y = vh - h;
moved = true;
}
-------------- code mark cannot work fine with bold mark -----------------
in the method getCenterXY , you did that (you use a flag to make sure if offsetScroll)
so .may be you design that for some reasons I don't know .may be that's not a bug . but it make me in puzzle . give me some tips , Jack .. ^O^
fixedcenter is only work when the show button is a single object in a document.
that 's all i hacked :(
constrainXY : function(){
if(this.constraintoviewport !== false){
if(!this.viewSize){
this.viewSize = [YAHOO.util.Dom.getViewportWidth(), YAHOO.util.Dom.getViewportHeight()];
}
var x = this.xy[0], y = this.xy[1];
var w = this.size.width, h = this.size.height;
var vw = this.viewSize[0], vh = this.viewSize[1];
var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft || 0;
var scrollY = document.documentElement.scrollTop || document.body.scrollTop || 0;
var moved = false;
if(x-scrollX + w > vw){
x = vw - w +scrollX;
moved = true;
}
if(y-scrollY + h > vh){
y = vh - h +scrollY;
moved = true;
}
if(x-scrollX < 0){
x = scrollX;
moved = true;
}
if(y-scrollY < 0){
y = scrollY;
moved = true;
}
//alert(moved+":"+y);
if(moved){
this.xy = [x, y];
if(this.isVisible()){
this.el.setLocation(x, y);
this.adjustAssets();
}
}
}
},
It's still has problem when i drag the dialog