2

Is it possible to see if iOS 11’s Smart Invert is enabled using either JavaScript or CSS? I’d like my websites to work with it, seeing I (and probably a lot of other people) use it a lot.

Jip
  • 21
  • 1
  • 3

1 Answers1

0

Based on the answer posted in the comments above and using Modernizr.js you could do this fairly easily with a custom test.

Modernizr.addTest('colorinvert', accessibilityIgnoresInvertColors in window && !accessibilityIgnoresInvertColors);

This will add a class to the page's <html> element called colorinvert if the colors are being inverted, and nocolorinvert if not.

This should make it easy to apply custom css or javascript logic when the colors are inverted.

Vanilla js could analyze this property and do the same thing as modernizr as well -- something like this run during initial page load should work:

var classname = "colorinvert";
if(typeof(window["accessibilityIgnoresInvertColors"]) === "undefined" || accessibilityIgnoresInvertColors) classname = "no" + classname;

document.getElementsByTagName("html")[0].classList.add(classname);
Will P.
  • 8,437
  • 3
  • 36
  • 45