The transition kicks in as soon as the page finishes loading

I am attempting to incorporate transitions on divs when the page loads, but I am encountering difficulties getting it to work.

template

<header>
    <transition name="slideLeft">
        <div v-show="loaded" class="contents content-left"></div>
    </transition>
    <transition name="slideRight">
        <div v-show="loaded" class="contents content-right"></div>
    </transition>
</header>

script

data(){
    return {
        loaded: false,
    };
},
created(){
    this.onLoaded();
},
methods: {
    onLoaded() {
      this.loaded = true;
    }
}

css

.slideLeft-enter-active{
    width: 400px;
}
.slideRight-enter-active{
    width: 400px;
}
header {
    background-color: #1b1d1f;
    height: 100vh;
    display: flex;
    justify-content: center;
}
header .contents {
    transition: 2s;
    width: 0;
    background-color: #151618;
}

Could someone please help me identify what might be causing the issue here?

Answer №1

Revamp your code styling

<style>
  .slide-left-enter,
  .slide-right-enter {
    width: 0 !important;
  }

  .slide-left-enter-to,
  .slide-right-enter-to {
    width: 400px !important;
  }

  header {
    background-color: #1b1d1f;
    height: 100vh;
    display: flex;
    justify-content: center;
  }

  header .contents {
    width: 400px;
    transition: all 2s;
    background-color: #151618;
    color: #fff;
  }
</style>

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

Unable to access $_SESSION variable when making AJAX request from a different port

After creating a website with PHP on port 80 (index.php) and setting the session variable with the userid upon login, I encountered an issue when clicking on a link that redirected me to port 8080, which is where a JavaScript file containing node.js proces ...

Validating data with Joi can result in multiple error messages being displayed for a single field

I'm attempting to implement a validation flow using the joi package, which can be found at https://www.npmjs.com/package/joi. 1) First, I want to check if the field category exists. If it doesn't, I should display the error message category requ ...

Having trouble uploading an image to AWS using Angular and NodeJS?

I am currently working on a Node/Express application and I need to gather file information for uploading from an Angular/Ionic front end. To achieve this, I have created a separate Service in Angular that successfully retrieves the Image name. However, my ...

Refresh Vue/Nuxt Components Fully

Understanding how this.$forceUpdate() functions, I am not simply looking to re-render the component. In Nuxt applications, page components have asyncData() as a lifecycle method that runs before created(). I utilize this method to retrieve initial data an ...

Unable to make a successful POST request using the JQuery $.ajax() function

I am currently working with the following HTML code: <select id="options" title="prd_name1" name="options" onblur="getpricefromselect(this);" onchange="getpricefromselect(this);"></select> along with an: <input type="text" id="prd_price" ...

What is the best method for ensuring that cheese rises to the top?

Is there a way to increase the value of the variable cheese? I suspect it has something to do with how the variable cheese is defined each time the JavaScript is activated, but I'm not sure how to go about it. Can you offer some guidance on this? & ...

Typescript implementation for a website featuring a single overarching file alongside separate files for each individual webpage

Although I've never ventured into the realm of Typescript before, I am intrigued by its concept of "stricter JS". My knowledge on the subject is currently very limited as I am just starting to experiment with it. Essentially, I have developed my own ...

A guide to building your own live HTML editing tool

I'm currently developing a PHP website that allows users to enter text into a textarea, and have the input displayed in a table in real time for a preview of the result. I am seeking guidance on how to make this feature possible. I have come across w ...

Implementing a persistent header on a WordPress site with Beaver Builder

My website URL is: . I have chosen to use beaver builder for building and designing my website. I am in need of a fixed header that can display over the top of the header image. Here is the code snippet that I currently have: <div id="header">html ...

Upon initializing mean.io assetmanager, a javascript error is encountered

I am eager to utilize the MEAN.io stack. I completed all the necessary initialization steps such as creating the folder, performing npm install, and obtaining the required libraries. Currently, in server/config/express.js file, I have the following code: ...

Heroku hosting a React/Node application that serves up index.html and index.js files, with a server actively running

It seems like the issue I'm facing is related to my start scripts. After researching online, I've come across various start scripts shared by different people. Some suggest using "start": "node index.js" -> (this doesn't start my server and ...

Guide on creating a Docker image from a Vue.js application and deploying it to a Nexus repository using GitLab's CI/CD pipeline

I am currently working on a Vuejs application that needs to be built in order to push into Nexus as a Docker image. All the Vuejs contents are stored on a GitLab repository. The pipeline consists of these stages: setup (retrieve information from pipeline ...

Adding non-reactive elements to reactive ones in VueORCombining static and dynamic components in

I am currently working on a project where I have a parent component called <v-window> that contains children elements of type <v-window-item>. The first child item is responsible for looping through data fetched from a Vuex getter and dynamical ...

Discover the key to optimizing your JavaScript development workflow by automating project structures and eliminating the need to start from scratch

I was looking for a way to streamline the process of setting up project structures for my projects so that I could utilize ALE linting and fixing without any hassle. After trying out one method, I'm confident that there must be a more efficient soluti ...

Is it possible to utilize the maximum value from the store in Vuelidate while implementing Vue?

Utilizing VUE and Vuelidate for form input validation, specifically within a modal popup that retrieves data through ...mapGetters from the store. When static values are set like this, it functions correctly : validations: { refundAmount: { ...

Count Scroller - Finding a Solution for _.debounce

Issue with Counter I have a counter that should increase or decrease by one each time the user scrolls up or down. The problem I'm facing is that my counter $('html').on('mousewheel', function (e) { var delta = e.originalEve ...

Creating an autocomplete feature with just one input field to display information for two to three additional input fields

I'm working on implementing an autocomplete feature similar to this example: . Feel free to test it out with the code snippets provided: 1000, 1001. I've successfully implemented the autocomplete functionality where typing in Pa suggests Paris. ...

Vue.js validation using vee-validate encountering an issue with errors

I am attempting to implement validation in Vue.js using vee-validate The version of Vue.js I am working with is 2.6.10 To install, I ran -npm install vee-validate In my main.ts file: import VeeValidate from "vee-validate"; Vue.use(VeeValidate); Howeve ...

What is the best way to deliver HTML and JavaScript content using Node.js from virtual memory?

Situation I'm currently developing an in-browser HTML/JS editor, utilizing memory-fs (virtual memory) with Webpack and webpack-html-plugin to package the files created by users in the editor. Storing the files in virtual memory helps avoid I/O operat ...

What is causing the error when trying to parse a JSON with multiple properties?

Snippet: let data = JSON.parse('{"name":"dibya","company":"wipro"}'); Error Message : An error occurred while trying to parse the JSON data. The console displays "Uncaught SyntaxError: Unexpected end of JSON input" at line 1, character 6. ...