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: scrollToTime does not work properly, when min specified #2051

Merged
merged 4 commits into from Jun 5, 2023

Conversation

hiroro-work
Copy link
Contributor

Fixed a bug that prevented scrollToTime does not working properly, when min specified.

@gdantas-laon
Copy link

pls accept this PR!!

@Poky85
Copy link

Poky85 commented Apr 14, 2023

@gdantas-laon Until fix is merged this works for me:

import * as React from 'react';
import { Calendar } from 'react-big-calendar';

const defaultMin = new Date(1972, 0, 1, 0, 0, 0, 0);

const normalizeTime = (time: Date) => {
  const normalized = new Date(time);
  normalized.setFullYear(1972, 0, 1);
  return normalized;
};

const getFixedScrollToTime = (scrollToTime: Date, min: Date) => {
  const time = normalizeTime(scrollToTime);
  const minimum = normalizeTime(min);
  const shiftMilliseconds = minimum.getTime() - defaultMin.getTime();

  return new Date(Math.max(defaultMin.getTime(), time.getTime() - shiftMilliseconds));
};

const MyCalendar: React.FunctionComponent = () => {
  const min = new Date(1972, 0, 1, 7, 0);
  const max = new Date(1972, 0, 1, 20, 0);
  const scrollToTime = new Date(1972, 0, 1, 12, 0);

  return (
    <Calendar events={[]} min={min} max={max} scrollToTime={getFixedScrollToTime(scrollToTime)} />
  );
};

@cutterbl
Copy link
Collaborator

cutterbl commented Jun 2, 2023

Can you update your branch with latest from master? Then I can test your changes.

@hiroro-work
Copy link
Contributor Author

@cutterbl Updated!

@cutterbl cutterbl merged commit 04c1888 into jquense:master Jun 5, 2023
1 check passed
github-actions bot pushed a commit that referenced this pull request Jun 5, 2023
## [1.8.1](v1.8.0...v1.8.1) (2023-06-05)

### Bug Fixes

* scrollToTime does not work properly, when min specified ([#2051](#2051)) ([04c1888](04c1888))
@github-actions
Copy link

github-actions bot commented Jun 5, 2023

🎉 This PR is included in version 1.8.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit to additio/react-big-calendar that referenced this pull request Mar 12, 2024
# [1.1.0](v1.0.0...v1.1.0) (2024-03-12)

### Bug Fixes

* add isBackgroundEvent to onSelectEvent event obj ([jquense#2491](https://github.com/additio/react-big-calendar/issues/2491)) ([fdbb496](fdbb496))
* **ARIA:** remove tabindex ([jquense#2508](https://github.com/additio/react-big-calendar/issues/2508)) ([7e01c3d](7e01c3d)), closes [jquense#2498](https://github.com/additio/react-big-calendar/issues/2498)
* changed flex-direction for rbc-toolbar mobile ([jquense#2497](https://github.com/additio/react-big-calendar/issues/2497)) ([8d7b20d](8d7b20d)), closes [jquense#1699](https://github.com/additio/react-big-calendar/issues/1699)
* day events sort fixed ([jquense#2512](https://github.com/additio/react-big-calendar/issues/2512)) ([ac1ff00](ac1ff00))
* **DnD:** dragAndDrop EventWrapper.js error: cannot add property 'X', object is not extensible ([0c4826a](0c4826a))
* **dnd:** move merge components ([fd02261](fd02261)), closes [jquense#2359](https://github.com/additio/react-big-calendar/issues/2359)
* fixing invalid ref with invalid scrollHeight ([jquense#2459](https://github.com/additio/react-big-calendar/issues/2459)) ([a4bc8f3](a4bc8f3))
* Modify events.js ([jquense#2444](https://github.com/additio/react-big-calendar/issues/2444)) ([2a838d9](2a838d9))
* replace deprecated onKeyPress by onKeyDown ([21f51f2](21f51f2))
* **rtl DnD:** Dragging an event in the RTL month view calendar gets confused to the wrong side ([jquense#2426](https://github.com/additio/react-big-calendar/issues/2426)) ([ebe8c2c](ebe8c2c)), closes [jquense#2310](https://github.com/additio/react-big-calendar/issues/2310) [jquense#1801](https://github.com/additio/react-big-calendar/issues/1801)
* scrollToTime does not work properly, when min specified ([jquense#2051](https://github.com/additio/react-big-calendar/issues/2051)) ([04c1888](04c1888))
* to build ([jquense#2517](https://github.com/additio/react-big-calendar/issues/2517)) ([621fc7e](621fc7e))
* typo ([jquense#2443](https://github.com/additio/react-big-calendar/issues/2443)) ([407e168](407e168))

### Features

* add citation file ([jquense#2523](https://github.com/additio/react-big-calendar/issues/2523)) ([3de0059](3de0059))
* **allDayMaxRows:** Allow for more granular control ([36871bf](36871bf)), closes [jquense#2386](https://github.com/additio/react-big-calendar/issues/2386)
* **event sort:** update event sort for multi day ([jquense#2502](https://github.com/additio/react-big-calendar/issues/2502)) ([ff209d0](ff209d0))
* showMore message add event info ([jquense#2496](https://github.com/additio/react-big-calendar/issues/2496)) ([18012b7](18012b7))
* Support multiple resources on an event ([91155c5](91155c5)), closes [jquense#2405](https://github.com/additio/react-big-calendar/issues/2405) [jquense#1649](https://github.com/additio/react-big-calendar/issues/1649)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants