Gesture Recognizers in iOS · Deceleration |

This is a companion discussion topic for the original entry at

It’s not easy to read? Of course when there is no explanation why you put finalPoint.x = min(max(finalPoint.x, bounds.minX), bounds.maxX) there. Anyone with basic knowledge of programming would understand what this line do, but for beginners of this course, we need explanation behind the logic of why you need to take the min those maxes.

@jessycatterwaul @jcatterwaul Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hi Michael!

I thought it would be enough to say what we’re going to code before doing it (the line about clamping). Please let me know if you know of a way you’d prefer to have heard that described.

This min/max combo as we wrote it is ubiquitous, but I don’t think it matters who you are: you might have the pattern memorized, but it’s not literally easy to parse in the way a “clamp” function is.

I decided not to devote any time to a diagram because I knew it was going to be rewritten later, but if you think that’s the way to go, I’m open to including that in an update.