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

Resize shadow doesn't match event time

Asked by Albert
1 month ago.

My event goes from 22-10-2021 13:00 to 26-10-2021 11:00.

When I resize the event, the shadow fills the entire cells instead of half but when i stop resizing the event fits correctly. Why this is happening?

onEventResizing: function (args) {
    console.log(args.start)
    console.log(args.end)
    switch (args.what) {
        case 'start':
            args.start = args.start.addHours(-11)
            args.multiresize[0].start = args.multiresize[0].start.addHours(-11)
            console.log("Start:" + args.multiresize[0].start)
            break;

        case 'end':
            args.end = args.end.addHours(-13)
            args.multiresize[0].end = args.multiresize[0].end.addHours(-13)
            console.log("End:" + args.multiresize[0].end)
            break;
    }
},
Answer posted by Dan Letecky [DayPilot]
1 month ago.

You'd need to turn off the "snap to grid" feature (https://doc.daypilot.org/scheduler/snap-to-grid/) to prevent this behavior:

dp.snapToGrid = false;
Comment posted by Albert
1 month ago.

The "snap to grid" feature is already disabled

Comment posted by Albert
1 month ago.

The "snap to grid" was enabled, but now it doesn't fill half a cell, but allows me to drop the event anywhere in the cell. This is not the desired behaviour

Comment posted by Dan Letecky [DayPilot]
1 month ago.

You'd have to change the logic in onEventResizing to adjust the start/end to your custom snap points.

You can find an example in this tutorial:
https://code.daypilot.org/39403/javascript-scheduler-customized-snap-to-grid

Comment posted by Albert
1 month ago.

Yes, I've adjusted the parameters:

args.start
args.multiresize[0].start
args.end
rgs.multiresize[0].end

The resulting event after resizing is correct, but the shadow is now drawing the size correctly.

Comment posted by Dan Letecky [DayPilot]
1 month ago.

If you turn off the snap to grid feature, the position (args.start etc.) will point to an exact point in the grid and it won't be adjusted to point to a cell edge.

So you will need to change the logic. Your original code would only work for snapToGrid = true:

args.start = args.start.addHours(-11);

For snapToGrid = false (and scale = "Day") it could look like this:

const endOfDay = args.start.getDatePart().addDays(1);
args.start = endOfDay.addHours(-11);
New Reply
This reply is
Your name (optional):