javascript - Sliding the images in ionic 2 -


enter image description here

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:

  1. when start dragging (slowly) , slide going current slide should scale 1 .

  2. and current slide going left or right should scaled 0.5.

  3. scaling should smooth transition.

if 1 solve problem, great help. thank you


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -