| Server IP : 185.208.173.17 / Your IP : 87.236.161.98 Web Server : Microsoft-IIS/10.0 System : Windows NT SRV8576125506 10.0 build 26100 (Windows Server 2016) AMD64 User : IUSR ( 0) PHP Version : 7.4.13 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/parsmega.nuxt/components/pages/home/ |
Upload File : |
<template>
<section
class="counter__section"
v-waypoint="{ active: true, callback: startCounting }"
>
<div class="counter__contents">
<div class="counter__item">
<span class="counter__item__value">
+{{ productsCounter }}
</span>
{{ $t("products count") }}
</div>
<div class="counter__item">
<span class="counter__item__value">
+{{ customersCounter }}
</span>
{{ $t("customers count") }}
</div>
<div class="counter__item">
<span class="counter__item__value"> +{{ selledCounter }} </span>
{{ $t("products sold") }}
</div>
</div>
</section>
</template>
<script>
import LazyHydrate from "vue-lazy-hydration";
export default {
name: "HomeCountersSection",
components: {
LazyHydrate
},
data() {
return {
customersCounter: 0,
intervalRef: null,
isAnimStarted: false,
productsCounter: 0,
selledCounter: 0,
};
},
methods: {
startCounting() {
if (this.isAnimStarted) return;
this.isAnimStarted = true;
this.intervalRef = setInterval(() => {
const isAnimateProductCounter =
this.productsCounter < this.productsCount;
if (isAnimateProductCounter) this.productsCounter++;
const isAnimateSelled =
this.selledCounter < this.selledProductsCount;
if (isAnimateSelled) this.selledCounter += 20;
const isAnimateCustomer =
this.customersCounter < this.customersCount;
if (isAnimateCustomer) this.customersCounter += 4;
const isStopInterval =
!isAnimateProductCounter &&
!isAnimateSelled &&
!isAnimateCustomer;
if (isStopInterval) clearInterval(this.intervalRef);
}, 30);
},
},
props: {
customersCount: {
required: true,
type: String,
},
productsCount: {
required: true,
type: String,
},
selledProductsCount: {
required: true,
type: String,
},
},
};
</script>
<style lang="scss" scoped>
.counter {
&__section {
background: $color-accent;
color: $color-white;
content-visibility: auto;
font-size: 0;
line-height: 0;
padding: $home-sections-padding 0;
position: relative;
text-align: center;
}
&__contents {
margin: 0 auto;
max-width: $app-max-width;
padding: 0 $padding-default;
}
&__item {
display: block;
font-size: 18px;
line-height: 1.5;
margin: $padding-default * 4 0;
padding: 0 $padding-default;
text-align: center;
&__value {
display: block;
direction: ltr;
font-weight: bold;
font-size: 48px;
}
}
@media (min-width: $tablet) {
&__item {
display: inline-block;
vertical-align: top;
width: 33%;
}
}
}
</style>