|
| 1 | +<template> |
| 2 | + <ion-page> |
| 3 | + <ion-header> |
| 4 | + <ion-toolbar> |
| 5 | + <ion-title>Tab 3</ion-title> |
| 6 | + </ion-toolbar> |
| 7 | + </ion-header> |
| 8 | + <ion-content :fullscreen="true"> |
| 9 | + <ion-header collapse="condense"> |
| 10 | + <ion-toolbar> |
| 11 | + <ion-title size="large">Tab 3</ion-title> |
| 12 | + </ion-toolbar> |
| 13 | + </ion-header> |
| 14 | + |
| 15 | + <div class="animations-grid"> |
| 16 | + <section> |
| 17 | + <IonLabel color="primary"> |
| 18 | + <strong>Basic animation</strong> |
| 19 | + </IonLabel> |
| 20 | + <IonAnimation |
| 21 | + ref="animation1" |
| 22 | + v-slot="{ animation }" |
| 23 | + :duration="2000" |
| 24 | + :fromTo="[ |
| 25 | + { property: 'opacity', fromValue: '1', toValue: '0.2' }, |
| 26 | + { property: 'transform', fromValue: 'translateX(0px)', toValue: 'translateX(-50px)' }, |
| 27 | + ]" |
| 28 | + fill="forwards" |
| 29 | + > |
| 30 | + <div class="red-square"></div> |
| 31 | + |
| 32 | + <div class="buttons"> |
| 33 | + <IonButton @click="animation.play()">Play</IonButton> |
| 34 | + <IonButton @click="animation.pause()">Pause</IonButton> |
| 35 | + <IonButton @click="animation.stop()">Stop</IonButton> |
| 36 | + </div> |
| 37 | + </IonAnimation> |
| 38 | + </section> |
| 39 | + |
| 40 | + <section> |
| 41 | + <IonLabel color="primary"> |
| 42 | + <strong>Keyframes animation</strong> |
| 43 | + </IonLabel> |
| 44 | + <IonAnimation |
| 45 | + v-slot="{ animation }" |
| 46 | + :duration="3000" |
| 47 | + :keyframes="[ |
| 48 | + { offset: 0, transform: 'scale(1) translate(0, 0)' }, |
| 49 | + { offset: 0.4, transform: 'scale(1.05) translate(15px, 15px)' }, |
| 50 | + { offset: 0.6, transform: 'scale(1.05) translate(-30px, 15px)' }, |
| 51 | + { offset: 1, transform: 'scale(1) translate(0, 0)' }, |
| 52 | + ]" |
| 53 | + fill="none" |
| 54 | + > |
| 55 | + <div class="blue-square"></div> |
| 56 | + |
| 57 | + <div class="buttons"> |
| 58 | + <IonButton @click="animation.play()">Play</IonButton> |
| 59 | + <IonButton @click="animation.pause()">Pause</IonButton> |
| 60 | + <IonButton @click="animation.stop()">Stop</IonButton> |
| 61 | + </div> |
| 62 | + </IonAnimation> |
| 63 | + </section> |
| 64 | + |
| 65 | + <section> |
| 66 | + <IonLabel color="primary"> |
| 67 | + <strong>Animation that repeats forever</strong> |
| 68 | + </IonLabel> |
| 69 | + <IonAnimation |
| 70 | + v-slot="{ animation }" |
| 71 | + :duration="1000" |
| 72 | + :keyframes="[ |
| 73 | + { offset: 0, transform: 'scale(1)' }, |
| 74 | + { offset: 0.75, transform: 'scale(1.05)' }, |
| 75 | + { offset: 1, transform: 'scale(1)' }, |
| 76 | + ]" |
| 77 | + :iterations="Infinity" |
| 78 | + > |
| 79 | + <div class="green-square"></div> |
| 80 | + |
| 81 | + <div class="buttons"> |
| 82 | + <IonButton @click="animation.play()">Play</IonButton> |
| 83 | + <IonButton @click="animation.pause()">Pause</IonButton> |
| 84 | + <IonButton @click="animation.stop()">Stop</IonButton> |
| 85 | + </div> |
| 86 | + </IonAnimation> |
| 87 | + </section> |
| 88 | + |
| 89 | + <section> |
| 90 | + <IonLabel color="primary"> |
| 91 | + <strong>Animation with style hooks</strong> |
| 92 | + </IonLabel> |
| 93 | + <IonAnimation |
| 94 | + v-slot="{ animation }" |
| 95 | + :duration="2000" |
| 96 | + :keyframes="[ |
| 97 | + { offset: 0, transform: 'scale(1)' }, |
| 98 | + { offset: 0.75, transform: 'scale(1.1)' }, |
| 99 | + { offset: 1, transform: 'scale(1)' }, |
| 100 | + ]" |
| 101 | + :beforeStyles="{ |
| 102 | + opacity: 0.5, |
| 103 | + }" |
| 104 | + :afterClearStyles="['opacity']" |
| 105 | + :afterStyles="{ |
| 106 | + transform: 'scale(0.9)', |
| 107 | + }" |
| 108 | + :beforeClearStyles="['transform']" |
| 109 | + fill="none" |
| 110 | + > |
| 111 | + <div class="red-square"></div> |
| 112 | + |
| 113 | + <div class="buttons"> |
| 114 | + <IonButton @click="animation.play()">Play</IonButton> |
| 115 | + <IonButton @click="animation.pause()">Pause</IonButton> |
| 116 | + <IonButton @click="animation.stop()">Stop</IonButton> |
| 117 | + </div> |
| 118 | + </IonAnimation> |
| 119 | + </section> |
| 120 | + |
| 121 | + <section> |
| 122 | + <IonLabel color="primary"> |
| 123 | + <strong>Animation with specific easing</strong> |
| 124 | + </IonLabel> |
| 125 | + <IonAnimation |
| 126 | + v-slot="{ animation }" |
| 127 | + :duration="2000" |
| 128 | + :keyframes="[ |
| 129 | + { |
| 130 | + offset: 0, |
| 131 | + transform: 'rotate(0)', |
| 132 | + }, |
| 133 | + { |
| 134 | + offset: 0.5, |
| 135 | + transform: 'rotate(60deg)', |
| 136 | + }, |
| 137 | + { |
| 138 | + offset: 1, |
| 139 | + transform: 'rotate(0)', |
| 140 | + }, |
| 141 | + ]" |
| 142 | + easing="cubic-bezier(.7,.55,0,1.15)" |
| 143 | + > |
| 144 | + <div class="blue-square"></div> |
| 145 | + |
| 146 | + <div class="buttons"> |
| 147 | + <IonButton @click="animation.play()">Play</IonButton> |
| 148 | + <IonButton @click="animation.pause()">Pause</IonButton> |
| 149 | + <IonButton @click="animation.stop()">Stop</IonButton> |
| 150 | + </div> |
| 151 | + </IonAnimation> |
| 152 | + </section> |
| 153 | + |
| 154 | + <section> |
| 155 | + <IonLabel color="primary"> |
| 156 | + <strong>Reversed animation direction</strong> |
| 157 | + </IonLabel> |
| 158 | + <IonAnimation |
| 159 | + v-slot="{ animation }" |
| 160 | + :duration="3000" |
| 161 | + :keyframes="[ |
| 162 | + { offset: 0, transform: 'scale(1)' }, |
| 163 | + { offset: 0.3, transform: 'scale(1.2)' }, |
| 164 | + { offset: 0.6, transform: 'scale(1.05)' }, |
| 165 | + { offset: 0.9, transform: 'scale(0.8)' }, |
| 166 | + { offset: 1, transform: 'scale(1)' }, |
| 167 | + ]" |
| 168 | + direction="reverse" |
| 169 | + easing="ease-in" |
| 170 | + > |
| 171 | + <div class="green-square"></div> |
| 172 | + |
| 173 | + <div class="buttons"> |
| 174 | + <IonButton @click="animation.play()">Play</IonButton> |
| 175 | + <IonButton @click="animation.pause()">Pause</IonButton> |
| 176 | + <IonButton @click="animation.stop()">Stop</IonButton> |
| 177 | + </div> |
| 178 | + </IonAnimation> |
| 179 | + </section> |
| 180 | + </div> |
| 181 | + </ion-content> |
| 182 | + </ion-page> |
| 183 | +</template> |
| 184 | + |
| 185 | +<style scoped> |
| 186 | +:root { |
| 187 | + --animation-color: purple; |
| 188 | +} |
| 189 | +
|
| 190 | +.animations-grid { |
| 191 | + padding: 3em; |
| 192 | + display: grid; |
| 193 | + grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); |
| 194 | + grid-auto-flow: row; |
| 195 | + row-gap: 4em; |
| 196 | + align-items: center; |
| 197 | + justify-items: center; |
| 198 | + text-align: center; |
| 199 | +} |
| 200 | +
|
| 201 | +.animations-grid > *:nth-child(2) { |
| 202 | + margin-left: auto; |
| 203 | + margin-right: auto; |
| 204 | +} |
| 205 | +
|
| 206 | +.buttons { |
| 207 | + width: 100%; |
| 208 | + display: flex; |
| 209 | + justify-content: space-around; |
| 210 | + align-items: center; |
| 211 | +} |
| 212 | +
|
| 213 | +.red-square { |
| 214 | + width: 250px; |
| 215 | + height: 250px; |
| 216 | + background-color: red; |
| 217 | + border-radius: 1em; |
| 218 | +} |
| 219 | +
|
| 220 | +.blue-square { |
| 221 | + width: 250px; |
| 222 | + height: 250px; |
| 223 | + background-color: blue; |
| 224 | + border-radius: 1em; |
| 225 | +} |
| 226 | +
|
| 227 | +.green-square { |
| 228 | + width: 250px; |
| 229 | + height: 250px; |
| 230 | + background-color: green; |
| 231 | + border-radius: 1em; |
| 232 | +} |
| 233 | +</style> |
0 commit comments