Jump to content
GreenSock

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

Antdev

Members
  • Posts

    59
  • Joined

  • Last visited

Antdev's Achievements

  1. Thanks Jack. Yes the delta Values were not the same as the other physics libraries emitted but adding the offset seems to resolve things for the dragging. I do appreciate these values being wrong are not a gsap issue but I want to use gsap as part of the solution and know you peeps are experts in all things related to this so it was a desperate post to try and move my forward in a moment of need.
  2. Just to update, InteractJS didn't turn out to be a good solution for the multitouch - there is a known issue where a finger on the screen breaks all other interactions. So I have aborted using that.
  3. Thank you for getting back to me Jack In this codepen you can see the issue as follows: https://codepen.io/antdev/pen/ExQXKLG Drag the square to the right hand side Let go of your mouse and click away from the square Drag the square again a short distance. Instead of the square dragging a short distance it instead jumps back to its initial position and is offset a short distance from there The gsap connection - I am moving the square with gsap. I wanted to know why it was jumping back to the initial position and offsetting from there. Something to do with how it does transforms behind the scenes. I would love to use Draggable but I need rotation and pinch zoom too which gsap doesn't do unfortunately. ContactJS is helping me capture all the touch gestures but I want to use gsap for the movement. I have a full Greensock Membership so was hoping you could help me as you are always reallly helpful in my times of need. Thanks Ant
  4. I have saved the last x position in a variable and then every time there is a new pan I add this value to the offset. This appears to stop the jumping. Not sure if it is the best solution that gsap offers for this scenario? let lastX = 0; let lastY = 0; var pointerListener = new PointerListener(domElement, options); domElement.addEventListener('pan', function(event){ // transform var x = lastX + event.detail.global.deltaX; var y = lastY + event.detail.global.deltaY; gsap.set(domElement, {x:x, y:y}); }); domElement.addEventListener('panend', function(event){ lastX = lastX + event.detail.global.deltaX; lastY= lastY + event.detail.global.deltaY; }); https://codepen.io/antdev/pen/KKQqNvX?editors=1011
  5. Thanks Jack - apologies I had listed the wrong codepen demo - I have updated it so you can see the issue now. It seems like the first time you drag it, it works correctly. Then if you remove your finger or release mouse then do it again - it jumps.
  6. I have been jumping from one physics library to the next trying to get multitouch dragging working on a multitouch screen with multiple users. I initially tried HammerJS but that had issues, then I tried InteractJS and that didn't work if you put a finger anywhere on the table then tried to interact with the modals that the users can move around. I am now trying ContactJS which is proving the best of the lot - it is a fork of Hammer. https://biodiv.github.io/contactjs Anyway my app will have dragging (panning), rotation and pinch zoom but initially I am just trying to get the panning working with gsap. I have included my codepen. The first time you drag the square it works fine. Subsequent drags are resulting in the square jumping to a position away from the finger. What appears to be happening is when I subsequently try to move it, it uses the squares original initial position still and offsets against this. Hence the jump? Well that is my guess. var x = event.detail.global.deltaX; var y = event.detail.global.deltaY; gsap.set(domElement, {x:x, y:y}); global.deltaX : Number, // traveled distance along the x-axis in px, whole contact duration global.deltaY : Number, // traveled distance along the y-axis in px, whole contact duration live.deltaX : Number, // traveled distance along the x-axis within the last 100ms in px live.deltaY : Number, // traveled distance along the y-axis within the last 100ms in px I tried the following too which stops the jumping on subsequent moves but it moves it way too much and it flies off the screen var x = event.detail.live.deltaX; var y = event.detail.live.deltaY; gsap.set(domElement, {x:"+=" + x, y:"+=" + y}); I can see after dragging the square to the right it has the following transform If I then just drag it a few pixels to the left it jumps back to its original position and offsets a few pixels from this original position to the left. So how does gsap correctly translate the subsequent movements? I really need to get this working asap so any help would be much appreciated. Thanks Ant
  7. I worked it out - doh!! gsap.set("#knob", { rotation: 0 });
  8. Hello I am trying to reset the rotation of a draggable that rotates. Hope you don't mind me grabbing one of your examples to amend to show you my issue. I have different levels in my game that use the same draggable ring. So for a new level I want to reset the rotation to zero. My attempts are failing. I am sure I am just doing it wrong. I am trying to do it using gsap.set(draggable, {rotation: 0}); Any help much appreciated. Thanks Ant
  9. Unfortunately yes it is a requirement and I am on the home run now fortunately. I will think twice next time about using typescript with gsap
  10. Thanks again Blake - I need to read up more on typescript as my lack of knowledge has really hampered me with this project. However I believe the advantages it has brought me in organising all the data that populates my apps was worth the pain I am suffering. It is just frustrating when you are up against the clock to get stuck for days on a line of code
  11. Anyway yeah I agree your solution is the best option and I will go with that as I have several apps with this kind of stuff in it and I don't want to get stuck again
  12. Ah OK thanks Blake tho interestingly I have no problem with the following in my app baseTl: gsap.timeline(), animation:gsap.timeline(), then in mounted I have this.baseTl = gsap.timeline({ paused: true }); this.animation = gsap .timeline({ repeat: -1, paused: true }) .add(this.baseTl.tweenFromTo(1, 2));
  13. Thank you Blake for your dedication to helping me solve this conundrum. I think I will stick with the solution setting it as an array as that feels cleaner to me. myDraggable: Array<Draggable>(), Hopefully there is no issue doing it this way? Many thanks Paul
  14. Thanks Blake - much appreciated.
  15. OK I have made some progress setting myDraggable to an Array of Draggable as I am aware the Draggable.create returns an array Then I needed to pass this.myDraggable[0] in my updateProgress function call Still confused why the other way didn't work that worked in CodeSandbox didn't work in my app instance but at least now I can happily disable my draggable Be still interested if you so look at the zip I uploaded if you discover anything but either way thank you very much for your timely responses. data() { return { myDraggable: Array<Draggable>(), proxy: document.createElement("div"), }; }, mounted() { this.init(); }, methods: { init: function () { this.myDraggable = Draggable.create(this.proxy, { trigger: ".wrapper", type: "x", inertia: true, resistance: 0.75, dragResistance: 0.75, onDrag: () => this.updateProgress(this.myDraggable[0]), }); }, updateProgress(myDraggable) { var debug = document.getElementById("debug"); debug.innerHTML = "draggable.x: " + myDraggable.x; }, disableDraggable() { this.myDraggable[0].disable(); }, },
×