@@ -34,7 +34,8 @@ import {
3434 throttle ,
3535 scrollBy ,
3636 clone ,
37- expando
37+ expando ,
38+ getContentRect
3839} from './utils.js' ;
3940
4041
@@ -1788,21 +1789,23 @@ function _unsilent() {
17881789}
17891790
17901791function _ghostIsFirst ( evt , vertical , sortable ) {
1791- let rect = getRect ( getChild ( sortable . el , 0 , sortable . options , true ) ) ;
1792+ let firstElRect = getRect ( getChild ( sortable . el , 0 , sortable . options , true ) ) ;
1793+ const sortableContentRect = getContentRect ( sortable . el ) ;
17921794 const spacer = 10 ;
17931795
17941796 return vertical ?
1795- ( ( evt . clientX < rect . left - spacer ) || ( evt . clientY < rect . top && evt . clientX < rect . right ) ) :
1796- ( ( evt . clientY < rect . top - spacer ) || ( evt . clientY < rect . bottom && evt . clientX < rect . left ) )
1797+ ( evt . clientX < sortableContentRect . left - spacer || evt . clientY < firstElRect . top && evt . clientX < firstElRect . right ) :
1798+ ( evt . clientY < sortableContentRect . top - spacer || evt . clientY < firstElRect . bottom && evt . clientX < firstElRect . left )
17971799}
17981800
17991801function _ghostIsLast ( evt , vertical , sortable ) {
1800- let rect = getRect ( lastChild ( sortable . el , sortable . options . draggable ) ) ;
1802+ const lastElRect = getRect ( lastChild ( sortable . el , sortable . options . draggable ) ) ;
1803+ const sortableContentRect = getContentRect ( sortable . el ) ;
18011804 const spacer = 10 ;
18021805
18031806 return vertical ?
1804- ( evt . clientX > rect . right + spacer || evt . clientX <= rect . right && evt . clientY > rect . bottom && evt . clientX >= rect . left ) :
1805- ( evt . clientX > rect . right && evt . clientY > rect . top || evt . clientX <= rect . right && evt . clientY > rect . bottom + spacer ) ;
1807+ ( evt . clientX > sortableContentRect . right + spacer || evt . clientY > lastElRect . bottom && evt . clientX > lastElRect . left ) :
1808+ ( evt . clientY > sortableContentRect . bottom + spacer || evt . clientX > lastElRect . right && evt . clientY > lastElRect . top ) ;
18061809}
18071810
18081811function _getSwapDirection ( evt , target , targetRect , vertical , swapThreshold , invertedSwapThreshold , invertSwap , isLastTarget ) {
0 commit comments