Skip to content

Instantly share code, notes, and snippets.

@ederchrono
Created May 15, 2019 06:44
Show Gist options
  • Save ederchrono/26b5f98e82508145448f5534cb605f38 to your computer and use it in GitHub Desktop.
Save ederchrono/26b5f98e82508145448f5534cb605f38 to your computer and use it in GitHub Desktop.
const clampPosition = (position) => {
// constrain image to be between 0 and device width
return Math.max(Math.min(position, DEVICE_WIDTH), 0)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment