File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -160,28 +160,30 @@ export class GridStackEngine {
160160
161161 let collide : GridStackNode ;
162162 let overMax = 0.5 ; // need >50%
163- collides . forEach ( n => {
164- if ( n . locked || ! n . _rect ) return ;
163+ for ( let n of collides ) {
164+ if ( n . locked || ! n . _rect ) {
165+ break ;
166+ }
165167 let r2 = n . _rect ; // overlapping target
166168 let yOver = Number . MAX_VALUE , xOver = Number . MAX_VALUE ;
167169 // depending on which side we started from, compute the overlap % of coverage
168170 // (ex: from above/below we only compute the max horizontal line coverage)
169171 if ( r0 . y < r2 . y ) { // from above
170172 yOver = ( ( r . y + r . h ) - r2 . y ) / r2 . h ;
171- } else if ( r0 . y + r0 . h > r2 . y + r2 . h ) { // from below
173+ } else if ( r0 . y + r0 . h > r2 . y + r2 . h ) { // from below
172174 yOver = ( ( r2 . y + r2 . h ) - r . y ) / r2 . h ;
173175 }
174176 if ( r0 . x < r2 . x ) { // from the left
175177 xOver = ( ( r . x + r . w ) - r2 . x ) / r2 . w ;
176- } else if ( r0 . x + r0 . w > r2 . x + r2 . w ) { // from the right
178+ } else if ( r0 . x + r0 . w > r2 . x + r2 . w ) { // from the right
177179 xOver = ( ( r2 . x + r2 . w ) - r . x ) / r2 . w ;
178180 }
179181 let over = Math . min ( xOver , yOver ) ;
180182 if ( over > overMax ) {
181183 overMax = over ;
182184 collide = n ;
183185 }
184- } ) ;
186+ }
185187 o . collide = collide ; // save it so we don't have to find it again
186188 return collide ;
187189 }
You can’t perform that action at this time.
0 commit comments