[Units] Shorten durations and make them based on 75 BPM or multiples of 3 frames
The short and long durations were a bit too long in many places where they are used. The veryLongDuration was also shortened to keep the rhythm consistent with the other duration animations.
-
veryShortDuration
has the duration of 3 frames at 60Hz (50ms) -
shortDuration
has the duration of 6 frames at 60Hz (100ms)- From my own experience with qqc2-breeze-style, this is a good duration for transitions that occur after a state change caused by a direct user interaction (e.g., pressed -> normal transition) or for the movement of a switch.
- NN/g also seems to think this is a generally good duration for those kinds of transitions (skip to "Animation Duration", 2/3rds down): https://www.nngroup.com/articles/animation-duration/
-
longDuration
has the duration of 12 frames at 60Hz (200ms) -
veryLongDuration
has the duration of 24 frames at 60Hz (400ms)- The NN/g article also suggests that this is a good maximum duration, but that's not the main reason why I changed it.
It is not currently possible to force each duration to last a consistent amount of frames. That probably wouldn't be desirable anyway since user inputs are not perfectly synced to the display's refresh rate.
Durations are based on 75 Beats Per Minute with 4 beats per measure. 75 BPM allows each time division to indirectly translate to an integer number of milliseconds and an integer number of frames on a 60Hz display.
-
veryShortDuration
is the length of a 1/64 note -
shortDuration
is the length of a 1/32 note -
longDuration
is the length of a 1/16 note -
veryLongDuration
is the length of a 1/8 note
Basing durations on BPM and note lengths is a convenient framework for deciding what length durations should be and hopefully creates a sort of rhythm for animations.
Not directly related to this MR, but worth thinking about:
The only duration we can add now before the names get cumbersome is mediumDuration
, which would probably end up having to be 150ms (dotted 1/32 note) since that's betweeen shortDuration
and longDuration
. It might be a good idea to come up with a more flexible naming system since we might want to have slightly longer and slightly shorter durations in different situations. Although, I suppose using different easing curves could achieve something that feels similar.
-
It could be directly based on note durations, but it seems kind of weird to type out
duration: Units.durations.sixtyFourthNote
in a non-musical context. It would feel better to type outduration: Units.someKindOfBaseDurationUnit / 64
instead and have an HIG page for what kinds of durations to use. We're going to need an HIG page anyway to go in depth on which durations should be used and when anyway. -
We could have no units of duration and have a multiplier that is really only used to make durations specified in milliseconds work with the global animation speed slider. That would look something like this:
duration: 100 * Units.durationMultiplier
. Of course we'd still need an HIG page. -
I know part of the point of Kirigami is to make it easy for developers to follow the HIG, so we could name duration units after common purposes for those units. However, that has the potential to get messy when names are used for situations that they have little to do with, but the values they're associated with are just right.
We should also consider units of velocity for SmoothedAnimations. The duration an animation needs may vary depending on how far it has to travel, so velocity might be a more natural fit than duration in various situations and we don't currently have any way to set units of velocity in a way that respects global animation speed settings.