[英]GSAP 3+ animation not working in VueJS project
In my local server (http://localhost:8080/)
GSAP animation working properly.在我的本地服务器
(http://localhost:8080/)
GSAP 动画正常工作。 Whenever I push the master branch and its build on netlify.com, but the animation not working.每当我在 netlify.com 上推送 master 分支及其构建时,但动画不起作用。
I add the code on my component and mounted properly, but I could not understand why it's not working in production!我在我的组件上添加了代码并正确安装,但我不明白为什么它在生产中不起作用!
CommonBanner.vue CommonBanner.vue
<template>
<div class="common-banner-area">
<div class="container-fluid px-5-percent">
<div ref="jsbannerimage" class="common-banner">
<img class="img-fluid" :src="ImageUrl" alt="square">
<div class="banner-content">
<h1 ref="jstitle">{{BannerTitle}}</h1>
<p ref="jssubtitle">{{BannerSubtitle}}</p>
</div>
</div>
</div>
</div>
</template>
<script lang="ts">
import {Component, Vue, Prop} from 'vue-property-decorator';
import {TimelineLite, Back} from 'gsap/all';
@Component({
name: 'CommonBanner',
components: {},
})
export default class CommonBanner extends Vue {
@Prop() public BannerTitle!: string;
@Prop() public BannerSubtitle!: string;
@Prop() public ImageUrl!: string;
public mounted() {
const {jstitle} = this.$refs;
const {jssubtitle} = this.$refs;
const {jsbannerimage} = this.$refs;
const imagetimeline = new TimelineLite();
imagetimeline.to(jsbannerimage, 0, {
opacity: 0,
ease: Back.easeInOut, // Specify an ease
});
imagetimeline.to(jsbannerimage, 2, {
opacity: 1
},
'+=0.5' // Run the animation 0.5s early
);
const timeline = new TimelineLite();
timeline.to(jstitle, 0, {
opacity: 0,
ease: Back.easeInOut, // Specify an ease
});
timeline.to(jstitle, 2, {
opacity: 1
},
'+=1' // Run the animation 0.5s early
);
const subtimeline = new TimelineLite();
subtimeline.to(jssubtitle, 0, {
opacity: 0,
ease: Back.easeInOut,
});
subtimeline.to(jssubtitle, 2, {
opacity: 1
},
'+=1.5' // Run the animation 0.5s early
);
}
}
</script>
Try loading the UMD version of GSAP.尝试加载 GSAP 的 UMD 版本。 You can do so by saying:
你可以这样说:
import { TimelineLite, Back } from "gsap/dist/gsap";
See the GSAP's installation page for more info.有关更多信息,请参阅GSAP 的安装页面。
With that being said, we recommend using the GSAP 3 formatting in which case you only need to import gsap
for the code provided.话虽如此,我们建议使用 GSAP 3 格式,在这种情况下,您只需为提供的代码导入
gsap
。 See the GSAP 3 migration guide for more info.有关详细信息,请参阅GSAP 3 迁移指南。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.