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

Revamp Drag and drop #917

Merged
merged 3 commits into from
Jul 25, 2018
Merged

Revamp Drag and drop #917

merged 3 commits into from
Jul 25, 2018

Conversation

jquense
Copy link
Owner

@jquense jquense commented Jul 24, 2018

ugh so i know i said i wasn't going to work on this, but I had some time this weekend and felt inspired at a simpler approach than what we've been doing.

A lot of the code changes here are unrelated core hygiene improvements, but they do help make the DnD implementation simpler.

Ultimately i realized that we already had most of the hard work done for doing a custom DnD implementation thanks to the event Selection logic. Rather than use a new library i've leveraged that to do direct calculations on where things should be in relation to the mouse

@jquense
Copy link
Owner Author

jquense commented Jul 24, 2018

closes #891

@jquense jquense merged commit d2e02c4 into master Jul 25, 2018
@jquense jquense deleted the dnd-two-the-revenge branch July 25, 2018 21:09
@ehahn9
Copy link
Collaborator

ehahn9 commented Jul 25, 2018

you are a rockstar @jquense!

@arecvlohe
Copy link
Collaborator

😲 Awesome!

@dmitrykrylov
Copy link
Contributor

@jquense when will that be released?

@sendajob
Copy link

sendajob commented Aug 8, 2018

How can we npm update the change?

@miltonmc
Copy link
Contributor

miltonmc commented Aug 9, 2018

@sendajob You can change your package.json to directly point to the repository on Github, to get the latest updates on it: https://docs.npmjs.com/files/package.json#github-urls

...
dependencies: {
    ...
      "react-big-calendar": "intljusticemission/react-big-calendar",
    ...
}

@sendajob
Copy link

sendajob commented Aug 9, 2018

When i do that the src folder is missing. any idea how to fix?

@miltonmc
Copy link
Contributor

miltonmc commented Aug 9, 2018

@sendajob can you provide some additional information, like if you are using yarn or npm, your OS, the exact error msg, a screenshot and/or your package.json?

You can try the following:

$ cd node_modules/react-big-calendar/
$ yarn
$ yarn build

@sendajob
Copy link

sendajob commented Aug 9, 2018

When i set dependency
"react-big-calendar": "intljusticemission/react-big-calendar",

the react-big-calendar/ in node_modules only has
node_modules/

no src no dist

@dmitrykrylov
Copy link
Contributor

I tried to fetch dependency from github in the way @miltonmc proposed. It was successfully imported, but I got accessors.start is not a function error. I tried to debug it but haven't managed to fix the error and switched back to the current npm-indexed version.

@jquense
Copy link
Owner Author

jquense commented Aug 10, 2018

we still need #921 which has a few bug fixes to this initial PR

@amazingmarvin
Copy link
Contributor

@jquense I've been testing this and it works really well! Huge improvement. The only complaint I have is that the events lose their height while you're dragging them.

@jquense
Copy link
Owner Author

jquense commented Aug 15, 2018

is that the events lose their height while you're dragging them.

hmm that doesn't sound right, in what context?

@amazingmarvin
Copy link
Contributor

amazingmarvin commented Aug 16, 2018

@jquense I am using the "day" Calendar.

import BigCalendar from "react-big-calendar";
import withDragAndDrop from "react-big-calendar/lib/addons/dragAndDrop";
const Calendar = withDragAndDrop(BigCalendar, { backend: false });

        // Probably not that useful - let me know if there's something
        // that would be helpful to include
        <Calendar
          localizer={localizer}
          defaultView="day"
          defaultDate={moment(date).toDate()}
          views={["day"]}
          toolbar={false}
          step={dayIncrement}
          timeslots={timeslots}
          events={items}
          selectable={false}
          onEventResize={this.resize}
          onEventDrop={this.drop}
          resizable={true}
          allDayAccessor={this.getTaskWithoutTime}
          startAccessor={this.getTaskStartTime}
          endAccessor={this.getTaskEndTime}
          tooltipAccessor={this.getTooltip}
          components={{
            event: DayTask,
          }}
        />

calendardrag

BTW, I get the same behavior when I don't use the custom components.event. Also same behavior when I remove the { backend: false } in the call to withDragAndDrop.

@amazingmarvin
Copy link
Contributor

OK, the problem is that I'm using startAccessor and endAccessor, whereas EventContainerWrapper doesn't:

    let end = dates.add(
      currentSlot,
      dates.diff(event.start, event.end, 'minutes'),
      'minutes'
    )

amazingmarvin pushed a commit to amazingmarvin/react-big-calendar that referenced this pull request Aug 17, 2018
@archived-m
Copy link

@jquense Could you do a publish now that #921 has been merged? Thanks!

@nnals
Copy link

nnals commented Sep 1, 2018

hello.
i would like to try the new drag'n'drop/resizing behavior but can't figure out how to add the master branch as a dependency to codesandbox. does it even work? or would i have to build first? in case it's possible could someone perhaps help me add the master branch to this codesandbox.
thank you very much!

@amazingmarvin
Copy link
Contributor

@nnals The way I did this was: I forked the repo, ran npm run build, removed lib from .gitignore, pushed to my master, and then added "react-big-calendar": "git+https://github.com/YOU/react-big-calendar.git" to my package.json. Not sure if there's an easier way!

@miguelduarte42
Copy link

Hi,

I seem to have lost the ability to drag calendar items outside of the calendar. Is this by design?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants