Results 1 to 6 of 6

Thread: relative movement animation

  1. #1
    Join Date
    Apr 2009
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default relative movement animation

    I want to animate this location function, any help?

    <code>
    function setPosition (id,topY,leftX) {
    var layerRef = document.getElementById(id);

    if (layerRef==null) return;

    if (layerRef.style.left && layerRef.style.top) {
    layerRef.style.left = leftX+'px';
    layerRef.style.top = topY+'px';
    }
    if (layerRef.style.posLeft && layerRef.style.posTop) {
    layerRef.style.posLeft = leftX;
    layerRef.style.posTop = topY;
    }
    }
    </code>

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

  3. The Following User Says Thank You to vwphillips For This Useful Post:

    jpweeks (04-19-2009)

  4. #3
    Join Date
    Apr 2009
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    The problem i'm having is identifying the div's current position to set as the variable for the animation starting point. I want the div's position to not be stagnant, so the javascript needs to talk to the div to find its current position, then proceed to the designated absolute position on the page which is explicitly identified in the script.

  5. #4
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    use layerRef.offsetTop and layerRef.offsetLeft to find the values.
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@§†ê® §©®¡þ† /\/\@|{ê®
    There are 10 kinds of people in the world, those that understand binary and those that don't.

  6. The Following User Says Thank You to Master_script_maker For This Useful Post:

    jpweeks (04-15-2009)

  7. #5
    Join Date
    Apr 2009
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    function Move(){
    var obj=document.getElementById('places');
    var srt=findPos(obj);
    zxcBAnimator('top',obj,srt,-350,2000);
    }

    function findPos(obj) {
    var obj=document.getElementById('places');
    var curtop = 0;
    if (obj.offsetParent) {

    do {
    curtop += obj.offsetTop;
    }
    while (obj = obj.offsetParent);
    return [curtop];
    }


    I'm using this movement animation script 'zxcBAnimator', and trying to identify the position start variable with the 'findPos' function. I'm not sure why this is not working.

  8. #6
    Join Date
    Apr 2009
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    nm...I've got it working now

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •