Jump to content
GreenSock

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

GRDC

Members
  • Posts

    31
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

2,126 profile views

GRDC's Achievements

Newbie

Newbie (1/14)

1

Reputation

2

Community Answers

  1. GRDC

    Unit testing

    Anyone have any experience setting up unit testing with GSAP, specifically draggable? I've seen Selenium employed for web testing
  2. I'm trying to get the x,y coordinates of a touch event in Safari. I'm currently using event.offsetX and event.ofsetY, which is functioning in all browsers except safari. Is there one accepted value across all browsers that I should be using?
  3. Is it possible to change the onClick function by simple assignment...such as: draggable[0].onClick = function(){alert('this is the new click function');}
  4. I guess what I was toying with was calculating and resetting the top/left values of the two objects "during" drag. Doing so resulted in the top left values becoming increasingly large, and not staying with the cursor. What I've opted to do is calculate the modulus (based on the fake origin) to which the object must snap prior to the draggable's creation, and change that value when the window resizes. Due to time constraints, this will have to suffice for now.
  5. Diaco, thanks for the help on this. I think I'm really close (at least to understanding). When I change the css of the origin to 49%, the snapping is off. Is it possible to calculate the snapping during (or on start of) drag, and respond to those values dynamically? One scenario that might arise is if the user elects to change the position of the origin (which is possible in my application through a drag on the red box).
  6. I'd like the green box to snap to the red box (at percent intervals based on the red box) during drag. In my efforts to set the green box's position during drag (either to pixels or percent), once I drag, it goes nuts and drags far beyond the cursor. I'm using object.position() to get the coordinates for snapping in these cases, which have proven unsuccessful. I'm guessing that my this.x and this.y values are negative due to absolute positioning, and clearProps after each dragEnd. What I may resort to: (pseudo) before drag: see how far the dragged object is from the origin object. snap: snap to the modulus of the draggable object vs origin object Thus far, I have not been successful at calculating the dragged object's current position and (re)setting its coordinates.
  7. My draggable object always starts with this.x and this.y at zero. So, the second that I drag to the left or top, the x,y values become negative. I noticed that yours does not behave in this way. Is there something in your code that makes the draggable instance begin at this.x,this.y coordinates relative to their container, and not themselves?
  8. Thanks for the replies guys. Diaco, I forked your pen, and monkeyed for a while. I'm struggling with programatically setting the top/left percentages during drag. Is this type of thing possible? In the pen, what I'd like to accomplish is that the green knob snaps to the red knob (origin), regardless of where that knob is on the screen. I'd ideally like to set the object's percentages during drag so as to be able to reference them via means other than the transform. http://codepen.io/anon/pen/xbvxbM?editors=001 Another idea I toyed with is using the snap function to get the coordinates of the origin object, and using a modulus to snap to a grid based on the those values. This may be enough, as I don't need to do anything fancy in the onDrag method. Any thoughts?
  9. The dragged object's top/left are stored as percentages (due to resizing of container that happens regularly). There is one object on the screen that is, in essence, the origin for snapping. It can reside at any arbitrary location within the container. I wish to snap to percentage intervals (say every 2%) based on the object that is considered the "origin" within that same container.
  10. Thanks for the replies. I'm using top, left by percentages to store the object's position. Blake, would you demonstrate a fork in your grid layout with top/left as percentages of their parent? I'm having trouble getting it to work.
  11. I have two objects on the screen. I've had success in snapping to a grid based on the draggable element. Is snapping to a grid based on another element (or given coordinates) possible with GSAP api? Would rounding and setting the dom element's position programatically in the drag() function be an acceptable workaround?
  12. I'm attempting to allow dragging of SVG elements on the screen, and store their coordinates as percentages in case of screen resize. Since the type: "x,y" draggable uses transform, I'm converting the number of transformed pixels at the end of the drag. All seems to be working, except the svg element itself does not update its position once it is dropped. Here's a codepen to demonstrate: http://codepen.io/anon/pen/yyZLja Any help in debugging is appreciated.
  13. Good replies all. I first went with the simple swap, but came to realize that I needed to use apply() to prevent default behaviors of the event. In the original onClick function, I was referencing variables which were local to the method which created the draggable object. How can I pass variables into the onClick function from the draggable object. Maybe something like this:? }, onClick: defaultClick(varHere) ?? :EDIT: Noticed the onClickParams is a piece of the framework, and passed in the locally scoped variable through that method.
×