question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Autoscroll timeline when dragging an item when close to left/right borders

See original GitHub issue

Is your feature request related to a problem? Please describe. I´m trying to move/drag items from left to right, but it is limited by the visible time, between defaultTimeStart and defaultTimeEnd. But I´m trying to drag/move those items out of the boundaries when the moving/dragging item is closed to the left/right borders.

Describe the solution you’d like

  • Start moving/dragging item close to the left or right border.
  • Once the startTime/endTime of item is close enought (sensibleAreaFromBorder millis) to a border, the timeline changes time (timeJump in millis) defaultTimeStart/defaultTimeEnd towards the past/future.
  • The item also makes a jump equivalent to the time moved in the visible timline without loosing the dragging/moving state so the user can keen moving to past/future if repeats the process.

Describe alternatives you’ve considered I tried to implement it by myself using the moveResizeValidator() function, I replaced the content of this function in the demo-custom-items in the latest beta branch. By using the following code in the moveResizeValidator() function you can get the intended feature, but very often I get the items disappearing from the timeline, and after stop moving/dragging (onmouseup) it appears again in a different location of the mouse. You can replicate this using my solution with the following code:

` moveResizeValidator = (action, item, time, resizeEdge, newGroupIndex) => {

if (action === 'move' && this.timelineComponent && this.timelineComponent.current && this.timelineComponent.current.state) {  
  const stateFrom = this.timelineComponent.current.state.visibleTimeStart;  
  const stateTo = this.timelineComponent.current.state.visibleTimeEnd;  

  const zoomMinutes = Math.round((stateTo - stateFrom) / 60000);  
  const MOVEMENTWINDOW = 4;  

  // 5 % Percent of the window area will be used for activanting the move Time window, will change base on zoom level  
  // For Zoom level 2 hours, area 6 minutes  
  const percetageTolerance = (zoomMinutes * 5) / 100;  
  const timeBorderArea = Math.round(percetageTolerance * 60000);  
  const duration = item.end - item.start; 

  // Moves to right  
  if (time + duration > stateTo - timeBorderArea) {  
    const newFrom = stateFrom + (timeBorderArea * MOVEMENTWINDOW); // Moves 20 percent  
    const newTo = stateTo + (timeBorderArea * MOVEMENTWINDOW); // Moves 20 percent  

    // onChangeVisibleTime(newFrom, newTo);  
    console.log(moment(newTimeForItem).format('HH:mm') + "  Moved with window range");  
    const newTimeForItem = time + (timeBorderArea * MOVEMENTWINDOW);  
    this.timelineComponent.current.updateScrollCanvas(newFrom, newTo); 
    return newTimeForItem;  
  }  

  // Moves to left  
  if (time < stateFrom + timeBorderArea) {  
    const newFrom = stateFrom - (timeBorderArea * MOVEMENTWINDOW); // Moves 20 percent  
    const newTo = stateTo - (timeBorderArea * MOVEMENTWINDOW); // Moves 20 percent  

    // onChangeVisibleTime(newFrom, newTo);  
    this.timelineComponent.current.updateScrollCanvas(newFrom, newTo);  
    return time - (timeBorderArea * (MOVEMENTWINDOW));  
  }  
  }  
console.log(moment(time).format('HH:mm')); 
return time;  

} `

Quick demo with the code above in the latest beta Scroll-timeline-while-moving-ite

Bug encountered very often since the library was not intender for this feature Bug-when-moving-item-and-timelin

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:5

github_iconTop GitHub Comments

1reaction
davidbejarcacerescommented, Oct 8, 2022

@vagabondhoang You can check my solution for this issue in my new PR. Let’s see if they accept it so anyone can use it.

0reactions
vagabondhoangcommented, Oct 11, 2022

Bro @davidbejarcaceres , does it work for auto scroll vertically when drag item ups/downs? Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scroll a list while the user is dragging an object near the bounds
I have a view that I am dragging and dropping into a list. That list is created using a recyclerView. The drag object...
Read more >
Dragging a draggable element out of a scrollable div - GSAP
I've noticed that it it's not possible to drag an element out of. ... the letter isn't shown when dragging because the scrollbar...
Read more >
Properties Gantt Docs - DHTMLX Documentation
autoscroll, enables autoscrolling while dragging a task or link out of the ... will appear from the left/right side of the screen or...
Read more >
41708 - Should be able to scroll in the viewport while dragging
(Core :: DOM: Copy & Paste and Drag & Drop, defect, P3). Product: ... test here works only in ie6+ with autoscroll near...
Read more >
Take control of your scroll - customizing pull-to-refresh and ...
Scrolls that originate on the element may propagate to ancestor elements. contain - prevents scroll chaining. Scrolls do not propagate to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found