2016-11-21 17 views
8

bir Materyal Tasarımı Radyal reaksiyon animasyon oluşturmak için nasılBen malzeme tasarımı Radyal reaksiyon koreografi kılavuz kullanarak rengini değiştirmek benim araç çubuğunu istiyorum

Radial Reaction

Bir açısal 2 geçiş olarak bu uygulamaya istiyorum ama yok bunu nasıl exacly biliyorum:

O şu şekilde görünecektir ..

@Component({ 
... 
    animations: [ 
    trigger('heroState', [ 
    state('inactive', style({ 
     backgroundColor: '#eee', 
     transform: 'scale(1)' 
    })), 
    state('active', style({ 
     backgroundColor: '#cfd8dc', 
     transform: 'scale(1.1)' 
    })), 
    transition('inactive => active', animate('100ms ease-in')), 
    transition('active => inactive', animate('100ms ease-out')) 
    ]) 
    ] 
}) 

cevap

8

Güncelleme: Updated PLUNKER, animationbox-shadow

@Component({ 
    selector: 'my-app', 
    template: ` 
    <div class="head" [@mtSlide]="activeSlide == 1 ? 'active': 'inactive'"> 
     <input id="searchBar" type="search" [@mtTranslate]="activeSlide == 2 ? 'active': 'inactive'"> 

     <i class="fa fa-bars" [@mtRotate]="activeSlide == 1 ? 'active': 'inactive'" (click)="menuOpen()" [style.z-index]="activeSlide == 1 ? 1 : 0"></i> 
     <i class="fa fa-arrow-left" [@mtRotate]="activeSlide == 2 ? 'active': 'inactive'" (click)="activeSlide = 1" [style.z-index]="activeSlide == 2 ? 1 : 0"></i> 

     <i class="fa fa-search" [@mtScale]="activeSlide == 1 ? 'active': 'inactive'" style="right:10px; left: initial;" (click)="activeSlide = 2"></i> 
    </div> 
    `, 
    animations: [ 
    trigger('mtSlide', [ 
    state('inactive', style({ 
     'box-shadow': 'rgb(0, 102, 255) 0px 0px 0px 0px inset, rgb(0, 0, 0) 0px 2px 8px -3px' 
    })), 
    state('active', style({ 
     'box-shadow': 'rgb(0, 102, 255) 100vw 0px 0px 0px inset, rgb(0, 0, 0) 0px 2px 8px -3px' 
    })), 
    transition('inactive <=> active', animate('200ms ease-out')) 
    ]), 

    trigger('mtTranslate', [ 
    state('inactive', style({ 
     transform: 'translateX(100%)' 
    })), 
    state('active', style({ 
     transform: 'translateX(0)' 
    })), 
    transition('inactive <=> active', animate('200ms ease-out')) 
    ]), 

    trigger('mtRotate', [ 
    state('inactive', style({ 
     transform: 'rotateZ(-90deg)' 
     opacity: 0; 
    })), 
    state('active', style({ 
     transform: 'rotateZ(0)'; 
     opacity: 1; 
    })), 
    transition('inactive <=> active', animate('300ms ease-out')) 
    ]), 

    trigger('mtScale', [ 
    state('inactive', style({ 
     transform: 'scale(0)' 
    })), 
    state('active', style({ 
     transform: 'scale(1)'; 
    })), 
    transition('inactive <=> active', animate('400ms ease-out')) 
    ])], 

    styles: [` 
    * { 
     box-sizing: border-box; 
    } 

    .head { 
     position: relative; 
     font-size: 18px; 
    } 

    .head, .color-bar, .head > input { 
     width: 100%; 
     height: 50px; 
    } 

    .head i, .head > input{ 
     position: absolute; 
    } 

    .head i { 
     line-height: 50px; 
     cursor: pointer; 
     color: white; 
     padding: 0 10px; 
     width: 50px; 
     text-align: center; 
     left: 10px; 
    } 

    .head i.fa-arrow-left { 
     color: #111; 
    } 

    .head > input { 
     border: 0; 
     outline: 0; 
     padding-left: 50px; 
    } 
    `] 
}) 
export class App { 
    activeSlide = 1; 

    menuOpen() { 
    alert('Menu Clicked'); 
    } 
} 
+0

çok güzel işi, ama aslında sadece 1 div tutmak ve sadece css geçişlerini kullanarak o bile mümkündür .. Başka div ile bunu değiştirmek yerine onun rengini değiştirmek isterdiniz? –

+0

evet, '.head div' öğesine doğrudan uygulayacağınız 'box-shadow: inset' ile görünür ve daha sonra –

+0

'un bu etkiyi oluşturabilmesi için 'gölge alanını ayarlamanız yeterlidir, ya da daha iyisi, cevabınızı tamamlayın. Onu deneyebilir ve kabul edebilir miyim? –

3

kullanarak Sen CSS kullanarak bu tasarım taklit edebilmek ve özellikle de, bir sözde elemanı olabilir. Herhangi bir JS kullanmaz, ancak birden fazla renk/etc eklemeniz gerekiyor olabilir.

.menu { 
 
    height: 50px; 
 
    width: 100%; 
 
    background: lightgray; 
 
    position: fixed; 
 
    top: 0; 
 
    left: 0; 
 
    overflow: hidden; 
 
} 
 
.menu .button1 { 
 
    position: absolute; 
 
    top: 20%; 
 
    left: 10px; 
 
    height: 30px; 
 
    width: 30px; 
 
    background: tomato; 
 
    cursor: pointer; 
 
} 
 
.menu .button1:before { 
 
    content: ""; 
 
    position: absolute; 
 
    top: 50%; 
 
    left: 50%; 
 
    transform: translate(-50%, -50%); 
 
    border-radius: 50%; 
 
    background: tomato; 
 
    transition: all 1s; 
 
    height: 0; 
 
    width: 0; 
 
    cursor: initial; 
 
} 
 
.menu .button1:hover:before { 
 
    height: 300vw; 
 
    width: 300vw; 
 
}
<div class="menu"> 
 
    <div class="button1"></div> 
 
</div>

İlgili konular