Skip to content
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

perf(image): disable transition for safari + unwatch observer after it triggers #573

Merged
merged 3 commits into from
Dec 11, 2023
Merged
Changes from 2 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
24 changes: 20 additions & 4 deletions src/components/Image/src/Image.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
$s[`shape_${resolvedShape}`],
]"
/>
<m-transition-fade-in @after-enter="afterEnter">
<component
:is="transitionComponent"
@after-enter="afterEnter"
>
<img
v-show="loaded"
:class="{
Expand All @@ -26,7 +29,7 @@
@load="onLoaded"
v-on="$listeners"
>
</m-transition-fade-in>
</component>
<pseudo-window
@resize="throttledResizeHandler"
/>
Expand Down Expand Up @@ -129,6 +132,10 @@ export default {
validator: cssValidator('object-position'),
default: 'center',
},
disableTransition: {
kevinlee11 marked this conversation as resolved.
Show resolved Hide resolved
type: Boolean,
default: false,
},
},

data() {
Expand Down Expand Up @@ -179,7 +186,14 @@ export default {
},

shouldGetImageDimensions() {
return this.shape !== 'square';
return this.shape !== 'square' || this.shape !== 'original';
},

transitionComponent() {
if (!this.disableTransition) {
return 'm-transition-fade-in';
}
return 'span';
kevinlee11 marked this conversation as resolved.
Show resolved Hide resolved
},
},

Expand All @@ -199,7 +213,8 @@ export default {
mounted() {
// Emit image:visible right away if Image is cached,
// since it will just render instead of transitioning in
if (this.loaded) {
// If it doesn't have a transition, so we'll just trigger it here
if (this.loaded || this.disableTransition) {
this.$emit('image:visible');
}

Expand Down Expand Up @@ -244,6 +259,7 @@ export default {
methods: {
load() {
this.shouldLoad = true;
observer?.unwatch(this.$el);
},

getImageDimensions() {
Expand Down
Loading