implement minWidth and minHeight options (code from Cerdic fork)