Vue.js transition-group does not apply the *-move class

As I dive into learning Vue, I find myself wondering if I may have overlooked something fundamental or stumbled upon a bug. Despite multiple readings of the documentation at https://v2.vuejs.org/v2/guide/transitions.html#List-Move-Transitions, I still can't shake the feeling that the first example should align with my current test.

Instructions: Simply click on the bars. I was under the impression that the *-move class would be applied to the elements in this scenario, but that does not appear to be the case.

View the JSFiddle here: https://jsfiddle.net/adarkar/unwgzt87/

HTML:

<html>
<head></head>
<body>

<svg id="svg" width="200" height="200">
  <g transform="translate(0,200) scale(1,-1)">
  <transition-group appear name="anim" tag="g">
  <rect v-for="(x,i) in xs" :key="x"
    :x="50*i" y="0" width="30" :height="50*x"
    style="fill: crimson;" @click="vue.xs.reverse()"></rect>
  </transition-group>
  </g>
</svg>

</body>
</html>

CSS:

.anim-move { transition: x 2s; }

Javascript:

var vue = new Vue({
  el: "#svg",
  data: { xs: [1,2,3] }
});

Answer №1

The CSS property known as transition is designed to transition between different CSS properties, rather than targeting specific element attributes (note that x is an SVG attribute). In the example you provided, it's actually transitioning the transform property.

If you prefer to use the shorthand version of the transition property, the correct syntax is as follows:

div {
  transition: <property> <duration> <timing-function> <delay>;
}

Here's a working example:

new Vue({
  el: "#svg",
  data: () => ({
    xs: [1, 2, 3]
  })
});
.anim-move {
  transition: transform 2s;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>

<svg id="svg" width="200" height="200">
  <g transform="translate(0,200) scale(1,-1)">
  <transition-group appear name="anim" tag="g">
    <rect v-for="(x,i) in xs" :key="x"
      :x="50*i" y="0" width="30" :height="50*x"
      style="fill: crimson;" @click="xs.reverse()">
    </rect>
  </transition-group>
  </g>
</svg>

If you need to apply the transition effect to multiple CSS properties, consider using the transition-property instead.

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

Developing interactive checkboxes for individual rows through React.js

Within a form, I have rows containing two inputs each. Upon clicking "add", a new row is created. For the second row onwards, by clicking "add" a checkbox labeled 1 should be added to indicate dependency on the previous row. In addition, for the third row, ...

Editable content area: Maintain and restore cursor position when placed on a blank line

While working with a contenteditable div and constantly updating the HTML as the user types, I am facing the challenge of saving and restoring the caret position. I came across a helpful solution provided by Tim Down on a similar issue, which I found on S ...

Exploring the connection between Jquery and Javascript event handling within ASP.NET C# code-behind, utilizing resources such as books and

It seems that Jquery, Javascript, and AJAX are gaining popularity now. I am interested in learning how to use this functionality within C#. Do you have any recommendations for resources or books that teach JavaScript from a C# perspective on the web? Not ...

The CSS style class is applied to two menus that share the same route but have different query parameters. These menus are styled with the class name

Utilizing both Vue and Vuetify version 3. For my navigation, I have implemented the v-navigation-drawer component alongside v-list for each menu item: <template> <v-navigation-drawer> <v-list nav> <v-list-item title=" ...

What is the best way to place a horizontal line behind buttons in a design?

Hello, I was experimenting with creating a background line behind the buttons on my webpage. Previously, I used an image for this purpose but now I want to achieve the same effect using a line. <div class="feedback-option"> <div class="radios2" ...

Efficient methods to reach the desired result using Selenium WebDriver promises

After working on a piece of code that utilizes Selenium WebDriver to retrieve the text of an element, I am wondering if there is a more concise way to accomplish this task? async function getText(driver, locator) { return await (await driver.findEleme ...

Aligning MaterialUI Grid items vertically within various Grid containers

Looking to implement a design that features three vertical columns. The first and last columns will display MaterialUI cards, while the middle column will showcase a vertical line with dots aligned vertically with the start of each card. The height of the ...

Limit image size in Outlook when using Mailchimp

I'm currently working on coding a Mailchimp template for a client and I've run into an issue with image dimensions. The problem arises when images exceed the width of the template (usually 600px), as they are displayed at their original size in ...

Is it possible to run Next.js 13 with React.js version 17?

Can Next.js 13 be used with React version 17? I upgraded my Next.js to version 13 and encountered a minimum requirement of React version 18, which is not compatible with my codebase. Is it possible to use Next.js 13 with React version 17 instead? ...

``A bidirectional data exchange mechanism enabling seamless communication between a parent and child

Currently, I am in the process of learning VueJS and experimenting with building a basic application that involves listing, viewing, creating, editing, and deleting stories. Each story consists of a title, content (text only), and a datetime stamp. So far, ...

Side navigation in Angular is not causing the main content to shrink

In my layout, I have a container that includes two sidenavs and multiple tables in between them. When I toggle the left sidenav, instead of the expected behavior where the content shrinks to accommodate the sidenav, the tables get pushed to the right as if ...

Convert numbers to words in the Indian currency format as you type up to a 16-digit number, displaying the Indian rupees symbol automatically without the need to click a button

How can we modify the code below to automatically add the Indian rupees symbol in the input field? https://i.sstatic.net/TlNLc.png $('.allow_decimal').keyup(function (event) { $(this).val(function (index, value) { return valu ...

"Utilizing Bootstrap 4: Wide text causes columns to stack on top of

My website has a layout with three columns: col-auto on the left, col in the middle, and col-auto on the right. The col-auto columns display skyscraper ads (600x160) while the col column contains text. However, when the text inside the col column is wide, ...

SwitchBase is undergoing a transformation where its unchecked state goes from uncontrolled to controlled. It is important to note that elements should not transition back and forth between un

There is a MUI checkbox I am using: <Checkbox checked={rowValues[row.id]} onChange={() => { const temp = { ...rowValues, [row.id]: !rowValues[row.id] }; setRowValues(temp); }} in ...

The ng-controller directive fails to function on the content of Kendo tabstrip tabs

My ng-controller is not functioning properly for the kendo tabstrip tab content. Could you please review my code below? <!--tabstripCtrl.js--> angular.module('tabstripApp',[]); var app = angular.module('tabstripApp'); app.con ...

Creating a dynamic word cloud in D3: Learn how to automatically adjust font sizes to prevent overflow and scale words to fit any screen size

I am currently utilizing Jason Davies' d3-cloud.js to create my word cloud, you can view it here 1. I'm encountering an issue where the words run out of space when the initial window size is too small. To address this, I have a function that cal ...

It seems like the method has already been executed despite encountering an unexpected end of JSON input error

Currently, I am utilizing the etherscan API to retrieve logs for certain events. Although my JSON parsing method seems quite traditional, an error is being thrown stating "unexpected end of JSON". function getEventHistory() { const topic0 = web3.util ...

What is preventing window.scrollTo() from being executed?

I have implemented Bootstrap's Buttons plugin to toggle the state of a custom checkbox. When the button is toggled on, a hidden element should appear at the top of the page and then the page should scroll to the top. Similarly, when the button is togg ...

What is the best way to modify a variable's value from a nested controller and vice versa?

There seems to be an issue with changing the 'mensaje' variable in both the "padre controller" and the "hijo controller" and visualizing the changes. When clicking on "cambiar padre," the value changes as expected. However, if I then click on "ca ...

Ways to separate a string based on changing values in Javascript

Given this unmodifiable string: "AAACCDEEB" I am looking to split it into an array whenever the value changes. In this scenario, I would end up with 5 arrays like so: [['A','A','A'], ['C','C'], [ ...