DRJO Posted September 22, 2021 Posted September 22, 2021 How can we easily disable snapping if the nearest snap point is not within a proximity of a snap point ? I didn't create a pen because I am using members inertia plugin. Many thanks
Solution OSUblake Posted September 22, 2021 Solution Posted September 22, 2021 Welcome to forums @DRJO You can use the trial version of all our plugins on CodePen, CodeSandbox, etc. You should use a snap points function, and if the point isn't within a certain radius, return the point that was passed in. Otherwise, return the closest point. snap: { points: function(point) { // now you can run whatever logic you want in here, like // looping through the other boxes to see which is closest // and if it's within a certain distance, apply the snapping. // Just return the adjusted point with x/y properties or // if it's not within the range, return the original point: return point; } } This thread should help give you some ideas. 3
DRJO Posted September 29, 2021 Author Posted September 29, 2021 this.dragger = Draggable.create('#progressbar__handle', { type: 'x', lockAxis: true, bounds: '#progressbar', snap: (value) => { let val = this.offsets.filter((n) => { return Math.abs(n - value) < 35 }) if (val.length) return val[0] }, overshootTolerance: 0.5 }) Cheers @OSUBlake, sharing my solution above. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now