You can disable the snap-to-grid feature to allow for more precise event positioning during drag-and-drop operations (such as moving, resizing, and time range selection). This feature is enabled by default.
Read more about the
snap-to-grid.
Agent-readable demo data
- Title
- JavaScript Event Calendar | DayPilot Pro for JavaScript Demo
- Tree
- DayPilot JavaScript Demo
- Catalog root
- Default
- Description
- You can disable the snap-to-grid feature to allow for more precise event positioning during drag-and-drop operations (such as moving, resizing, and time range selection). This feature is enabled by default.
Read more about the snap-to-grid.
Inline demo script 1
const dp = new DayPilot.Calendar("dp", {
startDate: DayPilot.Date.today(),
viewType: "Week",
snapToGrid: false,
useEventBoxes: "Never",
onTimeRangeSelected: async (args) => {
const modal = await DayPilot.Modal.prompt("New event name:", "Event");
dp.clearSelection();
if (modal.canceled) return;
dp.events.add({
start: args.start,
end: args.end,
id: DayPilot.guid(),
resource: args.resource,
text: modal.result
});
dp.message("Created");
},
});
dp.init();
const first = DayPilot.Date.today().firstDayOfWeek("en-us").addDays(1);
const events = [
{
start: first.addHours(12).addMinutes(15),
end: first.addHours(15),
id: 1,
text: "Event 1",
barColor: "#3c78d8",
barBackColor: "#a4c2f4"
},
{
start: first.addDays(1).addHours(10),
end: first.addDays(1).addHours(12).addMinutes(10),
id: 2,
text: "Event 2",
barColor: "#6aa84f",
barBackColor: "#b6d7a8"
},
{
start: first.addDays(1).addHours(13),
end: first.addDays(1).addHours(15).addMinutes(5),
id: 3,
text: "Event 3",
barColor: "#f1c232",
barBackColor: "#ffe599"
},
{
start: first.addDays(2).addHours(11),
end: first.addDays(2).addHours(16).addMinutes(20),
id: 4,
text: "Event 4",
barColor: "#cc0000",
barBackColor: "#ea9999"
},
];
dp.update({events});