r2806 - + Fixed offset problem bug.

r2806 - + Fixed offset problem bug.


Author: vtGavin
Date: Thu Jun 18 08:58:27 2009
New Revision: 2806
Modified:
branches/dev/positionTo/demos/positionTo/default.html
branches/dev/positionTo/ui/utils.positionTo.js
Log:
+ Fixed offset problem bug.
Modified: branches/dev/positionTo/demos/positionTo/default.html
==============================================================================
--- branches/dev/positionTo/demos/positionTo/default.html    (original)
+++ branches/dev/positionTo/demos/positionTo/default.html    Thu Jun 18
08:58:27 2009
@@ -81,30 +81,13 @@
</div>
</div>
-<!-- Sample page content -->
-<div class="hiddenInViewSource" style="padding:20px;">
-

Sed vel diam id libero <a href="http://example.com">rutrum
convallis</a>. Donec aliquet leo vel magna. Phasellus rhoncus faucibus
ante. Etiam bibendum, enim faucibus aliquet rhoncus, arcu felis ultricies
neque, sit amet auctor elit eros a lectus.



-<form>
-    <input value="text input" /><br />
-    <input type="checkbox" />checkbox<br />
-    <input type="radio" />radio<br />
-    <select>
-        <option>select</option>
-    </select><br /><br />
-    <textarea>textarea</textarea><br />
-</form>
-</div>
-<!-- End sample page content -->
-
-</div><!-- End demo -->
-
<div class="demo-description">


!!! positionTo description here !!!



-</div><!-- End demo-description -->
+</div>
</body>
</html>
Modified: branches/dev/positionTo/ui/utils.positionTo.js
==============================================================================
--- branches/dev/positionTo/ui/utils.positionTo.js    (original)
+++ branches/dev/positionTo/ui/utils.positionTo.js    Thu Jun 18 08:58:27 2009
@@ -16,7 +16,9 @@
    // to positionTo without corresponding reverts...
    
    // !!! TODO: remember initial positionTo or checkpoint the revert on each
one
-    
+
+
+ // !!! TODO: create a page resize handler to adjust the absolute
position of the positionable elements
var positionTo_handlers = {
mouseMove: function(){
        // !!! TODO: implement mouse following
@@ -30,6 +32,8 @@
// then: estimate the target node's position by comparing their
relative absolute offsets
if ($targetElem.parent().length)
{
+ $targetElem.parent().css('position', 'relative');
+
var targetParentOffset = $targetElem.parent().offset();
targetPosition = {
top: targetPosition.top - targetParentOffset.top,
@@ -49,13 +53,13 @@
// if: the positionable element has a previous sibling
// then: use that for the ordinal sibling
- if (this.prev().length > 0)
+ if (this.prev().length)
{
    $sibling_prev = this.prev();
}
// else if: it has a subsequent sibling
// then: likewise, use that for the ordinal sibling
- else if (this.next().length > 0)
+ else if (this.next().length)
{
    $sibling_next = this.next();
}
@@ -82,12 +86,6 @@
this.css('display', 'block')
.css('position', 'absolute');
- /*
- // !!! arbitrarily position the element
- this.css('left', targetPosition.right + 'px')
- .css('top', targetPosition.bottom + 'px');
- */
-
var positionableOffset_x = 0,
positionableOffset_y = 0,
array_positionableAnchor_chunks = positionableAnchor.split(' '),
@@ -110,7 +108,7 @@
    // now, figure out the horizontal positionable offset
    switch (array_positionableAnchor_chunks[1])
    {
-         case 'middle':
+         case 'center':
            positionableOffset_x -= (this.outerWidth() / 2);
            break;
            
@@ -137,7 +135,7 @@
    // figure out the horizontal target offset
    switch (array_targetAnchor_chunks[1])
    {
-         case 'middle':
+         case 'center':
            positionableOffset_x += (targetPosition.right -
targetPosition.left) / 2;
            break;