PDA

View Full Version : Fix for dropInBox bug



Jacques Gourdon
04-10-2012, 08:27 AM
1) Script Title: Positive offset for resting place

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/dropinbox.htm

3) Describe problem: When the variable pos: in the html file has negative values or 'center', that works fine.
But when positive values, the box does not show.
I edited the (pos) function in the dropincontentbox.js between the tests on val<0 and val=='center', to add a test on positive values:
Original:
*****************
[CODE]
if (val<0){ //if position value is negative, it means box should be offset from right edge of window
finalpos[i]=(i==0)? winmeasure.left+winmeasure.w-boxmeasure.w+val : winmeasure.top+winmeasure.h-boxmeasure.h+val
}
else if (val=="center"){
finalpos[i]=(i==0)? winmeasure.left+winmeasure.w/2-boxmeasure.w/2 : winmeasure.top+winmeasure.h/2-boxmeasure.h/2
}
******************
Corrected:
*****************
if (val<0){ //if position value is negative, it means box should be offset from right edge of window
finalpos[i]=(i==0)? winmeasure.left+winmeasure.w-boxmeasure.w+val : winmeasure.top+winmeasure.h-boxmeasure.h+val
}
else if (val>0){ //if position value is positive, it means box should be offset from left edge of window
finalpos[i]=(i==0)? val : val
}
else if (val=="center"){
finalpos[i]=(i==0)? winmeasure.left+winmeasure.w/2-boxmeasure.w/2 : winmeasure.top+winmeasure.h/2-boxmeasure.h/2
}
[CODE]
******************************
And the box shows with offsets from top and left when val is positive.