Jump to content
Search Community

admin web

Members
  • Posts

    13
  • Joined

  • Last visited

Posts posted by admin web

  1. 22 hours ago, OSUblake said:

    Another approach that requires a little more work, but is more flexible. It finds the closest point on a path, and does not require a proxy element.

     

    See the Pen RBwWWm by osublake (@osublake) on CodePen

     

     

    A couple threads on the technique.

     

    Thanks for the reply.

     am trying as per your code but still svg not drag along the path.

     

     

     

  2. 22 hours ago, Rodrigo said:

    Hi, I had to deal with something like this about a month ago.

     

    First you forgot to include jQuery in the pen's resources.

     

    Then in order to enforce the right bounds, you need to find the dimensions of the path you want to use as track using getBBox() and use those in the Draggable instance, but for that you have to line up the patch and the track correctly, otherwise it looks a bit funny:

     

    
    var bounds = document.getElementById("line2").getBBox();
    
    var R = Draggable.create( "#patch_218_454", {
      type: "x,y",
      bounds:{
        minX: 0, maxX:bounds.width,
        minY:-5, maxY:bounds.height - 5
      },
      onDrag: function (e) {
        console.log(e.offsetX);
        console.log(R);
      }
    });

     

    Then in order to limit the patch movement to the path you want to use, don't use the Draggable instance on the patch but in a dummy object, then simply trigger the instance using the patch and update an independent GSAP instance using the onDrag callback. This sample from one of our heroes @Diaco shows how to do that:

     

    See the Pen aOzeNR by MAW (@MAW) on CodePen

    Here in the docs, more specifically in the config object properties you'll find the trigger property.

     

    https://greensock.com/docs/Utilities/Draggable

     

    Hope this helps.

    Happy Tweening!!!

    Thanks for the reply

×
×
  • Create New...