Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multiday events rendering bug #67

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
react-big-calendar
========================

An event Calendar component built for React.
An events calendar component built for React.

[__DEMO and Docs__](http://intljusticemission.github.io/react-big-calendar/examples/index.html).
big calendar is built for modern browsers (read: ie10+) and uses flexbox over the classic tables-ception approach.
[__DEMO and Docs__](http://intljusticemission.github.io/react-big-calendar/examples/index.html)

To run the example locally, `git clone`, `npm install` and `npm run examples`, hosted at localhost:3000.
`react-big-calendar` is built for modern browsers (read: IE10+) and uses flexbox over the classic tables-ception approach.

To run the examples locally, run `npm install && npm run examples`, and open [localhost:3000/examples/index.html](http://localhost:3000/examples/index.html).

Inspired by [Full Calendar](http://fullcalendar.io/).

Expand All @@ -19,9 +20,9 @@ Include `react-big-calendar/lib/css/react-big-calendar.css` for styles.
### Localization and Date Formatting

`react-big-calendar` includes two options for handling the date formatting and culture localization, depending
on your preference of DateTime libraries. You can use either the Moment.js or Globalize.js localizers.
on your preference of DateTime libraries. You can use either the [Moment.js](http://momentjs.com/) or [Globalize.js](https://github.com/jquery/globalize) localizers.

Regardless of your choice you __must__ choose a localizer to use react-big-calendar.
Regardless of your choice, you __must__ choose a localizer to use this library:

#### Moment.js

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "react-big-calendar",
"version": "0.9.8",
"description": "Calendar! with events",
"version": "0.9.9",
"description": "Google Calendar like React component, inspired by fullcalendar.io",
"author": "Jason Quense <monastic.panic@gmail.com>",
"repository": "jquense/react-big-calendar",
"repository": "intljusticemission/react-big-calendar",
"license": "MIT",
"main": "lib/index.js",
"files": [
Expand All @@ -25,7 +25,7 @@
"clean:examples": "rimraf examples/static",
"less": "lessc -x src/less/styles.less ./lib/css/react-big-calendar.css",
"assets": "cpy src/less/* lib/less",
"build": "npm run clean && babel src --out-dir lib && npm run assets & npm run less",
"build": "npm run clean && babel src --out-dir lib && npm run assets && npm run less",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't missing an & the single & is how you run parallel tasks on windows, I assume not so on Mac/*nix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

single & is also for parallel tasks on OSX/unix, but I don't think it's a good idea to run these tasks in parallel because if you wait for an exit code from the command, you'll get it before it completes, in addition to have loose output consistency (you don't know when exactly it finishes)...

"build:examples": "npm run clean:examples && webpack --config webpack/docs.config.es6.js",
"build:visual-test": "webpack --config webpack/visual-test.es6.js",
"examples": "npm run clean:examples && babel-node ./examples/server.js",
Expand Down
14 changes: 6 additions & 8 deletions src/utils/eventLevels.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@ import dates from './dates';
import { accessor as get } from './accessors';

export function eventSegments(event, first, last, { startAccessor, endAccessor, culture }){
let slots = dates.diff(first, last, 'day')
let start = dates.max(dates.startOf(get(event, startAccessor), 'day'), first);
let end = dates.min(dates.ceil(get(event, endAccessor), 'day'), dates.add(last, 1, 'day'))
const slots = Math.round(dates.diff(first, last, 'day')) + 1;

let span = dates.diff(start, end, 'day');
const start = dates.max(dates.startOf(get(event, startAccessor), 'day'), first);
const end = dates.min(dates.startOf(get(event, endAccessor), 'day'), last);

span = Math.floor(Math.max(Math.min(span, slots), 1));

let padding = Math.floor(dates.diff(first, start, 'day'));
const span = Math.round(dates.diff(start, end, 'day')) + 1;
const padding = Math.round(dates.diff(first, start, 'day'));

return {
event,
span,
span: Math.max(Math.min(span, slots), 1),
left: padding + 1,
right: Math.max(padding + span, 1)
}
Expand Down