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

Unify snap modes #127

Merged
merged 8 commits into from
Dec 12, 2014
Merged

Unify snap modes #127

merged 8 commits into from
Dec 12, 2014

Conversation

taye
Copy link
Owner

@taye taye commented Dec 10, 2014

No more snap mode. targets array holds all snap targets. The targets can be points or functions that return points. Use interact.createSnapGrid(gridObject) to make a function that snaps to the given grid.

interact('*').draggable({
  snap: {
    targets: [
      // snap to this point
      { x: 100, y: 100, range: 25 },

      // give this function the x and y page coords
      // and snap to the object returned
      function (x, y) {
        return {
          x: x,
          y: (75 + 50 * Math.sin(x * 0.04)),
          range: 40
        };  
      },

      // create a function that snaps to a grid
      interact.createSnapGrid({
        x: 50, 
        y: 50, 
        range: 10,
        offset: { x: 5, y: 10 } // optional
      })  
    ],
    // this range is used if a target doesn't specify it's range
    range: Infinity
  }
})

Clsoes #121

interact('*').draggable({
  snap: {
    targets: [
      // snap to this point
      { x: 100, y: 100, range: 25 },

      // give this function the x and y page coords
      // and snap to the object returned
      function (x, y) {
        return {
          x: x,
          y: (75 + 50 * Math.sin(x * 0.04)),
          range: 40
        };
      },

      // create a function that snaps to a grid
      interact.createSnapGrid({
        x: 50,
        y: 50,
        range: 10,              // optional
        offset: { x: 5, y: 10 } // optional
      })
    ],
    // this range is used if a target doesn't specify it's range
    range: Infinity
  }
})
Fix issue with elementOrigin and snapping functions that return the
given coords – function (x, y) { return { x: x, y: y } }.

Allow snap function to return null.

Re: #126
@taye taye merged commit 44065ae into master Dec 12, 2014
@taye taye deleted the unify-snap-modes branch December 31, 2014 19:58
@taye taye mentioned this pull request Mar 3, 2015
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

Successfully merging this pull request may close these issues.

None yet

1 participant