Adding the Finishing Flourishes to a Gesture-Controlled VueJs Slide Transition

I'm currently working on a VueJS slideshow that can toggle between different slides based on button input. The main functionality of the slideshow is solid, but I'm facing a small challenge when it comes to applying transitions to the slide components.

Here's how the transition group and its child components are set up:

<transition-group :name="topicDirection ? 'topic-left' : 'topic-right'">
  <component v-for="(topic, index) in topics" :is="topic.component" :key="topic.title" 
    v-show="activeTopic === index"/>
</transition-group>

Below are the corresponding topic-left and topic-right classes in the CSS:

.topic-left-enter-active,
.topic-left-leave-active,
.topic-right-enter-active,
.topic-right-leave-active {
    transition: all 3s cubic-bezier(0.19, 1, 0.22, 1);
}

.topic-left-enter,
.topic-right-leave-to {
    transform: translateX(100%);
}

.topic-right-enter,
.topic-left-leave-to {
    transform: translateX(-100%);
}

.topic-left-enter,
.topic-left-leave-to,
.topic-right-enter,
.topic-right-leave-to {
    opacity: 0;
 }

Currently, I have achieved the desired animation for slide-right, but slide-left is displaying an unexpected animation behavior. Here's how they look:

https://i.stack.imgur.com/dg8g0.jpg

While slide-right hides the previous topic and transitions the new topic smoothly to the right with increasing opacity over three seconds, slide-left moves the previous topic to the left with decreasing opacity in three seconds, followed by a delay before showing the new topic in place.

The intention for the slide-left animation is to mirror the slide-right effect - the previous topic should fade out as the new topic slides in from the left with increasing opacity, like this:

https://i.stack.imgur.com/mpbNm.jpg

I believe this issue has a simple solution, but as I am still relatively new to VueJS, I find myself struggling with the logic behind it. Any assistance or clarification would be greatly appreciated. Thank you!

Answer №1

After experimenting, I achieved the desired effect for both left and right sides by implementing the following:

    .topic-left-enter {
    opacity: 0;
    transform: translateX(100%);
    }

.topic-right-enter {
    opacity: 0;
    transform: translateX(-100%);
    }

.topic-left-enter-active,
.topic-right-enter-active {
    transition: all 0.75s cubic-bezier(0.19, 1, 0.22, 1);
    }

Interestingly, the leave transition classes were causing interference with both the right and left transitions. This issue may require further investigation in the future, but for now, I am satisfied with this solution.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exploring the Power of Ajax Interceptor in Framework7-vue-cli

I have a challenge where I need to redirect all ajax requests with a status code of -1 in the response to the login screen. Despite my efforts, I am unable to monitor it. What steps should I take next? Appreciate your help. My approach: app.js Framework7. ...

Error in Vue: Expected object but received a function instead of a valid value

I am attempting to apply a computed function to my style. However, the computed function uses a property within it and Vue is throwing an error stating that it expects an object but is receiving a function. Below is the code in question. <template> ...

Futuristic routing in VueJS

I've been attempting to dynamically generate routes, but unfortunately I'm facing difficulties as it seems not feasible with Vuejs 3 import { createRouter, createWebHistory } from "vue-router"; import TopMenu from "../layouts/top-m ...

Steps for launching a hyperlink in a browser on Vue Native

I'm having trouble finding information on how to properly use the Linking component in react-native. The resources available are limited, and I'm not sure if I am implementing it correctly... Below is what I have in my template: <nb-button :o ...

Exploring Vue.js: The Power of Components and Cache

After researching ways to 'cache' API fetched data in my application, I discovered that it can be easily achieved using localStorage or sessionStorage. Although it functions well, I am interested in consolidating all cached data into a single JS ...

Brand new Laravel 9 setup featuring a vue 3 scaffold, but encountering issues with vite not displaying components

After setting up a fresh Laravel 9.19 installation with Vue scaffolding and vite.js, everything seemed to be working well, except for one issue - the Vue example component that comes with the default Laravel install wasn't rendering in the browser. M ...

What is the proper way to deploy a Vue App after it has been built?

After deploying my Vue App on a hosting platform, I noticed an issue. When I try to access "www.mydomain.com/about" directly in the browser, I receive a 404 Error Page. This made me wonder if I deployed the wrong thing. I ran npm run build before deployin ...

Exploring the possibilities of updating the version dynamically in package.json file

Upon receiving version 1.0.1 (server_version) from the server I make sure process.env.version matches server_version If they are the same, I update process.env.version to server_version. But unfortunately, this process cannot be done from the client side. ...

Display images in a list with a gradual fade effect as they load in Vue.js

In my Vue project, I am looking to display images one at a time with a fading effect. I have added a transition group with a fade in effect and a function that adds each image with a small delay. However, I am facing an issue where all the images show up ...

Vue draggable component

I'm currently facing an issue while trying to integrate the Vue Draggable Component into my existing component. Everything works perfectly fine in my component without the draggable feature, but as soon as I add it, the entire content becomes blank. I ...

The Vue route parameters are not recognized within the function type

Seeking assistance on extracting parameters from my route in a vue page, I have the following implementation: <script lang="ts"> import { defineComponent } from 'vue'; import { useRoute } from 'vue-router'; export ...

Unexpected behavior occurs in Django routing with a VueJS single page application when the URL is missing a trailing slash

In my development setup, I am utilizing a Django backend with a VueJS frontend, serving a REST API through Django and using VueJS along with vue-router for the single page application. After reading up on this on Stack Overflow, I found a helpful suggesti ...

Received a 'Vue error: Redundant navigation to current location prevented' when attempting to refresh the page with updated parameters

I'm attempting to refresh the page with new parameters when the state changes: @Watch('workspace') onWorkspaceChanged(o: Workspace, n: Workspace){ if(o.type === n.type && o.id === n.id) return; this.$router.push({name: this.$rout ...

VueJS offers a mixin that is accessible worldwide

I'm looking to create a global mixin that is accessible everywhere, but not automatically inserted into every component. I don't want to use Vue.mixin({...}); Following the guidelines from this source, I have structured my project accordingly. Y ...

How can I retrieve the index of a v-for loop within a function in Vue.js HTML?

How can I splice the array from the fields in HTML Vue JS if the status is true? I also need to pass the index value to a function. Is this possible? The error I am encountering is: Uncaught ReferenceError: index is not defined at Object.success (80 ...

how to toggle a pre-selected checkbox in a Vue component

https://i.stack.imgur.com/6GQl7.png When dealing with a tree view checkbox in Vue, I encountered an issue where editing data within a selected zone should automatically check the corresponding countries based on previous selections. The ID of the selected ...

What is the best way to access original copies of code-split .js files in Vue.js and webpack without caching?

I have successfully installed Vue.js in my app, utilizing vue-cli and webpack. All is functioning well, including implementing code splitting to optimize component loading. However, I am facing an issue when releasing updates as the code-split .js files ge ...

Steps for creating a personalized @click function for a <router-link> element

I am currently working on a VueJS 3 application that includes a router-link element. I am trying to implement a custom click-handler where instead of redirecting to the href URL, it will trigger a function in my pinia-store. <router-link ...

Pre-rendering Vue.js components with dynamically generated PHP content

Seeking guidance on prerendering a Vue app constructed with PHP (either Laravel or pure PHP). My inquiry pertains to understanding how prerendering functions with dynamic content. For instance, when creating a blog using Vue and PHP to display posts, I uti ...

Troubleshoot: Unable to utilize mapActions with Vuex modules

Having trouble using mapActions to reference actions in my modules. The Vuex docs say that module actions are not namespaced by default, so they should be accessible like main store actions. Here's how I have things set up: Store import * as ModuleA ...