@@ -1026,7 +1026,7 @@ export default function sortableContainer(
1026
1026
} ;
1027
1027
1028
1028
keyUpdatePosition = ( disableTransition = false ) => {
1029
- const { transitionDuration} = this . props ;
1029
+ const { transitionDuration, disableAutoscroll } = this . props ;
1030
1030
const nodes = this . manager . getOrderedRefs ( this . manager . activeKeyLift . collection ) ;
1031
1031
const targetIndex = getTargetIndex ( this . newIndex , this . prevIndex , this . index ) ;
1032
1032
const targetNode = nodes [ nodes . findIndex ( ( { node} ) => node . sortableInfo . index === targetIndex ) ] ;
@@ -1062,8 +1062,10 @@ export default function sortableContainer(
1062
1062
} ;
1063
1063
1064
1064
// Correct translate
1065
- translate . x = Math . max ( Math . min ( translate . x , this . maxTranslate . x ) , this . minTranslate . x ) ;
1066
- translate . y = Math . max ( Math . min ( translate . y , this . maxTranslate . y ) , this . minTranslate . y ) ;
1065
+ if ( ! disableAutoscroll ) {
1066
+ translate . x = Math . max ( Math . min ( translate . x , this . maxTranslate . x ) , this . minTranslate . x ) ;
1067
+ translate . y = Math . max ( Math . min ( translate . y , this . maxTranslate . y ) , this . minTranslate . y ) ;
1068
+ }
1067
1069
1068
1070
if ( transitionDuration && ! disableTransition ) {
1069
1071
this . helper . style [
@@ -1074,7 +1076,9 @@ export default function sortableContainer(
1074
1076
translate . x
1075
1077
} px,${ translate . y } px,0)`;
1076
1078
1077
- this . keyAutoscroll ( overflow ) ;
1079
+ if ( ! disableAutoscroll ) {
1080
+ this . keyAutoscroll ( overflow ) ;
1081
+ }
1078
1082
} ;
1079
1083
1080
1084
keyAutoscroll = ( { left, right, top, bottom} ) => {
@@ -1103,17 +1107,20 @@ export default function sortableContainer(
1103
1107
for ( let i = 0 , len = nodes . length ; i < len ; i ++ ) {
1104
1108
const { node} = nodes [ i ] ;
1105
1109
const index = node . sortableInfo . index ;
1110
+ const offsetWidth = this . width > node . offsetWidth ? node . offsetWidth / 2 : this . width / 2 ;
1106
1111
1107
1112
const translate = {
1108
1113
x : 0 ,
1109
1114
y : 0 ,
1110
1115
} ;
1111
- let { edgeOffset} = nodes [ i ] ;
1116
+ let { edgeOffset, boundingRect } = nodes [ i ] ;
1112
1117
1113
1118
// If we haven't cached the node's offsetTop / offsetLeft value
1114
1119
if ( ! edgeOffset ) {
1115
1120
edgeOffset = getEdgeOffset ( node , this . container ) ;
1121
+ boundingRect = node . getBoundingClientRect ( ) ;
1116
1122
nodes [ i ] . edgeOffset = edgeOffset ;
1123
+ nodes [ i ] . boundingRect = boundingRect ;
1117
1124
}
1118
1125
1119
1126
// Get a reference to the next and previous node
@@ -1124,6 +1131,7 @@ export default function sortableContainer(
1124
1131
// We need this for calculating the animation in a grid setup
1125
1132
if ( nextNode && ! nextNode . edgeOffset ) {
1126
1133
nextNode . edgeOffset = getEdgeOffset ( nextNode . node , this . container ) ;
1134
+ nextNode . boundingRect = nextNode . node . getBoundingClientRect ( ) ;
1127
1135
}
1128
1136
1129
1137
// If the node is the one we're currently animating, skip it
@@ -1145,12 +1153,25 @@ export default function sortableContainer(
1145
1153
// grid
1146
1154
if ( index < this . index && index >= this . newIndex ) {
1147
1155
// right/down 1
1148
- translate . x = nextNode . edgeOffset . left - edgeOffset . left ;
1149
- translate . y = nextNode . edgeOffset . top - edgeOffset . top ;
1156
+ translate . x = this . width + this . marginOffset . x ;
1157
+ if ( nextNode &&
1158
+ ( boundingRect . left + translate . x + node . offsetWidth >
1159
+ this . containerBoundingRect . left + offsetWidth + this . containerBoundingRect . width )
1160
+ ) {
1161
+ const widthCorrection =
1162
+ node . offsetWidth - nextNode . boundingRect . width +
1163
+ nextNode . boundingRect . width - this . width ;
1164
+ translate . x = nextNode . edgeOffset . left - edgeOffset . left - widthCorrection ;
1165
+ translate . y = nextNode . edgeOffset . top - edgeOffset . top ;
1166
+ }
1150
1167
} else if ( index > this . index && index <= this . newIndex ) {
1151
1168
// left/up 1
1152
- translate . x = prevNode . edgeOffset . left - edgeOffset . left ;
1153
- translate . y = prevNode . edgeOffset . top - edgeOffset . top ;
1169
+ translate . x = - ( this . width + this . marginOffset . x ) ;
1170
+ if ( prevNode && boundingRect . left + translate . x < this . containerBoundingRect . left - offsetWidth ) {
1171
+ const widthCorrection = prevNode . boundingRect . width - this . width ;
1172
+ translate . x = prevNode . edgeOffset . left - edgeOffset . left + widthCorrection ;
1173
+ translate . y = prevNode . edgeOffset . top - edgeOffset . top ;
1174
+ }
1154
1175
}
1155
1176
} else {
1156
1177
// x
0 commit comments