almende / vis

⚠️ This project is not maintained anymore! Please go to https://github.com/visjs
7.85k stars 1.48k forks source link

Fix mouse offset when parent has position:relative #4166

Open AndrolGenhald opened 5 years ago

AndrolGenhald commented 5 years ago

Fix issue when parent has position: relative. offsetLeft is offset from the nearest relatively positioned parent, so a relative parent that has any sort of left offset will cause the mouse position to be wrong. This issue isn't noticeable in most cases because it's taking the difference between the time you start dragging at and the current time under the mouse, and most timelines are linear. It does cause issues with non-linear timelines though, such as when some periods are hidden.

JSFiddle

Examples

Old code with left margin broken-margin Fixed code with left margin fixed-margin Old code with scroll broken-scroll Fixed code with scroll fixed-scroll

yotamberk commented 5 years ago

The timeline is no longer maintained here. Please resubmit this PR to the new maintained repo: https://github.com/yotamberk/timeline-plus