Jump to content


  • Posts

  • Joined

  • Last visited


0 Newbie
  1. I have exactly the same question. I need to drag some small elements inside a horizontally scrollable container, and I want that container to scroll automatically when element or mouse pointer is somewhere near left or right bound. Here's codepen: http://codepen.io/ulmix/pen/EaWjZG Algo: onDrag: 1) check where the mouse pointer is currently: 1a: if near bounds, go to 2 1b: if not, clearInterval(scrolling) 2) check if we're scrolling already. If not, then start setInterval, where I change scrollLeft of container, and trying to change draggable element position and update() it. onDragEnd: stop scrolling if it is in process. Unfortunately, update() behaves VERY strange here: element jumps all over the place. Why? I can't understand. And considering your "It'd be a bit tricky because it'd have to be able to sense any and all nested containers" - that's not right. Solution is simple: check only parent container by default, and give us option to set custom element as "scroll container". So please, GSAP developers, hear me: the autoscroll option for your Draggable plugin is very desirable! ===== UPDATE, additional questions. tried to implement more simple autoscroll, based on mousemove instead of setInterval - just like jQuery UI Draggable works. Here's what I've got: 1. http://codepen.io/ulmix/pen/KwWpbB- implementation for XY drag. Just works. 2. http://codepen.io/ulmix/pen/NPpqoY- implementation for X drag (" type: 'x' " added) - strange behaviour, drag element jumps far forward when trying to scroll 3. http://codepen.io/ulmix/pen/pveJYx- implementation for X drag (" lockAxis: true " added) - works normally. So, the question is: why option 2 - with type: 'x', but without lockAxis: true - is not working properly?