Use vue, vue-router, animejs to explain how to implement BubbleTransition of vue page switching effect. Friends who need it can refer to it
CodePen address
After using SPA on the front end, you can gain more control, such as page switching animations. Using the back-end page, we may not be able to achieve the above effects, or there will be an obvious splash screen. Because all resources need to be reloaded.
Today we use vue, vue-router, and animationjs to explain how to achieve the above effect.
Steps
Click on the menu to generate Bubble and start the entry animation
Page jump
Execute exit animation
Functional calling component
I hope that the effect is called through an object instead of instructions such as v-show, v-if, and to maintain uniformity, I still use Vue to write components. I usually implement this with a new Vue root node to keep the effect independent of the business components.
let instance = null function createServices (Comp) { // ... return new Vue({ // ... }).$children[0] } function getInstance () { instance = instance || createServices(BubbleTransitionComponent) return instance } const BubbleTransition = { scaleIn: () => { return getInstance().animate('scaleIn') }, fadeOut: () => { return getInstance().animate('fadeOut') } }
Then implement BubbleTransitionComponent, then BubbleTransition.scaleIn, BubbleTransition.scaleOut will work normally. Animation execution end events that animejs can listen to. anime().finished gets the Promise object.
<template> <p class="transition-bubble"> <span v-show="animating" class="bubble" id="bubble"> </span> </p> </template> <script> import anime from 'animejs' export default { name: 'transition-bubble', data () { return { animating: false, animeObjs: [] } }, methods: { scaleIn (selector = '#bubble', {duration = 800, easing = 'linear'} = {}) { // this.animeObjs.push(anime().finished) }, fadeOut (selector = '#bubble', {duration = 300, easing = 'linear'} = {}) { // ... }, resetAnimeObjs () { this.animeObjs.reset() this.animeObjs = [] }, animate (action, thenReset) { return this[action]().then(() => { this.resetAnimeObjs() }) } } }
The original idea is to add a tag to a specific route meta in the router config, and then judge the tag to perform animation during beforeEach. However, this method is not flexible enough. Instead, it is marked by Hash, combined with Vue-router, and the hash is reset when switching.
<router-link class="router-link" to="/#__bubble__transition__">Home</router-link> const BUBBLE_TRANSITION_IDENTIFIER = '__bubble__transition__' router.beforeEach((to, from, next) => { if (to.hash.indexOf(BUBBLE_TRANSITION_IDENTIFIER) > 0) { const redirectTo = Object.assign({}, to) redirectTo.hash = '' BubbleTransition.scaleIn() .then(() => next(redirectTo)) } else { next() } }) router.afterEach((to, from) => { BubbleTransition.fadeOut() })
Cool animations can catch the user’s attention in an instant. I myself often say when browsing some websites, wocao, so cool ! ! ! sigh. Maybe the final implementation won't require more than a few lines of code. I'll try to implement it myself. Next time the designer puts forward unreasonable animation requirements, I can show off. I can make this effect in minutes, but I don't think it should be used here** The animation does not meet the user’s psychological expectations.
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
Create ajax image upload by yourself
##Solution to automatically add pre tag to ajax return value
How to use ajax actions with different namespaces
##
The above is the detailed content of Vue page switching effect BubbleTransition. For more information, please follow other related articles on the PHP Chinese website!

你可能遇到过智能手机屏幕出现绿色线条的问题,即使没见过,也一定在网络上看到过相关图片。那么,智能手表屏幕变白的情况你遇见过吗?4月2日,CNMO从外媒了解到,一名Reddit用户在社交平台上分享了一张图片,展示了三星Watch系列智能手表屏幕变白的情况。该用户写道:"我离开时正在充电,回来时就这样了,我尝试重启,但重启过程中屏幕还是这样。"三星Watch智能手表屏幕变白这位Reddit用户并未指明这款智能手表的具体型号。不过,从图片上看,应该是三星Watch5。此前,另一位Reddit用户也报告

说起阿萨辛ASSASSIN,相信玩家们一定会想到《刺客信条》中的各位刺客大师,不仅身手了得,而且"躬身于黑暗、服务于光明"的信条,与国内知名机箱/电源/散热器品牌九州风神(DeepCool)旗下的阿萨辛ASSASSIN系列旗舰级风冷散热器不谋而合。最近,该系列的最新产品阿萨辛ASSASSIN4S重磅上线,"西装刺客,再进阶"为高级玩家带来全新的风冷散热体验。外观一览细节满满阿萨辛4S散热器采用双塔构造+单风扇内嵌设计,外面包覆立方体造型的整流罩,整体感极强,并提供白、黑两种配色可选,满足不同色系

随着春天的到来,万物复苏,一切都充满了生机与活力。在这个美好的季节里,如何为家居生活增添一抹别样的色彩?哈趣H2投影仪,以其精致的设计和超高的性价比,成为了这个春天里不可或缺的一道亮丽风景。这款H2投影仪小巧玲珑却不失时尚。无论是放在客厅的电视柜上,还是卧室的床头柜旁,都能成为一道亮丽的风景线。它的机身采用了奶白色的磨砂质地,这种设计不仅让投影仪的外观更显高级,同时也增加了触感的舒适度。米色仿皮纹材质,更是为整体外观增添了一抹温馨与雅致。这种色彩与材质的搭配,既符合现代家居的审美趋势,又能够融入

ITX平台以小巧的身形吸引了不少追求极致和独特美感的玩家,随着制程的提升和技术的进步,英特尔第14代酷睿和RTX40系显卡都可以在ITX平台中发挥实力,游戏玩家也对SFX电源有了更高的要求。游戏爱好者航嘉推出新的MX系列电源,在满足高性能需求的ITX平台中,MX750P全模组电源的定额功率高达750W,同时通过了80PLUS白金级认证。以下我们就带来这款电源的评测。航嘉MX750P全模组电源采用了简约时尚的设计理念,共有黑白两款供玩家选择,均采用磨砂表面处理,搭配银灰色和红色的字体有很好的质感,

在当下科技飞速发展的时代,笔记本电脑已经成为人们日常生活和工作中不可或缺的重要工具。对于那些对性能有高要求的玩家而言,拥有配置强大、性能出色的笔记本电脑才能满足其硬核需求。七彩虹隐星P15笔记本电脑凭借其卓越性能和令人惊艳的设计,成为了未来的引领者,堪称硬核笔记本的典范。七彩虹隐星P1524配备了13代英特尔酷睿i7处理器和RTX4060LaptopGPU,外观采用更时尚的宇宙飞船设计风格,同时在细节表现上也有出色表现。让我们先来了解一下这款笔记本的特点。至高搭载英特尔酷睿i7-13620H处理

一个可以自动分析PDF、网页、海报、Excel图表内容的大模型,对于打工人来说简直不要太方便。上海AILab,香港中文大学等研究机构提出的InternLM-XComposer2-4KHD(简写为IXC2-4KHD)模型让这成为了现实。相比于其他多模态大模型不超过1500x1500的分辨率限制,该工作将多模态大模型的最大输入图像提升到超过4K(3840x1600)分辨率,并支持任意长宽比和336像素~4K动态分辨率变化。发布三天,该模型就登顶HuggingFace视觉问答模型热度榜单第一。轻松拿捏

很多摄影爱好者喜欢使用镜头,他们的拍摄需求非常多变,因此在镜头的选择上更倾向于一支比较全能的产品,也就是我们俗称的"一镜走天下"镜头。刚好,现在尼康推出了一支新的产品,尼克尔Z28-400mmf/4-8VR镜头,一支真正的"一镜走天下"镜头。镜头从28mm广角端一直覆盖到400mm长焦端,配备其Z卡口相机,可以轻松拍摄十分丰富的摄影主题,并带来一场丰富的视角变化。今天,我们就通过近期的使用体验,跟大家一起聊聊这支尼克尔Z28-400mmf/4-8VR镜头。尼克尔Z28-400mmf/4-8VR是

在智能手机市场,三星的Galaxy系列一直以其卓越的性能和创新的设计备受瞩目。而GalaxyS23Ultra作为上代机皇,自发布以来便受到了广大消费者的喜爱。随着时间的推移,新机型层出不穷,那么,这款昔日的机皇如今还能否再战呢?接下来,我将分享自己在使用三星GalaxyS23Ultra过程中的实际体验,带大家一同探讨这个问题。首先,从外观设计上来看,GalaxyS23Ultra依然保持着三星一贯的精致与高端。其独特的微曲屏设计不仅提升了手机的整体美感,更为用户带来了更加沉浸的视觉体验。在日常使用


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Zend Studio 13.0.1
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 English version
Recommended: Win version, supports code prompts!
