search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Multimove and manually snapping to grid

Asked by Leo
12 months ago.

Hi there,

When using multimove in the scheduler and NOT using snapToGrid, but instead a custom implementation of snapping (using the onEventMoving event), it seems like only the primary event (the one being dragged by the cursor) is snapping, whereas all other mulitmove events are fluid.

I tried iterating through the multimove items and setting start and end, however this does not achieve any snapping.

How would you go about snapping multiple events while multimoving?

Answer posted by Dan Letecky [DayPilot]
12 months ago.

It is possible to change "start" end "end" properties of the additional selected events in onEventMoving. You can modify the args.multimove[x].start and args.multimove[x].end properties as needed. Just note that the first item in the args.multimove array is the master event - the custom "start" and "end" property change will be ignored (use args.start and args.end instead).

The following example resets the start and end of all additional events in the selection to the position of the master event:

onEventMoving: args => {
    const e = args.e;
    args.multimove.forEach(x => {
        if (x.event.id() === e.id()) {  // ignoring the first item that
            return;
        }
        x.start = args.start;
        x.end = args.end;
    });
}

You may need to review your logic to see if the start/end properties are being set to the correct values in your onEventMoving handler.

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.