Refactored the calculations for state change to be used in dismiss and gesture recognizers.