javascript - Sliding the images in ionic 2 -
i have set of images added ion-slides, however, when drag slide next slide, want current slide zoom out , next slide zoom in.
html code
:
<ion-content> <ion-slides class="image-slider" loop="true" slidesperview="2" direction="horizontal" zoom="true" (ionslidedrag)="slidemoved()" (ionslidedidchange)="slidedidchange()"> <ion-slide *ngfor="let img of images" > <img src="http://lorempixel.com/200/200/cats/{{img}}" class="thumb-img" /> </ion-slide> </ion-slides> </ion-content>
on dragging, slidemoved()
function called
.ts
file :
slidemoved() { this.scalecurrentval = 1; this.scalepreviousval = 0.5; let curr = this.slides.getactiveindex(); let htmlidactive = this.slides._slides[curr]; htmlidactive.style.webkitanimation = "animzoomout"; htmlidactive.style.webkitanimationduration = "500ms" htmlidactive.style.animation = "animzoomout"; htmlidactive.style.animationduration = "2s" }
after change of slides, slidedidchange()
called in same .ts
file:
slidedidchange() { this.scalecurrentval = 1; this.scalepreviousval = 0.5; let numslides = this.slides.length(); for( let = 0; < numslides; i++) { let htmlid = this.slides._slides[i]; if( === this.slides.getactiveindex()) { htmlid.style.transition = "transform 500ms"; htmlid.style.transform = "scale("+ this.scalecurrentval +")"; } else { htmlid.style.transition = "transform 500ms"; htmlid.style.transform = "scale("+ this.scalepreviousval +")"; } }
the animation goes :
@-webkit-keyframes animzoomin { {transform:scale(0.5);} {transform:scale(1);} } @keyframes animzoomin { {transform:scale(0.5);} {transform:scale(1);} } @-webkit-keyframes animzoomout { {transform:scale(1);} {transform:scale(0.1);} } @keyframes animzoomout { {transform:scale(1);} {transform:scale(0.1);} }
however above code doesn't work.
over all, want following result:
when start dragging (slowly) , slide going current slide should scale 1 .
and current slide going left or right should scaled 0.5.
scaling should smooth transition.
if 1 solve problem, great help. thank you
Comments
Post a Comment