ArrobeFr / jquery-calendar-bs4

A responsive jquery calendar scheduler built with bootstrap 4 and moment.js
MIT License
89 stars 20 forks source link

Code hangs on some datasets #19

Open igortyra opened 3 years ago

igortyra commented 3 years ago

In some situations the javascript code hangs into endless loop while trying to position events on the 'day' or 'week' grid. Looks like it depends on dataset. Fast way to reproduce issue (on week view):

calendar = $('#calendar').Calendar({
  locale: 'en',
  unixTimestamp: 1628373000,
  view: 'week',
  weekday: {
    timeline: {
      intervalMinutes: 30,
      fromHour: 6
    }
  },
  events: [
    {start:1628371000, end:1628373000, title: 'event1'},
    {start:1628371000, end:1628393000, title: 'event2'},
    {start:1628372000, end:1628375000, title: 'event3'},
    {start:1628373000, end:1628377000, title: 'event4'},
    {start:1628374000, end:1628378000, title: 'event5'},
  ],
  daynotes: [],
}).init();

the code works without event5 but hangs with it.

julo42 commented 1 year ago

Hi,

I just stumbled upon a similar bug, and fixed it by changing: for (e = 0; -1 == parseInt(currentElement.attr("data-positions")); ) { to: for (e = 0; -1 == parseInt(currentElement.attr("data-positions")) && e in o; ) {

This is on line 483 in jquery-calendar.no-modal.js