Skip to main content
Inspiring
August 2, 2022
Answered

How to limit slider range from 0 to 100, with integers only?

  • August 2, 2022
  • 1 reply
  • 2361 views

Greetings,

 

How can I limit a slider input and output range from range from 0 to 100, and have the slider round off to integers only when sliding the slider? Thanks for any help on this 🙂

This topic has been closed for replies.
Correct answer Roland Kahlenberg

Try this - 

const myValue = thisProperty;
Math.round(clamp(myValue,0,100))



1 reply

Roland Kahlenberg
Roland KahlenbergCorrect answer
Legend
August 2, 2022

Try this - 

const myValue = thisProperty;
Math.round(clamp(myValue,0,100))



Very Advanced After Effects Training | Adaptive & Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV
Mathias Moehl
Community Expert
Community Expert
August 2, 2022

In case you keyframe the slider: Just note that Roland's expression does not only round keyframes values, but also all the interpolation between them (this may or may not be what you want).

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
persystAuthor
Inspiring
August 2, 2022

Hi Mathias, thanks for the additional info, something for me to be aware of.