Canvas max width

Canvas max width
0.0 0

#1

Is there an easy way to set a max Canvas width, which means fitHeight is enabled and during resize until that maxWidth the fitWidth should be false, but after the maxWidth the fitWidth should be true.
Or should I do it manually?