-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.vue
147 lines (142 loc) · 3.9 KB
/
index.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<template>
<div>
<resize-observer @notify="handleResize" />
<section class="w-full min-h-screen flex items-center relative">
<div class="container">
<h1
v-scroll="scrollHandler"
class="main-title relative xl:w-3/4 lg:w-11/12 z-10 mx-auto start-animate-position"
>
{{ page.title }}
</h1>
<img
loading="lazy"
src="~assets/img/homepage-bg.jpg"
class="absolute top-0 bottom-0 left-0 right-0 h-full w-full object-cover z-0"
alt=""
/>
</div>
</section>
<section class="xl:mt-32 lg:mt-24 sm:mt-20 mt-12 section-padding">
<div class="container">
<h2 v-scroll="scrollHandler" class="title start-animate-position">
Our Works
</h2>
<ProjectSlider />
</div>
</section>
<section class="section-padding">
<div class="container">
<h2 v-scroll="scrollHandler" class="title start-animate-position">
{{ about.title }}
</h2>
<TextImg
:img="about.image.sourceUrl"
:text="about.text"
link-name="learn more about the company"
:link="about.link.uri"
:reverse="true"
:img-full="true"
/>
</div>
</section>
<section class="section-padding">
<div
ref="scrollBlock"
class="container xl:grid xl:grid-cols-2 xl:gap-x-10 mx-auto"
>
<div>
<div ref="dynamicTitle" v-scroll="fixTitle" class="top-32">
<h2 v-scroll="scrollHandler" class="title start-animate-position">
{{ services.title }}
</h2>
</div>
</div>
<div>
<Service
v-for="(service, index) in services.list"
:key="index"
:ref="`slide${index}`"
:class="{
'mb-0': index === services.list.length - 1,
'mb-20': index !== services.list.length - 1,
}"
:icon="service.icon"
:title="service.title"
:text="service.text"
:link="service.link"
/>
</div>
</div>
</section>
<section class="xl:mb-32 lg:mb-24 sm:mb-20 mb-12 section-padding">
<div class="container">
<Feedback class="mx-auto" />
</div>
</section>
</div>
</template>
<script>
import ProjectSlider from '@/components/sliders/ProjectSlider'
import TextImg from '@/components/TextImg'
import Service from '@/components/Service'
import Feedback from '@/components/Feedback'
import mainPageGQL from '~/apollo/queries/mainPage.gql'
import scroll from '~/mixins/scroll'
export default {
components: { ProjectSlider, TextImg, Service, Feedback },
mixins: [scroll],
async asyncData({ app }) {
const { data } = await app.apolloProvider.defaultClient.query({
query: mainPageGQL,
})
return {
page: data.page,
about: data.page.aboutBlock.about,
services: {
title: data.page.services.serviceTitle,
list: data.page.services.serviceList,
},
}
},
data: () => ({
isFixTitle: false,
titlePosition: '',
scrollBlockHeight: '',
scrollBlockPosition: '',
resizeVar: null,
}),
mounted() {
this.isFixTitle = window.innerWidth >= 1536
},
methods: {
fixTitle(evt, el) {
if (
this.$refs.scrollBlock &&
this.$refs.scrollBlock.getBoundingClientRect().top < 100 &&
this.$refs.scrollBlock.getBoundingClientRect().bottom > 200 &&
this.isFixTitle
) {
el.style.position = 'fixed'
} else {
el.style.position = 'static'
}
},
handleResize({ width }) {
this.isFixTitle = width >= 1536
},
},
head() {
return {
title: this.page.seo.title,
meta: [
{
hid: 'description',
name: 'description',
content: this.page.seo.metaDesc,
},
],
}
},
}
</script>