Jump to content
Search Community

paulmak

Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by paulmak

  1. Thank you for the quick reply, i'm not sure if im explaining it well.

    note: translating X is just being used as an example for simplicity, any property would be applicable.

    ​var targetlist = $(".sometarget");   // this could be multiple targets, an array.
     
    TweenMax.to ( targetlist, 1, { x : function( x ){  //insert unrelevant logic here    
    return x;  } } );  // I would like to get the current x value and send it through a function.
    
    ​The x would be different for each targetlist[number].

     

     

    ​TweenMax.to( targetlist, 1, { x: (this.vars.css.x + 100) } );  // This does not work even though this.vars.css.x does return a valid value.
    
    ​TweenMax.to( targetlist, 1, { x : ( this.target.position().left + 100 ) } );   //nor does this work, this.target.position().left returns a valid value.
    ​
    ​Is there a way to do this without doing it like the following-

    ​var targetlist = $( ".sometarget" );
    ​var targetlistlength = targetlist.length;
    ​var newtarget='';
    var targetx=0;
    ​for(var I = 0; I< targetlistlength;i++){
    newtarget=$(targetlist[ I ]);
    ​targetx = newtarget.position().left;
    // some logic done on targetx//
    ​TweenMax.to( newtarget, 1, {x: targetx } );
    }
    
    ​I would like to do something similar as to what is seen in Draggable instead, for example:

    ​Draggable.Create( $(".sometarget"), { snap: { x: function(endValue){ return (endValue / 2 )  * 2 ; } , y: function(endValue) { return (endValue / 2) * 2 ; } }  } );
    My goal is to simply tween a div background color(hsl format), increasing the hue by 120 every second, if hue goes over 360 I would like to subtract 360.

    TweenMax.to( $(".mytargetdiv") , 1 , { repeat:-1, backgroundColor: function(backgroundColor){ backgroundColor[0]+=120;if(backgroundColor[0] > 360){ backgroundColor-=360;} return backgroundColor  } } );
    //note: might need to process the backgroundColor value to strip an array[3] from the format hsl(x,y,z) and vise versa.
    
    Is Draggable's snap just an exception or can this be done for tweenmax vars?
  2. Hello,
    Within a draggables snap "vars" you can pass the x and y values as  "endValue" to a function for processing, how would you do this with other variables?
     
    For example:

    TweenMax.to(target,1,{x:function(x){return x+10;}});
    ​or something like
    TweenMax.to(target,1,{x:this.vars.x+10});

     
    I'm aware you can use relative values such as "+=10", is there a way to pass the variable without referencing something like "target.position().left" (such for when "target" is an array)?


    ​Thank you.

  3. Thank you for your suggestions, I've tried both but with no success. After playing around some more, I've simply implimented a global array[x,y] that onPress() would store the caller(x) and parent(y) and disable the parent[y], then onRelease() would cycle through the array[x][y] to match the caller with the [x] and enable the parent[y], afterwards slicing the array.
     
     
    Made a codepen demonstrating this issue and my solution...

    See the Pen wGBNMx by anon (@anon) on CodePen

      (drag the child red box out of the parent blue box)

    ​Please do let me know if a better solution exists.

  4. Hello,

     ​          How would one disable an initial parent from dragging while dragging a child, if both are draggable. Upon dragging this specific child, it detaches from the parent in order to be ready for a new parent later ( during onDragStart), but both the old/initial parent and "child" are registered as actively dragging simultaneously. Is there a gsap variable for this?

    Outside of this plugin(draggable) I would approach a similar issue by using a mouse event and seeing which element is on the top layer and allowing only that layer to do whatever changes.

    ​I could disable the parent during the onPress event of the child if its parent is draggable, and then upon the onRelease of a child I could loop through all possible parents(might not have same parent anymore)  and enable them (thus finding the one disabled). I don't think this is the proper solution though...

     

    Thanks in advance for any help!
     

×
×
  • Create New...