Adam Shaw 7 лет назад
Родитель
Сommit
baa2000d82

+ 15 - 3
src/interactions/DateSelecting.ts

@@ -1,4 +1,4 @@
-import { compareNumbers } from '../util/misc'
+import { compareNumbers, enableCursor, disableCursor } from '../util/misc'
 import { elementClosest } from '../util/dom-manip'
 import DateComponent from '../component/DateComponent'
 import HitDragging, { Hit } from './HitDragging'
@@ -38,11 +38,11 @@ export default class DateSelecting {
 
   handlePointerDown = (ev: PointerDragEvent) => {
     let { component, dragging } = this
-    let isValid = component.opt('selectable') &&
+    let canSelect = component.opt('selectable') &&
       component.isValidDateDownEl(ev.origEvent.target as HTMLElement)
 
     // don't bother to watch expensive moves if component won't do selection
-    dragging.setIgnoreMove(!isValid)
+    dragging.setIgnoreMove(!canSelect)
 
     // if touch, require user to hold down
     dragging.delay = ev.isTouch ? getComponentTouchDelay(component) : null
@@ -55,12 +55,18 @@ export default class DateSelecting {
   handleHitUpdate = (hit: Hit | null, isFinal: boolean) => {
     let calendar = this.component.getCalendar()
     let dragSelection: DateSpan | null = null
+    let isInvalid = false
 
     if (hit) {
       dragSelection = computeSelection(
         this.hitDragging.initialHit!.dateSpan,
         hit.dateSpan
       )
+
+      if (!this.component.isSelectionValid(dragSelection)) {
+        isInvalid = false
+        dragSelection = null
+      }
     }
 
     if (dragSelection) {
@@ -69,6 +75,12 @@ export default class DateSelecting {
       calendar.dispatch({ type: 'UNSELECT_DATES' })
     }
 
+    if (!isInvalid) {
+      enableCursor()
+    } else {
+      disableCursor()
+    }
+
     if (!isFinal) {
       this.dragSelection = dragSelection // only clear if moved away from all hits while dragging
     }

+ 1 - 1
src/interactions/EventDragging.ts

@@ -162,7 +162,7 @@ export default class EventDragging { // TODO: rename to EventSelectingAndDraggin
       origSeg: this.subjectSeg
     })
 
-    if (!isInvalid || isFinal) {
+    if (!isInvalid) {
       enableCursor()
     } else {
       disableCursor()

+ 1 - 1
src/interactions/EventResizing.ts

@@ -120,7 +120,7 @@ export default class EventDragging {
       calendar.dispatch({ type: 'UNSET_EVENT_RESIZE' })
     }
 
-    if (!isInvalid || isFinal) {
+    if (!isInvalid) {
       enableCursor()
     } else {
       disableCursor()