css-backgroundposition-xy.js 749 B

123456789101112131415
  1. /*
  2. Allan Lei https://github.com/allanlei
  3. Check adapted from https://github.com/brandonaaron/jquery-cssHooks/blob/master/bgpos.js
  4. Test: http://jsfiddle.net/allanlei/R8AYS/
  5. */
  6. Modernizr.addTest('bgpositionxy', function() {
  7. return Modernizr.testStyles('#modernizr {background-position: 3px 5px;}', function(elem) {
  8. var cssStyleDeclaration = window.getComputedStyle ? getComputedStyle(elem, null) : elem.currentStyle;
  9. var xSupport = (cssStyleDeclaration.backgroundPositionX == '3px') || (cssStyleDeclaration['background-position-x'] == '3px');
  10. var ySupport = (cssStyleDeclaration.backgroundPositionY == '5px') || (cssStyleDeclaration['background-position-y'] == '5px');
  11. return xSupport && ySupport;
  12. });
  13. });