Here I am

home

Path snapping in interact.js

29 Sep 2013

interact.js just got even snappier. `path` snapping now lets you set fixed axis origin points or use functions to return the points that the pointer should snap to.
interact.modifiers.snap({
  targets: [{
    x,
    y: 75,
    range: Infinity
  }]
})
interact.modifiers.snap({
  targets: [(x, y) => {
    return {
        x,
        y: (75 + 50 * Math.sin(x * 0.04)),
        range: Infinity
    };
  }]
})
interact.modifiers.snap({
  targets: [(x, y) => {
    return {
        y: x % 100 < 50? 50: 100,
        range: Infinity
    };
  }]
})