Skip to content

Commit

Permalink
[fixed] layout of events in months that don't start evenly at weekday 0
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Sep 13, 2015
1 parent 720675e commit 49e321f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion examples/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const Example = React.createClass({
selectable
popup
events={events}
defaultDate={new Date(2015, 1, 1)}
defaultDate={new Date(2015, 3, 1)}
eventPropGetter={e => ({ className: 'hi-event'})}
components={{
event: EventWeek,
Expand Down
40 changes: 20 additions & 20 deletions examples/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,52 +12,52 @@ export default [
{
"title": "All Day Event",
"allDay": true,
"start": new Date(2015, 1, 1),
"end": new Date(2015, 1, 1)
"start": new Date(2015, 3, 0),
"end": new Date(2015, 3, 0)
},
{
"title": "Long Event",
"start": new Date(2015, 1, 7),
"end": new Date(2015, 1, 10),
"start": new Date(2015, 3, 7),
"end": new Date(2015, 3, 10),
},
{
"title": "Some Event",
"start": new Date(2015, 1, 9, 0, 0, 0),
"end": new Date(2015, 1, 9, 0, 0, 0),
"start": new Date(2015, 3, 9, 0, 0, 0),
"end": new Date(2015, 3, 9, 0, 0, 0),
},
{
"title": "Conference",
"start": new Date(2015, 1, 11),
"end": new Date(2015, 1, 13)
"start": new Date(2015, 3, 11),
"end": new Date(2015, 3, 13)
},
{
"title": "Meeting",
"start": new Date(2015, 1, 12, 10, 30, 0, 0),
"end": new Date(2015, 1, 12, 12, 30, 0, 0)
"start": new Date(2015, 3, 12, 10, 30, 0, 0),
"end": new Date(2015, 3, 12, 12, 30, 0, 0)
},
{
"title": "Lunch",
"start":new Date(2015, 1, 12, 12, 0, 0, 0),
"end": new Date(2015, 1, 12, 13, 0, 0, 0)
"start":new Date(2015, 3, 12, 12, 0, 0, 0),
"end": new Date(2015, 3, 12, 13, 0, 0, 0)
},
{
"title": "Meeting",
"start":new Date(2015, 1, 12,14, 0, 0, 0),
"end": new Date(2015, 1, 12,15, 0, 0, 0)
"start":new Date(2015, 3, 12,14, 0, 0, 0),
"end": new Date(2015, 3, 12,15, 0, 0, 0)
},
{
"title": "Happy Hour",
"start":new Date(2015, 1, 12, 17, 0, 0, 0),
"end": new Date(2015, 1, 12, 17, 30, 0, 0)
"start":new Date(2015, 3, 12, 17, 0, 0, 0),
"end": new Date(2015, 3, 12, 17, 30, 0, 0)
},
{
"title": "Dinner",
"start":new Date(2015, 1, 12, 20, 0, 0, 0),
"end": new Date(2015, 1, 12, 21, 0, 0, 0)
"start":new Date(2015, 3, 12, 20, 0, 0, 0),
"end": new Date(2015, 3, 12, 21, 0, 0, 0)
},
{
"title": "Birthday Party",
"start":new Date(2015, 1, 13, 7, 0, 0),
"end": new Date(2015, 1, 13, 10, 30, 0)
"start":new Date(2015, 3, 13, 7, 0, 0),
"end": new Date(2015, 3, 13, 10, 30, 0)
}
]
8 changes: 4 additions & 4 deletions src/utils/eventLevels.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import dates from './dates';
import localizer from '../localizer';
import { accessor as get } from './accessors';
//import canUseDom from 'dom-helpers/util/inDOM';

Expand All @@ -8,10 +9,9 @@ import { accessor as get } from './accessors';
// isIE = ('documentMode' in document)
// }

export function eventSegments(event, first, last, { startAccessor, endAccessor }){

let start = dates.duration(first,
dates.max(get(event, startAccessor), first), 'day');
export function eventSegments(event, first, last, { startAccessor, endAccessor, culture }){
let startOfWeek = localizer.startOfWeek(culture);
let start = dates.duration(first, dates.max(get(event, startAccessor), first), 'weekday', startOfWeek);

let span = Math.min(dates.duration(
dates.max(get(event, startAccessor), first)
Expand Down

0 comments on commit 49e321f

Please sign in to comment.