Adam Shaw 7 سال پیش
والد
کامیت
bde253d5a4

+ 7 - 7
src/interactions/DateClicking.ts

@@ -1,20 +1,20 @@
 import DateComponent from '../component/DateComponent'
 import FeaturefulElementDragging from '../dnd/FeaturefulElementDragging'
-import HitDragListener, { isHitsEqual } from '../dnd/HitDragListener'
+import HitDragging, { isHitsEqual } from './HitDragging'
 import { PointerDragEvent } from '../dnd/PointerDragging'
 
 export default class DateClicking {
 
   component: DateComponent
   dragging: FeaturefulElementDragging
-  hitListener: HitDragListener
+  hitDragging: HitDragging
 
   constructor(component: DateComponent) {
     this.component = component
     this.dragging = new FeaturefulElementDragging(component.el)
-    this.hitListener = new HitDragListener(this.dragging, component)
-    this.hitListener.on('pointerdown', this.onPointerDown)
-    this.hitListener.on('dragend', this.onDragEnd)
+    this.hitDragging = new HitDragging(this.dragging, component)
+    this.hitDragging.on('pointerdown', this.onPointerDown)
+    this.hitDragging.on('dragend', this.onDragEnd)
   }
 
   onPointerDown = (ev: PointerDragEvent) => {
@@ -33,7 +33,7 @@ export default class DateClicking {
       !pointer.shouldIgnoreMove && // not ignored in onPointerDown
       !pointer.wasTouchScroll
     ) {
-      let { initialHit, finalHit } = this.hitListener
+      let { initialHit, finalHit } = this.hitDragging
 
       if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {
         component.getCalendar().triggerDayClick(initialHit, initialHit.el, component.view, ev.origEvent)
@@ -42,7 +42,7 @@ export default class DateClicking {
   }
 
   destroy() {
-    this.hitListener.destroy()
+    this.hitDragging.destroy()
   }
 
 }

+ 9 - 9
src/interactions/DateSelecting.ts

@@ -1,7 +1,7 @@
 import { compareNumbers } from '../util/misc'
 import { elementClosest } from '../util/dom-manip'
 import DateComponent from '../component/DateComponent'
-import HitDragListener, { Hit } from '../dnd/HitDragListener'
+import HitDragging, { Hit } from './HitDragging'
 import { Selection } from '../reducers/selection'
 import UnzonedRange from '../models/UnzonedRange'
 import { PointerDragEvent } from '../dnd/PointerDragging'
@@ -13,7 +13,7 @@ export default class DateSelecting {
   component: DateComponent
   globalContext: GlobalContext
   dragging: FeaturefulElementDragging
-  hitListener: HitDragListener
+  hitDragging: HitDragging
   dragSelection: Selection
 
   constructor(component: DateComponent, globalContext: GlobalContext) {
@@ -23,15 +23,15 @@ export default class DateSelecting {
     this.dragging = new FeaturefulElementDragging(component.el)
     this.dragging.touchScrollAllowed = false
 
-    let hitListener = this.hitListener = new HitDragListener(this.dragging, component)
-    hitListener.on('pointerdown', this.onPointerDown)
-    hitListener.on('dragstart', this.onDragStart)
-    hitListener.on('hitover', this.onHitOver)
-    hitListener.on('hitout', this.onHitOut)
+    let hitDragging = this.hitDragging = new HitDragging(this.dragging, component)
+    hitDragging.on('pointerdown', this.onPointerDown)
+    hitDragging.on('dragstart', this.onDragStart)
+    hitDragging.on('hitover', this.onHitOver)
+    hitDragging.on('hitout', this.onHitOut)
   }
 
   destroy() {
-    this.hitListener.destroy()
+    this.hitDragging.destroy()
   }
 
   onPointerDown = (ev: PointerDragEvent) => {
@@ -59,7 +59,7 @@ export default class DateSelecting {
   onHitOver = (overHit: Hit) => { // TODO: do a onHitChange instead?
     let { globalContext } = this
     let calendar = this.component.getCalendar()
-    let dragSelection = computeSelection(this.hitListener.initialHit, overHit)
+    let dragSelection = computeSelection(this.hitDragging.initialHit, overHit)
 
     if (dragSelection) {
       globalContext.selectedCalendar = calendar

+ 12 - 12
src/interactions/EventDragging.ts

@@ -1,6 +1,6 @@
 import { default as DateComponent, Seg } from '../component/DateComponent'
 import { PointerDragEvent } from '../dnd/PointerDragging'
-import HitDragListener, { isHitsEqual, Hit } from '../dnd/HitDragListener'
+import HitDragging, { isHitsEqual, Hit } from './HitDragging'
 import { EventMutation, diffDates, getRelatedEvents, applyMutationToAll } from '../reducers/event-mutation'
 import { GlobalContext } from '../common/GlobalContext'
 import { startOfDay } from '../datelib/marker'
@@ -12,7 +12,7 @@ export default class EventDragging {
   component: DateComponent
   globalContext: GlobalContext // need this as a member?
   dragging: FeaturefulElementDragging
-  hitListener: HitDragListener
+  hitDragging: HitDragging
   draggingSeg: Seg
   mutation: EventMutation
 
@@ -24,17 +24,17 @@ export default class EventDragging {
     this.dragging.pointer.selector = '.fc-draggable'
     this.dragging.touchScrollAllowed = false
 
-    let hitListener = this.hitListener = new HitDragListener(this.dragging, globalContext.componentHash)
-    hitListener.subjectCenter = true
-    hitListener.on('pointerdown', this.onPointerDown)
-    hitListener.on('dragstart', this.onDragStart)
-    hitListener.on('hitover', this.onHitOver)
-    hitListener.on('hitout', this.onHitOut)
-    hitListener.on('dragend', this.onDragEnd)
+    let hitDragging = this.hitDragging = new HitDragging(this.dragging, globalContext.componentHash)
+    hitDragging.subjectCenter = true
+    hitDragging.on('pointerdown', this.onPointerDown)
+    hitDragging.on('dragstart', this.onDragStart)
+    hitDragging.on('hitover', this.onHitOver)
+    hitDragging.on('hitout', this.onHitOut)
+    hitDragging.on('dragend', this.onDragEnd)
   }
 
   destroy() {
-    this.hitListener.destroy()
+    this.hitDragging.destroy()
   }
 
   onPointerDown = (ev: PointerDragEvent) => {
@@ -94,7 +94,7 @@ export default class EventDragging {
   }
 
   onHitOver = (hit) => {
-    let { initialHit } = this.hitListener
+    let { initialHit } = this.hitDragging
     let calendar = hit.component.getCalendar()
 
     let mutation = computeEventMutation(initialHit, hit)
@@ -165,7 +165,7 @@ export default class EventDragging {
   }
 
   onDragEnd = () => {
-    let { initialHit } = this.hitListener
+    let { initialHit } = this.hitDragging
     let initialCalendar = initialHit.component.getCalendar()
 
     // TODO: what about across calendars?

+ 10 - 10
src/interactions/EventResizing.ts

@@ -1,5 +1,5 @@
 import { default as DateComponent, Seg } from '../component/DateComponent'
-import HitDragListener, { isHitsEqual, Hit } from '../dnd/HitDragListener'
+import HitDragging, { isHitsEqual, Hit } from './HitDragging'
 import { EventMutation, diffDates, getRelatedEvents, applyMutationToAll } from '../reducers/event-mutation'
 import { elementClosest } from '../util/dom-manip'
 import UnzonedRange from '../models/UnzonedRange'
@@ -10,7 +10,7 @@ export default class EventDragging {
 
   component: DateComponent
   dragging: FeaturefulElementDragging
-  hitListener: HitDragListener
+  hitDragging: HitDragging
   draggingSeg: Seg
   mutation: EventMutation
 
@@ -21,16 +21,16 @@ export default class EventDragging {
     this.dragging.pointer.selector = '.fc-resizer'
     this.dragging.touchScrollAllowed = false
 
-    let hitListener = this.hitListener = new HitDragListener(this.dragging, component)
-    hitListener.on('pointerdown', this.onPointerDown)
-    hitListener.on('dragstart', this.onDragStart)
-    hitListener.on('hitover', this.onHitOver)
-    hitListener.on('hitout', this.onHitOut)
-    hitListener.on('dragend', this.onDragEnd)
+    let hitDragging = this.hitDragging = new HitDragging(this.dragging, component)
+    hitDragging.on('pointerdown', this.onPointerDown)
+    hitDragging.on('dragstart', this.onDragStart)
+    hitDragging.on('hitover', this.onHitOver)
+    hitDragging.on('hitout', this.onHitOut)
+    hitDragging.on('dragend', this.onDragEnd)
   }
 
   destroy() {
-    this.hitListener.destroy()
+    this.hitDragging.destroy()
   }
 
   onPointerDown = (ev) => {
@@ -49,7 +49,7 @@ export default class EventDragging {
 
   onHitOver = (hit, ev: PointerDragEvent) => {
     let calendar = this.component.getCalendar()
-    let { initialHit } = this.hitListener
+    let { initialHit } = this.hitDragging
     let eventInstance = this.draggingSeg.eventRange.eventInstance
 
     let mutation = computeMutation(

+ 13 - 13
src/interactions/ExternalDragging.ts

@@ -1,5 +1,5 @@
 import ElementDragging from '../dnd/ElementDragging'
-import HitDragListener, { Hit } from '../dnd/HitDragListener'
+import HitDragging, { Hit } from './HitDragging'
 import globalContext from '../common/GlobalContext'
 import { PointerDragEvent } from '../dnd/PointerDragging'
 import { EventStore, parseDef, createInstance } from '../reducers/event-store'
@@ -10,18 +10,18 @@ import { assignTo } from '../util/object'
 
 export default class ExternalDragging {
 
-  hitListener: HitDragListener
+  hitDragging: HitDragging
   addableEventStore: EventStore
   explicitEventCreationData: any
   eventCreationData: any
 
   constructor(dragging: ElementDragging, rawEventCreationData?) {
-    let hitListener = this.hitListener = new HitDragListener(dragging, globalContext.componentHash)
-    hitListener.dieIfNoInitial = false
-    hitListener.on('dragstart', this.onDragStart)
-    hitListener.on('hitover', this.onHitOver)
-    hitListener.on('hitout', this.onHitOut)
-    hitListener.on('dragend', this.onDragEnd)
+    let hitDragging = this.hitDragging = new HitDragging(dragging, globalContext.componentHash)
+    hitDragging.dieIfNoInitial = false
+    hitDragging.on('dragstart', this.onDragStart)
+    hitDragging.on('hitover', this.onHitOver)
+    hitDragging.on('hitout', this.onHitOut)
+    hitDragging.on('dragend', this.onDragEnd)
 
     dragging.enableMirror()
 
@@ -29,7 +29,7 @@ export default class ExternalDragging {
   }
 
   destroy() {
-    this.hitListener.destroy() // should not be responsible for destroying something not belonged!
+    this.hitDragging.destroy() // should not be responsible for destroying something not belonged!
   }
 
   onDragStart = (ev: PointerDragEvent) => {
@@ -62,7 +62,7 @@ export default class ExternalDragging {
       }
     })
 
-    let { dragging } = this.hitListener
+    let { dragging } = this.hitDragging
 
     dragging.setMirrorNeedsRevert(false)
 
@@ -87,17 +87,17 @@ export default class ExternalDragging {
 
     this.addableEventStore = null
 
-    let { dragging } = this.hitListener
+    let { dragging } = this.hitDragging
 
     dragging.enableMirror()
     dragging.setMirrorNeedsRevert(true)
   }
 
   onDragEnd = (pev: PointerDragEvent) => {
-    this.hitListener.dragging.enableMirror() // always restore!
+    this.hitDragging.dragging.enableMirror() // always restore!
 
     if (this.addableEventStore) {
-      let finalHit = this.hitListener.finalHit
+      let finalHit = this.hitDragging.finalHit
       let finalView = finalHit.component.view
       let finalCalendar = finalView.calendar
 

+ 4 - 4
src/dnd/HitDragListener.ts → src/interactions/HitDragging.ts

@@ -1,12 +1,12 @@
 import EmitterMixin from '../common/EmitterMixin'
-import { PointerDragEvent } from './PointerDragging'
-import ElementDragging from './ElementDragging'
+import { PointerDragEvent } from '../dnd/PointerDragging'
+import ElementDragging from '../dnd/ElementDragging'
 import DateComponent, { DateComponentHash } from '../component/DateComponent'
 import { Selection } from '../reducers/selection'
 import { computeRect } from '../util/dom-geom'
 import { constrainPoint, intersectRects, getRectCenter, diffPoints } from '../util/geom'
 
-export interface Hit extends Selection {
+export interface Hit extends Selection { // TODO: rename! put somewhere else
   component: DateComponent
 }
 
@@ -19,7 +19,7 @@ fires (none will be fired if no initial hit):
 - pointerup
 - dragend
 */
-export default class HitDragListener {
+export default class HitDragging {
 
   droppableHash: DateComponentHash
   dragging: ElementDragging