Jump to content
GreenSock

moleboy

Members
  • Posts

    4
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

moleboy's Achievements

Newbie

Newbie (1/14)

1

Reputation

  1. Hi again, I thought I was done with this one but wondered if I could refine it even better. The snap is working great now (thanks for your input). As TweenMax is now adding inline styles for position I wanted to know if there was a way to revert back to the original styles when the items are dragged off the targets - at the moment they are all heading back to the same spot? http://codepen.io/antpearson/pen/IaAfl I tried using the clearProps:"all" in the animation routine but this causes the object to return abruptly. I guess I'm wondering if there is a way to animate the TweenMax locations off gradually - returning the item to its original absolutely positioned location? Either that or a way to store the original positioning somehow on each dragged object so it can be recalled and added to the TweenMax animation that sends it back? thanks again
  2. Hi Jack, That works a treat, thanks for making that clear. I knew I was getting in a muddle somewhere but couldn't work out where. Looking forward to the new tool - it sounds like it will be super handy. This Draggable utility class is much easier to deal with than the jQueryUI/Touch Punch implementation of Drag & Drop!
  3. Thanks guys for responding to my query. Peleg, I looked at that codepend example but it only checks for points on one axis. Carl, I've taken a bit of time to put a codepen together. I'm not trying to force a livesnap now but used the codepen example that you guys had setup with the overlap threshold as a basis. It's here http://codepen.io/antpearson/pen/zlxvg The tween into position on the target isn't quite going to plan - I think it's because of the absolute positioning on the drag items. Any idea how I could get round that? And any idea how I could send the drag items back to their starting positions when dragged off the targets? It's kind of working but I think it won't if I sort out the snapping properly. At some point I'm going to need to handle the logic that tests if the correct drag item is on the correct target. Thanks again for your help
  4. Hi there, In the demo for Draggable you show livesnap snapping to a grid. I wondered if it was possible to have an array of x and y values and cause the dragged item to snap to the closest one when near? The livesnap appears to only work with either a range of x values or y values, not specific points in a container. Also I'd like to be able to drag until I get close to a location and then it snaps. In the flash days I used pythagarus to work out the distance. I tried doing that in the ondrag function like below but it doesn't want to snap despite it getting the console log. Any guidance would be much appreciated. Thanks! onDrag:function(e) { for(var i=0; i<targetLocations.length;i++){ var xDistanceFromPoint = Math.abs(this.x - targetLocations[i].x); var yDistanceFromPoint = Math.abs(this.y - targetLocations[i].y); var distanceFromPoint = Math.sqrt((xDistanceFromPoint*xDistanceFromPoint)+(yDistanceFromPoint*yDistanceFromPoint)); if(distanceFromPoint < 50){ console.log("snapped"); this.y = targetLocations[i].y; this.x = targetLocations[i].x; } } }
×