Skip to content

prefers-reduced-motion #65

@rober423

Description

@rober423

looking at your animation and velocity files in 4X/Modules, and I noticed there's no mention of prefers-reduced-motion CSS. I would think you would want the animation module to be sensitive to prefers-reduced-motion without needing the developer to add it on later. For your case, I would suggest forcing a duration of 1ms if prefers-reduced-motion is reduce, if what I'm seeing at line 3554 of Velocity.js is what I think it is.

For example, I am currently working on creating a pull request for JGrowl and I made the following function to help with this:

const prefersReduced = window.matchMedia((prefers-reduced-motion: reduce)) === true || window.matchMedia((prefers-reduced-motion: reduce)).matches === true;

//function parameter func must include $(this).show() or .remove()/.hide() for use when prefersReduced is true.
$.fn.jGrowlAnimate = function( properties, duration, easing, func, funcArgs ) {
if (prefersReduced) {
if (typeof func === 'function') func.apply(this, funcArgs);
return $(this);
}
else {
return $(this).animate(properties, duration, easing, function() {
if (typeof func === 'function') func.apply(this, funcArgs);
});
}
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions