In diesem Artikel wird der Beispielcode für den HTML5-Blindeffekt vorgestellt und mit allen geteilt. Die Details lauten wie folgt:
Einführung in die Implementierungsmethode:
1. Das Jalousie-Layout wird dem Inhaltslayout mit Positionierung überlagert (Position: absolut) und der Hintergrund wird auf transparent gesetzt (Hintergrundfarbe: transparent).
2. Keyframes definieren das Ein- und Ausblenden (Transparenzänderung) und die Animation von Blindfenstereffekten.
3. Starten Sie die Animation, indem Sie das className-Attribut des DOM festlegen, animator.className = 'baiyeWindow'; hören Sie sich das Animationsabschlussereignis 'animationend' an und löschen Sie das className-Attribut.
4. Rufen Sie im Falle eines Inhaltslayoutwechsels die Startanimationsmethode auf. Beide Layouts müssen das Wechselereignis ng-click=switchLayout() binden.
5. Ablaufdiagramm der Animationsausführung:
HTML-Code:
<!--Layout zur Anzeige des Jalousieneffekts--Inhalt wechseln--><div id=fadeInOut class=content ng-click=switchLayout()>...</div><!--Layout-Layout--> < ul id=baiyeWindow ng-click=switchLayout()> <li><div class=ye></div></li> <li><div class=ye></div></li> <li>< div class=ye></div></li> <li><div class=ye></div></li> </ul>
CSS-Stilcode:
//Ein- und Aussprechen effect.fade-animation{ @-webkit-keyframes fadeInOut { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1 } } @keyframes fadeInOut { 0% { Deckkraft: 1; } 50 % { Deckkraft: 0 } 100 % { Deckkraft: 1; } Animation: fadeInOut 1s Easy-In; //Blinds effect.baiyeWindow{ height: 1.68rem; top : 1.2rem; li{ height: 0.42rem; line-height: 40px; transparent; .ye{ -webkit-animation: slideOut 1s easy-in-out; width: 100%; : relative; top: 50 % } } @-webkit-keyframes slideOut { 0 % { top: 50 % } padding-bottom: 40px; top: 0; } @keyframes slideOut { 0% { padding-bottom: 0; } }
JS-Code:
//Layout wechseln $scope.switchLayout = function(){ ... $scope.startBaiYeWindow(); //Nachdem die Animation 0,5 Sekunden lang gestartet wurde, steuern Sie das Layout, um $timeout(function () { if ($ Scope.show) { $scope.show = false; } else { .... } }, 500);//Animation starten $scope.startBaiYeWindow = function () { var animator = document.getElementById('baiyeWindow'); var animatorFadeInOut = document.getElementById('fadeInOut'); animator.addEventListener('animationend', function () { animator.className = ''; animatorFadeInOut.className = 'content'; }) ; $timeout(function () { animator.className = 'baiyeWindow'; animatorFadeInOut.className = 'content fade-animation' }, 0);
Das Obige ist der gesamte Inhalt dieses Artikels. Ich hoffe, dass er für das Studium aller hilfreich ist. Ich hoffe auch, dass jeder das VeVb Wulin Network unterstützt.