Use roundedEquals to test vw and vh units (#2264)

This commit is contained in:
Jason Eberle
2018-03-04 20:58:55 -05:00
committed by patrick kettner
parent 0239cb14df
commit baab13f486
2 changed files with 5 additions and 4 deletions

View File

@@ -14,10 +14,11 @@
}]
}
!*/
define(['Modernizr', 'testStyles', 'computedStyle'], function(Modernizr, testStyles, computedStyle) {
define(['Modernizr', 'testStyles', 'computedStyle', 'roundedEquals'], function(Modernizr, testStyles, computedStyle, roundedEquals) {
testStyles('#modernizr { height: 50vh; }', function(elem) {
var height = parseInt(window.innerHeight / 2, 10);
var compStyle = parseInt(computedStyle(elem, null, 'height'), 10);
Modernizr.addTest('cssvhunit', compStyle == height);
Modernizr.addTest('cssvhunit', roundedEquals(compStyle, height));
});
});

View File

@@ -14,11 +14,11 @@
}]
}
!*/
define(['Modernizr', 'testStyles', 'computedStyle'], function(Modernizr, testStyles, computedStyle) {
define(['Modernizr', 'testStyles', 'computedStyle', 'roundedEquals'], function(Modernizr, testStyles, computedStyle, roundedEquals) {
testStyles('#modernizr { width: 50vw; }', function(elem) {
var width = parseInt(window.innerWidth / 2, 10);
var compStyle = parseInt(computedStyle(elem, null, 'width'), 10);
Modernizr.addTest('cssvwunit', compStyle == width);
Modernizr.addTest('cssvwunit', roundedEquals(compStyle, width));
});
});