Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Movement plugin not respecting threshold #361

Open
ivanmayes opened this issue Jan 10, 2023 · 1 comment
Open

Movement plugin not respecting threshold #361

ivanmayes opened this issue Jan 10, 2023 · 1 comment

Comments

@ivanmayes
Copy link

Describe the bug
I've set the threshold option for the ItemMovement plugin, but it doesn't seem to respect the threshold in cases. The items move immediately when clicked if the dates are slightly off of the "cadence" of the calendar as well. For instance, if I have an item with a date of Jun. 25 - Jul 25 and I'm looking in a monthly zoom, when I click the item, the item will sometimes immediately "snap" to either Jun 1-Jul 1 or to Jul 1-Aug 1.

Code
How to reproduce this error?
Paste your code here with example data.

{
			threshold: {
				horizontal: 500,
				vertical: 500
			},
			autoScroll: {
				speed: {
					vertical: 0
				}
			},
			events: {
				onMove(ev: OnArg) {
					// items before the current movement
					return ev.items.before.map((beforeMovementItem, index) => {
						// item data after move
						const afterMovementItem = ev.items.after[index];
						// clone item to prevent bugs
						const myItem: Row = GSTC.api.merge({}, afterMovementItem);

						// Prevent items moving between rows
						myItem.rowId = beforeMovementItem.rowId;

						// return modified item (or not if we don't want to move it -> return beforeMovementItem;)
						return myItem;
					});
				},
				onEnd(ev: OnArg) {
					// that.saveDateModifications(ev.items);
					// Submit changes to any items affected by the resize.
					ev.items.after.forEach((item, i) => {
						if (
							item.time &&
							(
								item.time.start !== ev.items.initial[i].time.start ||
								item.time.end !== ev.items.initial[i].time.end
							)
						) {
							that.itemMoved.emit({
								item,
								start: new Date(item.time.start).toISOString(),
								end: new Date(item.time.end).toISOString()
							})
						}
					});

					return ev.items.after;
				}
			},

		}

gantt-schedule-timeline-calendar version
What version are you using? 3.19.0
You can get it from package.json or with state.get('config.version').

Screenshots or movies
If applicable, add screenshots or movie to help explain your problem.

Screen.Recording.2023-01-10.at.3.07.54.PM.mov
@ivanmayes
Copy link
Author

Been a couple months, the clamping issue is a pretty critical issue for my users to use the interactive features of the plugin. Any suggestions on how to prevent the items from immediately snapping to new dates and causing a move event that could unknowningly shift dates for items?

It seems like threshold should theoretically make it so that things don't automatically snap to the grid, let me know if I need to implement this in a different way.

Perhaps there is an alternate flow where the user need to fully click to select an item, and THEN they can click and drag that item. This two click method, while not ideal for some use cases, could help when the movement of an item is really sensitive and would help establish more intention to a movement action.

Any advice or update you could provide would be super helpful. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant