Skip to content

Instantly share code, notes, and snippets.

@blup
Created July 29, 2015 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blup/6cb835d64a6771931bea to your computer and use it in GitHub Desktop.
Save blup/6cb835d64a6771931bea to your computer and use it in GitHub Desktop.
pct = R.compose(R.divide(R.__, max-min), R.subtract(R.__, min))
left = R.compose(R.multiply(ui.background.offsetWidth-ui.handle.offsetWidth), pct)
pctFormatted = R.compose(R.concat(R.__, '%'), R.multiply(100), pct)
leftFormatted = R.compose(R.concat(R.__, 'px'), left)
ui.foreground.style.width = pctFormatted(val)
ui.handle.style.left = leftFormatted(val)
# vs
pct = (val-min) / (max-min)
left = pct * (ui.background.offsetWidth-ui.handle.offsetWidth)
ui.foreground.style.width = (pct*100) + '%'
ui.handle.style.left = left + 'px'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment