@@ -326,16 +326,15 @@ export function bindTableGroupListener(eventManager: EventManager) {
326326 stateManager . updateCursor ( ) ;
327327 }
328328
329- if (
330- ( table . theme . scrollStyle . horizontalVisible && table . theme . scrollStyle . horizontalVisible === 'focus' ) ||
331- ( ! table . theme . scrollStyle . horizontalVisible && table . theme . scrollStyle . visible === 'focus' )
332- ) {
329+ const scrollStyle = table . theme . scrollStyle ;
330+ const horizontalVisible = scrollStyle ?. horizontalVisible ?? scrollStyle ?. visible ;
331+ const verticalVisible = scrollStyle ?. verticalVisible ?? scrollStyle ?. visible ;
332+ const barToSide = scrollStyle ?. barToSide ?? false ;
333+
334+ if ( ! barToSide && horizontalVisible === 'focus' ) {
333335 stateManager . hideHorizontalScrollBar ( ) ;
334336 }
335- if (
336- ( table . theme . scrollStyle . verticalVisible && table . theme . scrollStyle . verticalVisible === 'focus' ) ||
337- ( ! table . theme . scrollStyle . verticalVisible && table . theme . scrollStyle . visible === 'focus' )
338- ) {
337+ if ( ! barToSide && verticalVisible === 'focus' ) {
339338 stateManager . hideVerticalScrollBar ( ) ;
340339 }
341340
@@ -981,6 +980,61 @@ export function bindTableGroupListener(eventManager: EventManager) {
981980 stateManager . endSelectCells ( ) ;
982981 }
983982 } ) ;
983+ // 当 barToSide=true 且 visible='focus' 时,hover 到整个 canvas 区域都应显示滚动条
984+ const scrollStyle = table . theme . scrollStyle ;
985+ const barToSide = scrollStyle ?. barToSide ?? false ;
986+ const horizontalVisible = scrollStyle ?. horizontalVisible ?? scrollStyle ?. visible ;
987+ const verticalVisible = scrollStyle ?. verticalVisible ?? scrollStyle ?. visible ;
988+ const shouldShowScrollOnCanvasHover = barToSide && horizontalVisible === 'focus' ;
989+ const shouldShowVScrollOnCanvasHover = barToSide && verticalVisible === 'focus' ;
990+
991+ if ( shouldShowScrollOnCanvasHover || shouldShowVScrollOnCanvasHover ) {
992+ table . scenegraph . stage . addEventListener ( 'pointerenter' , ( e : FederatedPointerEvent ) => {
993+ // 检查事件是否来自当前表格的 canvas 区域(包括空白区域)
994+ const target = e . target as any ;
995+ const isEventFromCurrentTableCanvas =
996+ target === table . scenegraph . stage || target ?. isDescendantsOf ?.( table . scenegraph . stage ) ;
997+ if ( ! isEventFromCurrentTableCanvas ) {
998+ return ;
999+ }
1000+ if ( shouldShowScrollOnCanvasHover ) {
1001+ const relativeX = e . x - table . tableX ;
1002+ const target =
1003+ table . options . scrollFrozenCols &&
1004+ table . getFrozenColsOffset ?.( ) > 0 &&
1005+ relativeX >= 0 &&
1006+ relativeX < table . getFrozenColsWidth ( )
1007+ ? 'frozen'
1008+ : table . options . scrollRightFrozenCols &&
1009+ table . getRightFrozenColsOffset ?.( ) > 0 &&
1010+ relativeX > table . tableNoFrameWidth - table . getRightFrozenColsWidth ( )
1011+ ? 'rightFrozen'
1012+ : 'body' ;
1013+ stateManager . showHorizontalScrollBar ( false , target ) ;
1014+ }
1015+ if ( shouldShowVScrollOnCanvasHover ) {
1016+ stateManager . showVerticalScrollBar ( ) ;
1017+ }
1018+ } ) ;
1019+
1020+ table . scenegraph . stage . addEventListener ( 'pointerleave' , ( e : FederatedPointerEvent ) => {
1021+ // 检查鼠标是否离开了整个 canvas 区域
1022+ const relatedTarget = e . relatedTarget as any ;
1023+ const isLeavingCanvas =
1024+ ! relatedTarget ||
1025+ ( relatedTarget !== table . scenegraph . stage && ! relatedTarget . isDescendantsOf ?.( table . scenegraph . stage ) ) ;
1026+ if ( ! isLeavingCanvas ) {
1027+ return ;
1028+ }
1029+ if ( shouldShowScrollOnCanvasHover ) {
1030+ stateManager . hideHorizontalScrollBar ( ) ;
1031+ }
1032+ if ( shouldShowVScrollOnCanvasHover ) {
1033+ stateManager . hideVerticalScrollBar ( ) ;
1034+ }
1035+ } ) ;
1036+ }
1037+
9841038 table . scenegraph . stage . addEventListener ( 'pointermove' , ( e : FederatedPointerEvent ) => {
9851039 const eventArgsSet : SceneEvent = getCellEventArgsSetWithTable ( e , table ) ;
9861040
0 commit comments