Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set snap on or off by user #1033

Open
Dutchstyler opened this issue Apr 6, 2024 · 0 comments
Open

Set snap on or off by user #1033

Dutchstyler opened this issue Apr 6, 2024 · 0 comments

Comments

@Dutchstyler
Copy link

Just work with the script for 2 weeks and love it.
But is it possible to set the snap on and off? Tryed a few things but I 'm to new with this to understand.

Thouht to set a input value and read this out to edit the modifier. But that`s not working.

What I have by now:

var gridTarget = interact.snappers.grid({
// can be a pair of x and y, left and top,
// right and bottom, or width, and height
x: document.getElementById("gridsnap").value,
y: 10

});

// target elements with the "draggable" class
interact('.draggable')
.draggable({
// enable inertial throwing
inertia: false,
modifiers: [
/*
interact.modifiers.snap({
targets: [
//interact.snappers.grid({ x: 3.5, y: 3.5 })
gridTarget
],
range: Infinity,
relativePoints: [ { x: 0, y: 0 } ]
}),*/
interact.modifiers.snap({ targets: [gridTarget] }),
interact.modifiers.restrictRect({ //Blijf binnen het huidige element.
restriction: 'parent',
endOnly: false
})
],

// enable autoScroll
autoScroll: false,

listeners: {
  // call this function on every dragmove event
  move: dragMoveListener,

  // call this function on every dragend event
  end (event) {


  }
}

})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant