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) {
}
}
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 }) ],
})