2015-01-22 22 views
8

chcę użyć właściwości CSS w:Testowanie CSS "mix-blend-trybie"

mix-blend-mode: soft-light; 

I będę testować przez modernizr dla awaryjna bla bla ...

Testowany:

Modernizr.mixblendmode //undefined 
Modernizr.testProp('mixblendmode'); //false 
Modernizr.addTest('mixblendmode'); // no-mixblendmode 

Czego mi brakuje?

Testowane w Firefoksie, CSS, praca, ale jak przetestować w Modernizr?

+0

Proszę powiedzieć, dlaczego -1 i nie na temat? – l2aelba

Odpowiedz

11

Got go:

Modernizr.addTest('mix-blend-mode', function(){ 
    return Modernizr.testProp('mixBlendMode'); 
}); 

(lub bez modernizr)

if('CSS' in window && 'supports' in window.CSS) { 

    var support = window.CSS.supports('mix-blend-mode','multiply'); 

    /* Add class like Modernizr */ 
    /* -- jQuery -- */ 
    $('html').addClass(support?'mix-blend-mode':'no-mix-blend-mode'); // jQuery 
    /* -- Pure JS -- */ 
    document.getElementsByTagName('html')[0].className += support ? ' mix-blend-mode' : ' no-mix-blend-mode'; 
    /* -- Pure JS (IE9+) -- */ 
    document.querySelector('html').classList.add(support ? 'mix-blend-mode' : 'no-mix-blend-mode'); 
} 

(lub CSS)

@supports(mix-blend-mode:multiply) { 

} 

Nr: https://dev.opera.com/articles/getting-to-know-css-blend-modes/

mogę używać: http://caniuse.com/#feat=css-mixblendmode

3

Modernizr obecnie nie obsługuje tej funkcji. Od Modernizr/issues/1388:

niestety, "[...] w niektórych przeglądarkach, mix-blend-mode jest realizowany; właściwość jest ważna, zautomatyzowane testy przechodzą, ale bez mieszania rzeczywiście zachodzi" - http://blogs.adobe.com/webplatform/2013/09/12/browser-support-matrix-for-css-blending/

+0

:(aha .... dziękuję bardzo ale alternatywa? – l2aelba

+0

@ l2aelba naprawdę nie. Możesz stworzyć test podobny do [background-blend-mode] (https://github.com/Modernizr/Modernizr/pull/ 1392/files), ale nadal nie wiesz na pewno, czy przeglądarka faktycznie coś robi. – Stijn

+0

'window.CSS.supports ('mix-blend-mode', 'soft-light');'? – l2aelba