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
| <script> const imgUrl = "https://xxxxxxxxxxxx/"; export default { name: "Banner", data() { return { p0Src: imgUrl + 'banner/ppp0.png', p1Src: imgUrl + 'banner/pp1.png', p2Src: imgUrl + 'banner/pp2.png', p3Src: imgUrl + 'banner/pp3.png', p4Src: imgUrl + 'banner/pp4.png', p6Src: imgUrl + 'banner/pp6.png', p0Top: 0, p1Top: 0, p2Top: 0, p3Top: 0, p4Top: 0, p6Top: 0, bannerTitleMarginTop: -100, requestId: undefined, }; }, props:{ blogTitle:{ type: String, require: true }, blogDescription:{ type: String, require: true }, }, mounted() { this.addScrollListener(); }, beforeDestroy() { this.removeScrollListener(); }, methods: { addScrollListener() { window.addEventListener('scroll', this.handleScroll, {passive: true}); }, removeScrollListener() { window.removeEventListener('scroll', this.handleScroll); }, handleScroll() { const value = window.scrollY; this.p0Top = value * 0.6; this.p1Top = value * 0.36; this.p2Top = value * 0.24; this.p3Top = value * 0.16; this.p4Top = value * 0.12; this.p6Top = 0; this.bannerTitleMarginTop = value * 1.1 - 100; if (this.requestId === undefined) { this.requestId = requestAnimationFrame(this.updateStyles); } }, updateStyles() { this.requestId = undefined; } } } </script>
|