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

+ 4 - 4
src/common/GlobalContext.ts

@@ -41,7 +41,7 @@ export class GlobalContext { // TODO: rename file to something better
 
   bind() {
     let pointerUpListener = this.pointerUpListener = new PointerDragListener(document as any)
-    pointerUpListener.ignoreMove = true
+    pointerUpListener.shouldIgnoreMove = true
     pointerUpListener.emitter.on('pointerup', this.onPointerUp)
   }
 
@@ -76,11 +76,11 @@ export class GlobalContext { // TODO: rename file to something better
 
   onPointerUp = (ev) => {
     let { listenerHash } = this
-    let { isTouchScroll, downEl } = this.pointerUpListener
+    let { wasTouchScroll, downEl } = this.pointerUpListener
 
     for (let id in listenerHash) {
-      listenerHash[id].dateSelecting.onDocumentPointerUp(ev, isTouchScroll, downEl)
-      listenerHash[id].eventDragging.onDocumentPointerUp(ev, isTouchScroll, downEl)
+      listenerHash[id].dateSelecting.onDocumentPointerUp(ev, wasTouchScroll, downEl)
+      listenerHash[id].eventDragging.onDocumentPointerUp(ev, wasTouchScroll, downEl)
     }
   }
 

+ 1 - 1
src/dnd/HitDragListener.ts

@@ -26,7 +26,7 @@ export default class HitDragListener {
   emitter: EmitterMixin
   initialHit: Hit
   movingHit: Hit
-  finalHit: Hit // won't ever be populated if ignoreMove
+  finalHit: Hit // won't ever be populated if shouldIgnoreMove
   coordAdjust: any
   dieIfNoInitial: boolean = true
   isIgnoringMove: boolean = false

+ 3 - 3
src/dnd/IntentfulDragListener.ts

@@ -82,7 +82,7 @@ export class IntentfulDragListenerImpl implements IntentfulDragListener {
       this.emitter.trigger('pointerdown', ev)
 
       // if moving is being ignored, don't fire any initial drag events
-      if (!this.pointerListener.ignoreMove) {
+      if (!this.pointerListener.shouldIgnoreMove) {
         // actions that could fire dragstart...
 
         this.startDelay(ev)
@@ -159,7 +159,7 @@ export class IntentfulDragListenerImpl implements IntentfulDragListener {
 
   tryStartDrag(ev: PointerDragEvent) {
     if (this.isDelayEnded && this.isDistanceSurpassed) {
-      if (!this.pointerListener.isTouchScroll || this.touchScrollAllowed) {
+      if (!this.pointerListener.wasTouchScroll || this.touchScrollAllowed) {
         this.isDragging = true
         this.emitter.trigger('dragstart', ev)
 
@@ -202,7 +202,7 @@ export class IntentfulDragListenerImpl implements IntentfulDragListener {
   }
 
   setIgnoreMove(bool: boolean) {
-    this.pointerListener.ignoreMove = bool
+    this.pointerListener.shouldIgnoreMove = bool
   }
 
 }

+ 8 - 8
src/dnd/PointerDragListener.ts

@@ -28,12 +28,12 @@ export default class PointerDragListener {
   // options
   selector: string
   handleSelector: string
-  ignoreMove: boolean = false // bad name?
+  shouldIgnoreMove: boolean = false
 
   // internal states
   isDragging: boolean = false
   isTouchDragging: boolean = false
-  isTouchScroll: boolean = false
+  wasTouchScroll: boolean = false
 
   constructor(containerEl: HTMLElement) {
     this.containerEl = containerEl
@@ -60,7 +60,7 @@ export default class PointerDragListener {
       this.subjectEl = subjectEl
       this.downEl = downEl
       this.isDragging = true // do this first so cancelTouchScroll will work
-      this.isTouchScroll = false
+      this.wasTouchScroll = false
       return true
     }
 
@@ -72,7 +72,7 @@ export default class PointerDragListener {
     this.isDragging = false
     this.subjectEl = null
     this.downEl = null
-    // keep isTouchScroll around for later access
+    // keep wasTouchScroll around for later access
   }
 
   queryValidSubjectEl(ev: UIEvent): HTMLElement {
@@ -95,7 +95,7 @@ export default class PointerDragListener {
     ) {
       this.emitter.trigger('pointerdown', createEventFromMouse(ev, this.subjectEl))
 
-      if (!this.ignoreMove) {
+      if (!this.shouldIgnoreMove) {
         document.addEventListener('mousemove', this.handleMouseMove)
       }
 
@@ -134,7 +134,7 @@ export default class PointerDragListener {
       // https://stackoverflow.com/a/45760014
       let target = ev.target
 
-      if (!this.ignoreMove) {
+      if (!this.shouldIgnoreMove) {
         target.addEventListener('touchmove', this.handleTouchMove)
       }
 
@@ -175,10 +175,10 @@ export default class PointerDragListener {
   }
 
   handleTouchScroll = () => {
-    this.isTouchScroll = true
+    this.wasTouchScroll = true
   }
 
-  // can be called by user of this class, while dragging
+  // can be called by user of this class, to cancel touch-based scrolling for the current drag
   cancelTouchScroll() {
     if (this.isDragging) {
       isWindowTouchMoveCancelled = true

+ 3 - 3
src/interactions/DateClicking.ts

@@ -22,7 +22,7 @@ export default class DateClicking {
     let { pointerListener } = this.dragListener
 
     // do this in pointerdown (not dragend) because DOM might be mutated by the time dragend is fired
-    pointerListener.ignoreMove = !component.isValidDateInteraction(pointerListener.downEl)
+    pointerListener.shouldIgnoreMove = !component.isValidDateInteraction(pointerListener.downEl)
   }
 
   onDragEnd = (ev: PointerDragEvent) => {
@@ -30,8 +30,8 @@ export default class DateClicking {
     let { pointerListener } = this.dragListener
 
     if (
-      !pointerListener.ignoreMove && // not ignored in onPointerDown
-      !pointerListener.isTouchScroll
+      !pointerListener.shouldIgnoreMove && // not ignored in onPointerDown
+      !pointerListener.wasTouchScroll
     ) {
       let { initialHit, finalHit } = this.hitListener
 

+ 3 - 3
src/interactions/DateSelecting.ts

@@ -40,7 +40,7 @@ export default class DateSelecting {
       component.isValidDateInteraction(ev.origEvent.target as HTMLElement)
 
     // don't bother to watch expensive moves if component won't do selection
-    dragListener.pointerListener.ignoreMove = !isValid
+    dragListener.pointerListener.shouldIgnoreMove = !isValid
 
     dragListener.delay = (isValid && ev.isTouch) ?
       getComponentDelay(component) :
@@ -84,7 +84,7 @@ export default class DateSelecting {
     })
   }
 
-  onDocumentPointerUp = (ev: PointerDragEvent, isTouchScroll: boolean, downEl: HTMLElement) => {
+  onDocumentPointerUp = (ev: PointerDragEvent, wasTouchScroll: boolean, downEl: HTMLElement) => {
     let { component } = this
 
     if (this.dragSelection) {
@@ -98,7 +98,7 @@ export default class DateSelecting {
 
       this.dragSelection = null
 
-    } else if (!isTouchScroll && component.selection) {
+    } else if (!wasTouchScroll && component.selection) {
       // if there was a pointerup that did not result in a selection and was
       // not merely a touchmove-scroll, then possibly unselect the current selection.
       // won't do anything if already unselected (OR, leverage selectedCalendar?)

+ 3 - 3
src/interactions/EventDragging.ts

@@ -47,7 +47,7 @@ export default class EventDragging {
 
     let origTarget = ev.origEvent.target as HTMLElement
 
-    dragListener.pointerListener.ignoreMove =
+    dragListener.pointerListener.shouldIgnoreMove =
       !this.component.isValidSegInteraction(origTarget) ||
       elementClosest(origTarget, '.fc-resizer')
   }
@@ -152,10 +152,10 @@ export default class EventDragging {
   TODO: rethinking ordering of onDocumentPointerUp firing,
   we want something that will always fire LAST, in case drag never activated
   */
-  onDocumentPointerUp = (ev, isTouchScroll) => {
+  onDocumentPointerUp = (ev, wasTouchScroll) => {
     if (
       !this.mutation &&
-      !isTouchScroll &&
+      !wasTouchScroll &&
       this.globalContext.eventSelectedComponent === this.component
     ) {
       this.component.getCalendar().dispatch({

+ 1 - 1
src/interactions/EventResizing.ts

@@ -38,7 +38,7 @@ export default class EventDragging {
     let eventInstanceId = seg.eventRange.eventInstance.instanceId
 
     // if touch, need to be working with a selected event
-    this.dragListener.pointerListener.ignoreMove =
+    this.dragListener.pointerListener.shouldIgnoreMove =
       !this.component.isValidSegInteraction(ev.origEvent.target) ||
       (ev.isTouch && this.component.selectedEventInstanceId !== eventInstanceId)
   }