Hi,

Just noticed that if a draggable element uses a percentage in the
style for 'left', a couple things don't seem to work right.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://
www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://ussda.demosphere.com/common/js/ps1.8.2/
prototype.js" language="JavaScript" type="text/javascript"></script>
<script src="http://ussda.demosphere.com/common/js/ps1.8.2/
scriptaculous.js" language="JavaScript" type="text/javascript"></
script>
</head>
<body>
        <div id="d1" style="height:200px; width:300px; border:1px solid
green; position:relative;">
                <div id="d2" style="position:absolute; top:20px; left:20px; 
height:
20px; width:80px; border:1px solid gray;">
                        ABC 123
                </div>
        </div>
        <script type="text/javascript">
                new Draggable('d2',{revert:true});
        </script>
</body>
</html>

Notice the 'left:20px' style - this setting works ok. But if you try
it with 'left:20%' two odd things happen. The first is very quick in
this example and hard to see (but shows up more in my production
version) - at the start of the drag, there is a quick flash or wiggle
to left=0 then back again. This does not happen with a 'px' setting
only with a '%' setting. The second is the x,y location where it
reverts to - it always goes back to the numeric quantity in pixel
units, not the amount as a percentage. Wouldn't this be a bug?

I like to use percentage because my container element changes in size
if the browser window is resized or more options are chosen, etc. For
now however, I'm doing something like this:
    var wid=$('container').getWidth();
    var gleft=Math.round(wid*0.04); // left:4%
    gdiv.setStyle({position:'absolute', top:gtop+'px', left:gleft
+'px', width:'92%'});

With that it doesn't flash, and stays lined up as the drag and drop
operates, but of course it isn't reacting to dynamic changes in
container size as it would with a percentage.

Thanks,
--Jay
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to