浏览代码

clientrect, renames

Adam Shaw 7 年之前
父节点
当前提交
02c7b7adf3
共有 3 个文件被更改,包括 10 次插入10 次删除
  1. 1 1
      src/common/OffsetTracker.ts
  2. 8 8
      src/common/scroll-geom-cache.ts
  3. 1 1
      src/dnd/AutoScroller.ts

+ 1 - 1
src/common/OffsetTracker.ts

@@ -31,7 +31,7 @@ export default class OffsetTracker {
     let point = { left: pageX, top: pageY }
 
     for (let scrollCache of this.scrollCaches) {
-      if (!pointInsideRect(point, scrollCache.rect)) {
+      if (!pointInsideRect(point, scrollCache.clientRect)) {
         return false
       }
     }

+ 8 - 8
src/common/scroll-geom-cache.ts

@@ -1,10 +1,10 @@
 import { Rect } from '../util/geom'
-import { computeRect } from '../util/dom-geom'
+import { computeInnerRect } from '../util/dom-geom'
 import { ScrollController, ElementScrollController, WindowScrollController } from './scroll-controller'
 
 export abstract class ScrollGeomCache extends ScrollController {
 
-  rect: Rect
+  clientRect: Rect
   origScrollTop: number
   origScrollLeft: number
 
@@ -27,7 +27,7 @@ export abstract class ScrollGeomCache extends ScrollController {
     this.scrollHeight = scrollController.getScrollHeight()
     this.clientWidth = scrollController.getClientWidth()
     this.clientHeight = scrollController.getClientHeight()
-    this.rect = this.computeRect() // do last in case it needs cached values
+    this.clientRect = this.computeClientRect() // do last in case it needs cached values
 
     if (this.doesListening) {
       this.getEventTarget().addEventListener('scroll', this.handleScroll)
@@ -35,7 +35,7 @@ export abstract class ScrollGeomCache extends ScrollController {
   }
 
   abstract getEventTarget(): EventTarget
-  abstract computeRect(): Rect
+  abstract computeClientRect(): Rect
 
   destroy() {
     if (this.doesListening) {
@@ -108,8 +108,8 @@ export class ElementScrollGeomCache extends ScrollGeomCache {
     return this.scrollController.el
   }
 
-  computeRect() {
-    return computeRect(this.scrollController.el)
+  computeClientRect() {
+    return computeInnerRect(this.scrollController.el)
   }
 
 }
@@ -126,7 +126,7 @@ export class WindowScrollGeomCache extends ScrollGeomCache {
     return window
   }
 
-  computeRect(): Rect {
+  computeClientRect(): Rect {
     return {
       left: this.scrollLeft,
       right: this.scrollLeft + this.clientWidth,
@@ -136,7 +136,7 @@ export class WindowScrollGeomCache extends ScrollGeomCache {
   }
 
   handleScrollChange() {
-    this.rect = this.computeRect()
+    this.clientRect = this.computeClientRect()
   }
 
 }

+ 1 - 1
src/dnd/AutoScroller.ts

@@ -134,7 +134,7 @@ export default class AutoScroller {
     let bestSide: Edge | null = null
 
     for (let scrollCache of this.scrollCaches) {
-      let rect = scrollCache.rect
+      let rect = scrollCache.clientRect
       let leftDist = left - rect.left
       let rightDist = rect.right - left
       let topDist = top - rect.top