Skip to content

fix: initial animation/transition on Safari #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
<input type="checkbox" v-model="circles[3].loading" />
</div>-->
<div style="border: 1px solid red; display: inline-block">
<ve-progress :progress="progress" animation="rs 2000 2000" :legend-formatter="customFormatter" >
<ve-progress :progress="progress" animation="bounce 3000 300" :legend-formatter="customFormatter" :loading="loading" half >
<template #legend>
<span id="my-slot">Hello Circle</span>
</template>
</ve-progress>
<ve-progress
<!-- <ve-progress
:progress="progress"
:determinate="determinate"
:size="size"
Expand All @@ -67,7 +67,7 @@
<template #legend-caption>
<p>hello</p>
</template>
</ve-progress>
</ve-progress>-->
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/components/Circle/Circle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
</g>
</fade-in-transition>
<circle
ref="circleProgress"
class="ep-circle--progress"
:class="animationClass"
:r="radius"
Expand Down
4 changes: 4 additions & 0 deletions src/components/Circle/CircleContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ g.ep-circle--container {

.ep-circle--progress {
animation-timing-function: ease-in-out;
&.ep-animation-playing {
// Workaround only required for older Apple systems and Safari browser
transition: none !important;
}
&.animation__default {
animation-name: ep-progress--init__default;
}
Expand Down
1 change: 1 addition & 0 deletions src/components/Circle/HalfCircle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
</g>
</fade-in-transition>
<path
ref="circleProgress"
:stroke-width="options.thickness"
class="ep-half-circle--progress ep-circle--progress"
:class="animationClass"
Expand Down
22 changes: 22 additions & 0 deletions src/components/Circle/circleMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default {
},
data: () => ({
isInitialized: false,
isAnimationPlaying: false,
}),
computed: {
progress() {
Expand Down Expand Up @@ -44,6 +45,7 @@ export default {

animationClass() {
return [
this.isAnimationPlaying && "ep-animation-playing",
`animation__${
!this.options.loading && this.dataIsAvailable && this.isInitialized ? this.options.animation.type : "none"
}`,
Expand Down Expand Up @@ -146,12 +148,32 @@ export default {
getBounceInOffset() {
return this.circumference - this.progressOffset < 100 ? this.progressOffset : this.progressOffset + 100;
},
toggleIsAnimationPlaying() {
this.$nextTick(() => {
this.isAnimationPlaying = !this.isAnimationPlaying;
});
},
},
async mounted() {
const circle = this.$refs.circleProgress;
if (circle) {
// this is only required for older MacOS/IOS versions and Safari. On Apple system the transition is triggered
// right after initial animation causing the progress line rendered twice. So we track animation state to
// add/remove CSS transition properties
circle.addEventListener("animationstart", this.toggleIsAnimationPlaying, false);
circle.addEventListener("animationend", this.toggleIsAnimationPlaying, false);
}
if (!this.options.loading) {
// await initial delay before applying animations
await wait(this.options.animation.delay);
}
this.isInitialized = true;
},
unmounted() {
const circle = this.$refs.circleProgress;
if (circle) {
circle.removeEventListener("animationstart", this.toggleIsAnimationPlaying, false);
circle.removeEventListener("animationend", this.toggleIsAnimationPlaying, false);
}
},
};
92 changes: 0 additions & 92 deletions src/styles/animationsUsage.scss

This file was deleted.