Skip to content
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
2 changes: 2 additions & 0 deletions packages/theme/components/AppFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ export default {
}
&__social-image {
margin: 0 var(--spacer-2xs) 0 0;
background-color: #fff;
border-radius: 100%;
}
}
.sf-footer {
Expand Down
53 changes: 53 additions & 0 deletions packages/theme/components/utils/LoadWhenVisible.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<template>
<div ref="root">
<slot v-if="isVisible" />
</div>
</template>
<script>
import {
defineComponent, onMounted, onUnmounted, ref,
} from '@nuxtjs/composition-api';

export default defineComponent({
name: 'LoadWhenVisible',
props: {
options: {
type: Object,
default: () => ({
rootMargin: '0px 0px 200px 0px',
}),
},

},
setup({ options }) {
const isVisible = ref(false);
const root = ref(null);

let observer = null;
if (process.browser && ('IntersectionObserver' in window)) {
observer = new IntersectionObserver((entries) => {
if (entries[0].intersectionRatio <= 0) return;
observer.unobserve(root.value);
isVisible.value = true;
}, options);
}

onMounted(() => {
if (observer) {
observer.observe(root.value);
}
});

onUnmounted(() => {
if (observer) {
observer.unobserve(root.value);
}
});

return {
root,
isVisible,
};
},
});
</script>
6 changes: 5 additions & 1 deletion packages/theme/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
<nuxt :key="route.fullPath" />
</div>
<BottomNavigation />
<AppFooter />
<LoadWhenVisible>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you add rootMargin option, please set up it here. Please try 100px 0 0 0.

Thanks to that footer should be shown a little bit earlier, and UX will be better.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oki

<AppFooter />
</LoadWhenVisible>
</div>
</template>

Expand All @@ -27,6 +29,7 @@ import {
useUser,
} from '@vue-storefront/magento';
import useUiState from '~/composables/useUiState.ts';
import LoadWhenVisible from '~/components/utils/LoadWhenVisible';

import { useMagentoConfiguration } from '~/composables/useMagentoConfiguration';
import AppHeader from '~/components/AppHeader.vue';
Expand All @@ -37,6 +40,7 @@ export default defineComponent({
name: 'DefaultLayout',

components: {
LoadWhenVisible,
LazyHydrate,
AppHeader,
TopBar,
Expand Down
5 changes: 1 addition & 4 deletions packages/theme/static/icons/facebook.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 1 addition & 10 deletions packages/theme/static/icons/google.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 5 additions & 9 deletions packages/theme/static/icons/pinterest.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 1 addition & 10 deletions packages/theme/static/icons/twitter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 8 additions & 9 deletions packages/theme/static/icons/youtube.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.