JS Animations
You can create animations through Javascript (using RAF - requestAnimationFrame()
) with Quasar.
import { animate } from 'quasar' |
Example:import { animate } from 'quasar'
animate.start({
from: 6,
to: 158,
apply (pos) {
el.style.maxHeight = `${pos}px`
},
done () {
console.log(`we're done!`)
}
})
Easing Functions
Easing functions take the current percent progress of the animation (a float between 0 and 1) and return a position multiplier (0 being initial position and 1 being final position).
The following easing functions are included:
ease[In|Out|InOut][Quad|Cubic|Quart|Quint|Circ]
- For example,
easeInCubic
.Quad
throughQuint
get progressively more exaggerated.Circ
is slightly different (the graph is a quarter circle), it accelerates much faster at the end.
- For example,
overshoot
- Shoots past the end position and returns slowly
standard
- Use for on-screen movement. Accelerates quickly, decelerates slowly
decelerate
- Use for elements entering the screen. Flies in and slowly decelerates (
easeOutCubic
).
- Use for elements entering the screen. Flies in and slowly decelerates (
accelerate
- Use for elements leaving the screen. Accelerates and then leaves at full velocity (
easeInCubic
).
- Use for elements leaving the screen. Accelerates and then leaves at full velocity (
sharp
- Use for elements leaving the screen that may return (e.g. navigation bar). Accelerates and decelerates (
easeInOutQuad
)
- Use for elements leaving the screen that may return (e.g. navigation bar). Accelerates and decelerates (
Example:import { animate, easing } from 'quasar'
animate.start({
from: 0,
to: 100,
easing: easing.standard
...
})
Or with the carousel:<template>
<q-carousel :swipe-easing="overshoot">
Slides...
</q-carousel>
</template>
<script>
import { easing, QCarousel } from 'quasar'
export default {
components: {
QCarousel
},
data: () => ({
overshoot: easing.overshoot
})
}
</script>