2016-12-19 40 views
14

Transformacja 3D w Firefoksie wydaje się mieć problemy z z-index. Wydaje mi się, że renderowanie "ignoruje" położenie 3D Z, i po prostu używa indeksu Z z DOM. Co ciekawe, gdy widoczna część jest mniejsza, tak że widoczna jest tylko część koła, indeks Z jest nagle poprawny, chociaż pojawiają się inne artefakty.Przekształcanie z-indeksu 3D z firefoxem, zachowanie-3d nie zachowane

Istnieje ta demonstracja błędu przecięcia, która jest zainfekowana od 2011 roku w Firefoksie, ale moje kręgi nie przecinają się - mam więc nadzieję, że jest to jakoś możliwe. http://jsfiddle.net/yNfQX/21/

Firefox Bugtrackera: https://bugzilla.mozilla.org/show_bug.cgi?id=689498

.perspective { 
 
    width: 400px; 
 
    height: 400px; 
 
    position: relative; 
 
    perspective: 3000px; 
 
    display: block; 
 
} 
 
.dcw { 
 
    width: 100%; 
 
    height: 100%; 
 
    position: absolute; 
 
    transform-style: preserve-3d; 
 
} 
 
.dc { 
 
    top: calc(50% - 44px); 
 
    left: calc(50% - 44px); 
 
    margin: auto; 
 
    border-radius: 50%; 
 
    position: absolute; 
 
    cursor: pointer; 
 
    transform-style: preserve-3d; 
 
    width: 88px; 
 
    height: 88px; 
 
    border: 1px solid black; 
 
}
<div class="perspective"> 
 
    <div class="dcw"> 
 
    <div class="dc" style="background-color: rgba(255,0,0,1);transform: rotateZ(0deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(251,4,4,1);transform: rotateZ(10deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(248,7,7,1);transform: rotateZ(20deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(244,11,11,1);transform: rotateZ(30deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(241,14,14,1);transform: rotateZ(40deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(237,18,18,1);transform: rotateZ(50deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(234,21,21,1);transform: rotateZ(60deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(230,25,25,1);transform: rotateZ(70deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(227,28,28,1);transform: rotateZ(80deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(223,32,32,1);transform: rotateZ(90deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(219,36,36,1);transform: rotateZ(100deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(216,39,39,1);transform: rotateZ(110deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(212,43,43,1);transform: rotateZ(120deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(209,46,46,1);transform: rotateZ(130deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(205,50,50,1);transform: rotateZ(140deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(202,53,53,1);transform: rotateZ(150deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(198,57,57,1);transform: rotateZ(160deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(195,60,60,1);transform: rotateZ(170deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(191,64,64,1);transform: rotateZ(180deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(187,68,68,1);transform: rotateZ(190deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(184,71,71,1);transform: rotateZ(200deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(180,75,75,1);transform: rotateZ(210deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(177,78,78,1);transform: rotateZ(220deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(173,82,82,1);transform: rotateZ(230deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(170,85,85,1);transform: rotateZ(240deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(166,89,89,1);transform: rotateZ(250deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(163,92,92,1);transform: rotateZ(260deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(159,96,96,1);transform: rotateZ(270deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(155,100,100,1);transform: rotateZ(280deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(152,103,103,1);transform: rotateZ(290deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(148,107,107,1);transform: rotateZ(300deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(145,110,110,1);transform: rotateZ(310deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(141,114,114,1);transform: rotateZ(320deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(138,117,117,1);transform: rotateZ(330deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(134,121,121,1);transform: rotateZ(340deg) translateX(125px) rotateX(-60deg); "></div> 
 
    <div class="dc" style="background-color: rgba(131,124,124,1);transform: rotateZ(350deg) translateX(125px) rotateX(-60deg); "></div> 
 
    </div> 
 
</div>

JSFiddle niego: https://jsfiddle.net/gvquf0g6/

Jak powinno wyglądać (zdjęcie z Chrome): How it should look like (screenshot from Chrome):

z-index problem (zrzut ekranu z Firefoksa):

z-index issue (screenshot from Firefox)

Artifact problem i pracy z-index z częściowym widocznym kołem (zrzut ekranu z Firefoksa): enter image description here enter image description here

Przenoszenie kursor myszy nad artefaktami (brakujące bloki) wypełnia je tak, jak powinny być po pierwszym renderowaniu.

+1

Hm, wydaje się tylko częściowo działa dla mnie w Chrome. macOS 10.12.2, Chrome 55.0.2883.95 (64-bitowy). [praca] (https://snag.gy/D8f9K0.jpg) i [nie] (https://snag.gy/6TdINf.jpg). – Coder256

+1

Na Firefoksie 53 wygląda [tak] (https://i.stack.imgur.com/EE77F.png), z powodu [bug 1274673] (https://bugzilla.mozilla.org/show_bug.cgi?id = 1274673) – Oriol

+1

@Oriol - Mam nadzieję, że flaga "rozwiązana" jest prawdziwa. Jak długo potrwa 53 lata, ponieważ niedawno wydali [50.1.0] (https://www.mozilla.org/en-US/firefox/50.1.0/releasenotes/) 13 grudnia 2016 roku? –

Odpowiedz

6

Niestety, zamawianie z zamkiem nie działa poprawnie z warstwami cyklicznymi. Jest to znany problem, którego Firefox w ogóle nie obsługuje. To stary błąd przeglądarki Firefox i nie można go naprawić, dopóki nie naprawi błędu w przeglądarce.

2

W międzyczasie znalazłem rozwiązanie, ale nie jest to, co chciałem i to też nie jest doskonałe, pojawiają się artefakty i animowanie go z przejściem daje wiele problemów. Ale jako statyczny "obraz" wydaje się działać.

Zasadniczo okrąg jest narysowany dwukrotnie, raz dla niebieskiej połówki i raz dla zielonej połówki, ale tylko połowa z nich jest widoczna.

W Chrome jest zepsuty, można go rozwiązać ... ale dbałem tylko o firefox. (i to było naprawdę szybkie i brudne kodowania, po prostu spojrzał na niego ponownie, i zauważyłem dwukrotnie uznany funkcję drawCircle2 ...) https://jsfiddle.net/7w31uLsL/

$dcw = $(".dcw"); 
 
var newElement; 
 
var center = 300; 
 
var distance = 200, 
 
    color; 
 
for (var i = 0; i < 360; i = i + 10) { 
 
    color = 20 + Math.round((128/360) * i); 
 
    color2 = 220 - Math.round((128/360) * i); 
 
    
 
    $(drawCircle2(color,color2,i,distance)).appendTo($dcw); 
 
} 
 

 
function drawCircle2(color,color2,rotation,distance) { 
 
\t return '<div class="circle" style="transform: translate3d(0,0,0) rotateZ(' + rotation + 'deg) translateX('+distance+'px) rotateX(10deg);">' + 
 
    '<div style="background-color: rgba(' + color + ',0,0,1);"></div>' + 
 
    '<div style="background-color: rgba(' + color + ',0,0,1);"></div>' + 
 
'</div>'; 
 
} 
 

 
function drawCircle2(color,color2,rotation,distance) { 
 
\t return '<div class="circle2" style="background-color: rgba(' + color + ',0,0,1);transform: translate3d(0,0,0) rotateZ(' + rotation + 'deg) translateX('+distance+'px) rotateX(10deg);">' + 
 
'</div>'; 
 
}
.color-wheel { 
 
    width: 600px; 
 
    height: 600px; 
 
    position: relative; 
 
    perspective: 3000px; 
 
    display: block; 
 
} 
 

 
.dcw { 
 
    top: 0; 
 
    bottom:0; 
 
    height: 100%; 
 
    width: 50%; 
 
    position: absolute; 
 
    transform-style: preserve-3d; 
 
    overflow:hidden; 
 
} 
 
.dcw:first-child { 
 
    right:50%; 
 
    left:0; 
 
} 
 
.dcw:last-child { 
 
    right:0; 
 
    left:50%; 
 
} 
 

 
.dcw:first-child .circle2 { 
 
    left: calc(100% - 94px); 
 
} 
 
.dcw:last-child .circle2 { 
 
    left: calc(0% - 94px); 
 
} 
 

 
.circle2 { 
 
    top: calc(50% - 94px); 
 
    margin: auto; 
 
    position: absolute; 
 
    cursor: pointer; 
 
    transform-style: preserve-3d; 
 
    width: 188px; 
 
    height: 188px; 
 
    border-radius:50%; 
 
    border:1px solid black; 
 
} 
 
.circle { 
 
    top: calc(50% - 94px); 
 
    margin: auto; 
 
    position: absolute; 
 
    cursor: pointer; 
 
    transform-style: preserve-3d; 
 
    width: 188px; 
 
    height: 188px; 
 
    border-radius:50%; 
 
    border:1px solid black; 
 
} 
 
.circle div { 
 
    left:0; 
 
    right:0; 
 
    position: absolute; 
 
    transform-style: preserve-3d; 
 
    width: 100%; 
 
    height: 50%; 
 
} 
 
.circle div:first-child { 
 
    
 
    border-top-left-radius:1000px; 
 
    border-top-right-radius:1000px; 
 
    top: 0; 
 
    bottom:50% 
 
} 
 
.circle div:last-child { 
 
    border-bottom-left-radius:1000px; 
 
    border-bottom-right-radius:1000px; 
 
    bottom: 0; 
 
    top:50%; 
 
}
<script type="text/javascript" src="//code.jquery.com/jquery-git.js"></script> 
 
<div class="color-wheel"> 
 
    <div class="dcw" style="background-color:blue;"> 
 

 
    </div> 
 
    <div class="dcw" style="background-color:green;"> 
 

 
    </div> 
 
</div>