File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -217,6 +217,12 @@ const snap = {
217
217
218
218
interact . createSnapGrid = function ( grid ) {
219
219
return function ( x , y ) {
220
+ const limits = grid . limits || {
221
+ left : - Infinity ,
222
+ right : Infinity ,
223
+ top : - Infinity ,
224
+ bottom : Infinity ,
225
+ } ;
220
226
let offsetX = 0 ;
221
227
let offsetY = 0 ;
222
228
@@ -228,8 +234,8 @@ interact.createSnapGrid = function (grid) {
228
234
const gridx = Math . round ( ( x - offsetX ) / grid . x ) ;
229
235
const gridy = Math . round ( ( y - offsetY ) / grid . y ) ;
230
236
231
- const newX = gridx * grid . x + offsetX ;
232
- const newY = gridy * grid . y + offsetY ;
237
+ const newX = Math . max ( limits . left , Math . min ( limits . right , gridx * grid . x + offsetX ) ) ;
238
+ const newY = Math . max ( limits . top , Math . min ( limits . bottom , gridy * grid . y + offsetY ) ) ;
233
239
234
240
return {
235
241
x : newX ,
You can’t perform that action at this time.
0 commit comments