Search In
• More options...
Find results that contain...
Find results in...

# slopps

Members

5

13

1. ## Draggable hitTest() Multiple Elements

If you look at the docs, one of the examples says //checks if at least 50% of the surface area of either element is overlapping: if (this.hitTest("#element3", "50%")) { //do stuff } therefore, it checks if 50% of either element is overlapping with the other
2. ## Draggable hitTest() Multiple Elements

You're right on both accounts. I was going to argue that it was being calculated anyway, but looking at the hitTest implementation I see that the area is only calculated if a ratio is passed. Perhaps it could become a new function, getOverlapArea or some such? It goes without saying, I defer to you as this is one of the most well made libraries I've used (thank you, btw!). Not sure if percentage would be as necessary since area could also be used for comparison between the drop-zones to determine dropspot "most-over." In the meantime, if anyone needs it you could get the overlap area of two elements with the following function (borrowed mostly from Draggables own hitTest implementation): *Note: this is not as backward compatible as gsaps own hitTest code, so use at your own risk: getOverlapArea = function(element1, element2) { if(element1.jquery) element1 = element1[0]; //convert from jquery to dom element if(element2.jquery) element2 = element2[0]; //convert from jquery to dom element var rect1 = element1.getBoundingClientRect(); var rect2 = element2.getBoundingClientRect(); var xOverlap = Math.max(0, Math.min(rect1.right , rect2.right) - Math.max(rect1.left, rect2.left)); var yOverlap = Math.max(0, Math.min(rect1.bottom, rect2.bottom) - Math.max(rect1.top, rect2.top)); return xOverlap * yOverlap; };
3. ## Draggable hitTest() Multiple Elements

I would actually argue that the hitTest() function should return a percentage rather than a boolean. The percentage would represent the overlap. 0 would mean no hit detected, anything above zero would represent the percentage of overlap. This would be useful when the item was touching multiple drop spots, when you want to know which drop spot the drag item was most over.
4. ## Draggable while scaling issue

Thank you! Seems to work very nicely even with the animation. I was initially not willing to change the transform origin due to other constraints, but they're easier to work around than this would otherwise be. I will note, if you rotate the drag item in addition to scaling, this stops working as expected. Fortunately I was able to talk my project managers into getting rid of the rotation. Thank you again
5. ## Draggable while scaling issue

Just finished making these two short codepens to demonstrate. This Draggable has a separate drag handle for the drag item, and on release it scales the entire drag item up. If you click on the handle while it's scaled up, I want the item to shrink back to it's normal size only while you are dragging. However, I can't figure out how to make it stay under your mouse where you actually clicked the handle. codepen 1 - instantly scale-down: http://codepen.io/anon/pen/VerJdJ codepen 2 - animate scale-down (this is what i would prefer if possible): http://codepen.io/anon/pen/JGOQYZ I thought maybe while scaling, if I could change the transform origin to where the mouse pointer is that would fix it, but unfortunately there are other coordinates in the application that rely on the transformOrigin being 50%, 50%. Is there a way to do this? Outcome: 1.) The item shrinks but is no longer under your mouse pointer. Even attempting to relocate it manually seems wonky (see codepen and other things I have tried below) Expected Outcome: 1.) the item shrinks and remains attached at the same offset to the mouse (appearing to scale at your mouse point, as if your mouse point were the origin) Things I have tried: 1.) in the onDragPress, I attempted to get the the mouse coordinates within the drag target's container and instantly relocate the item to those coordinates. That results in bazaar behavior. 2.) I've attempted calling myDraggable.update() before and during setting the scalethe scale animation, and onDragMove Any help is appreciated, thanks a lot in advance! Also, let me say: TimelineLite and TweenLite are some of the most incredible libraries I've used. Pushing my company to purchase a member license.
×