44 getScrollOffsetForCol ,
55 getScrollOffsetForRow ,
66} from 'src/utils/interaction/' ;
7- import _ , { isEmpty } from 'lodash' ;
7+ import { cloneDeep , isEmpty , isNil , throttle } from 'lodash' ;
88import { BaseEventImplement } from './base-event' ;
99import { BaseEvent } from './base-interaction' ;
1010import { InterceptType , S2Event , ScrollDirection } from '@/common/constant' ;
@@ -145,7 +145,7 @@ export class BrushSelection extends BaseEvent implements BaseEventImplement {
145145 let newY = this . endBrushPoint . y + y ;
146146 let needScrollForX = true ;
147147 let needScrollForY = true ;
148- const vScrollBarWidth = facet . vScrollBar . getBBox ( ) . width ;
148+ const vScrollBarWidth = facet . vScrollBar ? .getBBox ( ) ? .width ;
149149 const extraPixel = 2 ; // 额外加缩进,保证 getShape 在 panelBox 内
150150
151151 if ( newX > maxX ) {
@@ -178,7 +178,7 @@ export class BrushSelection extends BaseEvent implements BaseEventImplement {
178178
179179 private autoScrollIntervalId = null ;
180180
181- private autoScrollConfig : BrushAutoScrollConfig = _ . cloneDeep (
181+ private autoScrollConfig : BrushAutoScrollConfig = cloneDeep (
182182 BRUSH_AUTO_SCROLL_INITIAL_CONFIG ,
183183 ) ;
184184
@@ -302,7 +302,7 @@ export class BrushSelection extends BaseEvent implements BaseEventImplement {
302302 const nextIndex = this . validateYIndex (
303303 rowIndex + ( config . y . value > 0 ? 1 : - 1 ) ,
304304 ) ;
305- y = _ . isNil ( nextIndex )
305+ y = isNil ( nextIndex )
306306 ? 0
307307 : getScrollOffsetForRow ( nextIndex , dir , this . spreadsheet ) - scrollY ;
308308 }
@@ -317,7 +317,7 @@ export class BrushSelection extends BaseEvent implements BaseEventImplement {
317317 const nextIndex = this . validateXIndex (
318318 colIndex + ( config . x . value > 0 ? 1 : - 1 ) ,
319319 ) ;
320- x = _ . isNil ( nextIndex )
320+ x = isNil ( nextIndex )
321321 ? 0
322322 : getScrollOffsetForCol ( nextIndex , dir , this . spreadsheet ) - scrollX ;
323323 }
@@ -387,7 +387,7 @@ export class BrushSelection extends BaseEvent implements BaseEventImplement {
387387 ) ;
388388 } ;
389389
390- private handleScroll = _ . throttle ( ( x , y ) => {
390+ private handleScroll = throttle ( ( x , y ) => {
391391 if (
392392 this . brushSelectionStage === InteractionBrushSelectionStage . UN_DRAGGED
393393 ) {
@@ -458,7 +458,6 @@ export class BrushSelection extends BaseEvent implements BaseEventImplement {
458458
459459 private bindMouseMove ( ) {
460460 this . spreadsheet . on ( S2Event . GLOBAL_MOUSE_MOVE , ( event ) => {
461- event ?. preventDefault ?.( ) ;
462461 if (
463462 this . brushSelectionStage === InteractionBrushSelectionStage . UN_DRAGGED
464463 ) {
@@ -483,7 +482,6 @@ export class BrushSelection extends BaseEvent implements BaseEventImplement {
483482 private bindMouseUp ( ) {
484483 // 使用全局的 mouseup, 而不是 canvas 的 mouse up 防止刷选过程中移出表格区域时无法响应事件
485484 this . spreadsheet . on ( S2Event . GLOBAL_MOUSE_UP , ( event ) => {
486- event ?. preventDefault ?.( ) ;
487485 this . clearAutoScroll ( ) ;
488486 if ( this . isValidBrushSelection ( ) ) {
489487 this . spreadsheet . interaction . addIntercepts ( [
@@ -543,7 +541,7 @@ export class BrushSelection extends BaseEvent implements BaseEventImplement {
543541 }
544542
545543 private resetScrollDelta ( ) {
546- this . autoScrollConfig = _ . cloneDeep ( BRUSH_AUTO_SCROLL_INITIAL_CONFIG ) ;
544+ this . autoScrollConfig = cloneDeep ( BRUSH_AUTO_SCROLL_INITIAL_CONFIG ) ;
547545 }
548546
549547 private getBrushPoint ( event : CanvasEvent ) : BrushPoint {
0 commit comments