Skip to content

Commit f8499b0

Browse files
authored
Change Typo of dragtype to dragType and fix end drag issue (#171)
2 parents d0089d6 + af9eda3 commit f8499b0

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

src/components/EventItem.jsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Popover } from 'antd';
55
import EventItemPopover from './EventItemPopover';
66
import { DnDTypes, CellUnit, DATETIME_FORMAT } from '../config/default';
77

8-
const stopDragHelper = ({ count, cellUnit, config, dragtype, eventItem, localeDayjs, value }) => {
8+
const stopDragHelper = ({ count, cellUnit, config, dragType, eventItem, localeDayjs, value }) => {
99
const whileTrue = true;
1010
let tCount = 0;
1111
let i = 0;
@@ -14,7 +14,7 @@ const stopDragHelper = ({ count, cellUnit, config, dragtype, eventItem, localeDa
1414
if (count !== 0 && cellUnit !== CellUnit.Hour && config.displayWeekend === false) {
1515
while (whileTrue) {
1616
i = count > 0 ? i + 1 : i - 1;
17-
const date = localeDayjs(new Date(eventItem[dragtype])).add(i, 'days');
17+
const date = localeDayjs(new Date(eventItem[dragType])).add(i, 'days');
1818
const dayOfWeek = date.weekday();
1919

2020
if (dayOfWeek !== 0 && dayOfWeek !== 6) {
@@ -70,11 +70,11 @@ class EventItem extends Component {
7070
}
7171
}
7272

73-
resizerHelper = (dragtype, eventType = 'addEventListener') => {
74-
const resizer = dragtype === 'start' ? this.startResizer : this.endResizer;
75-
const doDrag = dragtype === 'start' ? this.doStartDrag : this.doEndDrag;
76-
const stopDrag = dragtype === 'start' ? this.stopStartDrag : this.stopEndDrag;
77-
const cancelDrag = dragtype === 'start' ? this.cancelStartDrag : this.cancelEndDrag;
73+
resizerHelper = (dragType, eventType = 'addEventListener') => {
74+
const resizer = dragType === 'start' ? this.startResizer : this.endResizer;
75+
const doDrag = dragType === 'start' ? this.doStartDrag : this.doEndDrag;
76+
const stopDrag = dragType === 'start' ? this.stopStartDrag : this.stopEndDrag;
77+
const cancelDrag = dragType === 'start' ? this.cancelStartDrag : this.cancelEndDrag;
7878
if (this.supportTouch) {
7979
resizer[eventType]('touchmove', doDrag, false);
8080
resizer[eventType]('touchend', stopDrag, false);
@@ -85,7 +85,7 @@ class EventItem extends Component {
8585
}
8686
};
8787

88-
initDragHelper = (ev, dragtype) => {
88+
initDragHelper = (ev, dragType) => {
8989
const { schedulerData, eventItem } = this.props;
9090
const slotId = schedulerData._getEventSlotId(eventItem);
9191
const slot = schedulerData.getSlotById(slotId);
@@ -102,10 +102,10 @@ class EventItem extends Component {
102102
if (ev.buttons !== undefined && ev.buttons !== 1) return;
103103
clientX = ev.clientX;
104104
}
105-
this.setState({ [dragtype === 'start' ? 'startX' : 'endX']: clientX });
105+
this.setState({ [dragType === 'start' ? 'startX' : 'endX']: clientX });
106106

107107
schedulerData._startResizing();
108-
this.resizerHelper(dragtype, 'addEventListener');
108+
this.resizerHelper(dragType, 'addEventListener');
109109
document.onselectstart = () => false;
110110
document.ondragstart = () => false;
111111
};
@@ -192,7 +192,7 @@ class EventItem extends Component {
192192
config,
193193
eventItem,
194194
localeDayjs,
195-
dragtype: 'start',
195+
dragType: 'start',
196196
value: newStart,
197197
});
198198

@@ -317,7 +317,7 @@ class EventItem extends Component {
317317
.add(cellUnit === CellUnit.Hour ? count * config.minuteStep : count, cellUnit === CellUnit.Hour ? 'minutes' : 'days')
318318
.format(DATETIME_FORMAT);
319319
newEnd = await stopDragHelper({
320-
dragtype: 'start',
320+
dragType: 'end',
321321
cellUnit,
322322
config,
323323
count,
@@ -351,7 +351,7 @@ class EventItem extends Component {
351351
if (conflictOccurred !== undefined) {
352352
conflictOccurred(schedulerData, 'EndResize', eventItem, DnDTypes.EVENT, slotId, slot ? slot.name : null, eventItem.start, newEnd);
353353
} else {
354-
console.log('Conflict occurred, set conflictOccurred func in Scheduler to handle it');
354+
console.error('Conflict occurred, set conflictOccurred func in Scheduler to handle it');
355355
}
356356
this.subscribeResizeEvent(this.props);
357357
} else if (updateEventEnd !== undefined) {
@@ -515,6 +515,7 @@ class EventItem extends Component {
515515
}
516516

517517
export default EventItem;
518+
518519
EventItem.propTypes = {
519520
schedulerData: PropTypes.object.isRequired,
520521
eventItem: PropTypes.object.isRequired,

src/examples/pages/Basic/class-based.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,4 @@ class Basic extends Component {
175175
};
176176
}
177177

178-
export default wrapperFun(Basic);
178+
export default wrapperFun(Basic);

0 commit comments

Comments
 (0)