• DEVHIDE
        • Home (current)
        • About
        • Contact
        • Cookie
        • Home (current)
        • About
        • Contact
        • Cookie
        • Disclaimer
        • Privacy
        • TOS
        Login Or Sign up

        Vue JS transition using in v for

        224 Views Asked by Nima Asaadi At 29 January 2022 at 06:41 2025-12-09T23:55:32.092000

        Im new to vuejs and I have problem. look my code

        Template:

        <div class="component">
            <ul>
                <li v-for="game in games" :class="{active: isHover}" @mouseenter="isHover=true" @mouseleave="isHover=false">
                    <div class="poster">
                        <img :src="game.poster" :alt="game.title">
                    </div>
                    <transition name="show">
                        <div class="information" v-if="isHover">
                            <div class="name">
                                <p>{{game.name}}</p>
                            </div>
                            <div class="text">
                                <p>{{game.demo}}</p>
                            </div>
                            <div class="link">
                                <a href="#">OPEN LINK</a>
                            </div>
                        </div>
                    </transition>
                </li>
            </ul>
        </div>
        

        Script:

        // Library
        import {ref} from "vue";
        
        // Export
        export default {
            name: "GameBar",
            setup()
            {
                let isHover=ref(false)
                const games=ref([
                    {
                        name: 'RAINBOW SIX',
                        demo: 'Some Text Some Text Some Text Some Text Some Text Some Text',
                        poster: 'assets/home/media/game/3.jpg',
                    },{
                        name: 'PUBG',
                        demo: 'Some Text Some Text Some Text Some Text Some Text Some Text',
                        poster: 'assets/home/media/game/6.jpg',
                    }
                ])
                return {
                    isHover,games
                }
            }
        }
        

        Style:

        .component{
        
            // Animation
            .show-enter-active,.show-leave-active{
                transition: all 0.2s ease;
            }
            .show-enter-to,.show-leave-from{
                opacity: 1;
            }
            .show-enter-from,.show-leave-to{
                opacity: 0;
                top: 5px !important;
            }
        }
        

        Now my problem is when mouse enter on li, all li transition work and show information class. I know its because of isHover variable. but I don`t know how can I handle this like JQuery when using $(this).find(CHILD). I searched a lot but no solution found...

        vue.js transition v-for vuejs-transition
        Original Q&A
        1

        There are 1 best solutions below

        0
        mo3n mo3n On 29 January 2022 at 07:18 BEST ANSWER

        Defined a property in the components data function, for example hoveredItem, and then change @moueseenter and @mouseleave handlers to set this.hoveredItem accordingly. Here's the code:

          data() {
            return {
              hoveredItem: '',
            };
          },
        
        <li
          v-for="game in games"
          :key="game.name"
          :class="{active: game.name == hoveredItem}"
          @mouseenter="hoveredItem = game.name"
          @mouseleave="hoveredItem = ''"
        >
          <!-- rest of the code -->
        </li>
        

        Related Questions in VUE.JS

        • Problems with matter.js and i18n in vue.js
        • Form Validation not working in custom component Vue
        • Authenticating vue app on each route change
        • Vue/TailwindCSS - Content is behind Sidebar
        • Vue3 Suspense Parent > Child Animation
        • Pass dynamic object data via nuxt-link to component
        • Failed to resolve import, but the path is valid, and detected as such by VSCode
        • how to use less variables in vue components?
        • Prevent a webpage from navigating away
        • Creating a modal window in product edit page in Shopware6 and saving data to custom table(repository) from a form within the modal window
        • How do I fix (or ignore) a TypeScript error that's inside a HTML template?
        • Vue.js Checkbox Alignment Issue: Centering Checkboxes Within Table Cells
        • How to reset vue product filter?
        • Vue display output of two dimensional array
        • vue js error when adding bonus items to another item

        Related Questions in TRANSITION

        • How to make an animation happen everytime I click on a div that has the animation?
        • Script for transition plot in R
        • VueJS - Transition-group idea for single-item replacements
        • Tailwind transition stop working in React
        • Launch an Android Application programatically without an Animation/Transition
        • Page transition using next.js and R3F
        • CSS Error automatic zoom in background image when transition flex-grow
        • Transition for Gradient Background
        • transition animations for subviews in SwiftUI
        • Children view controllers must have a common parent view controller in swift
        • How to handle states and transitions in nestjs?
        • How to remove background of a view with different Transition?
        • Change Font Size of Text in Navigation
        • Nutx 3 layout transitions not working. Why?
        • How to add transition using a JS file

        Related Questions in V-FOR

        • Clicking the radio button inside a v-for loop changes at a time state to all of the radio button vue3
        • updating modelValue from the child component inside the v-for loop vue3
        • Vue.js v-for do no render image
        • How to use item id from v-for list in a method of underlying component in vue3
        • How to set css dynamically in v-for?
        • Array of image icons NOT loading very rarely sometimes
        • Apply methods to item in v-for array Vue 3 JS
        • Vue 3 - Cannot read index v-for index argument
        • Updating a "for" attribute of a label from an array in VueJS
        • Not able to push return of function into vue3 modal
        • Is there any way in javascript and vuejs to detect a dragevent from leaving the container?
        • DevXtreme DataGrid in Vue
        • How to compute an array and return a nested array of to numbers inside a parent array using vuejs/javascript?
        • Why scoped slots aren't working in vue js 3?
        • In Vue.js, how can I add additional parameters alongside an emit?

        Related Questions in VUEJS-TRANSITION

        • The transition behavior of Vue3 is different from Vue2. When controlling with template outside of transition
        • VueJS Migration from 2X to 3X Not Working
        • Vue JS transition using in v for
        • Paginated async Component doesn't trigger setup() on route change
        • Why do VueJS move animations only work in one direction?
        • props keep showing as $attrs in VUE DEV TOOLS
        • Vue3, which repository to use, vue3, or vue-next
        • How to use ternary operator in transition using javascript in vuejs?
        • Vuejs - transition-group carousel animation one item at a time
        • Slide transition on tab (one pushing the other)
        • How to split CodePen into webpacked Components?
        • Vuejs transition being does not work with child elemenets
        • Animate adding/deleting items from todo list using transition
        • Vue + Vuetify transition-group list animation issue when removing last item
        • How to clean cache from a vue.js website?

        Trending Questions

        • UIImageView Frame Doesn't Reflect Constraints
        • Is it possible to use adb commands to click on a view by finding its ID?
        • How to create a new web character symbol recognizable by html/javascript?
        • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
        • Heap Gives Page Fault
        • Connect ffmpeg to Visual Studio 2008
        • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
        • How to avoid default initialization of objects in std::vector?
        • second argument of the command line arguments in a format other than char** argv or char* argv[]
        • How to improve efficiency of algorithm which generates next lexicographic permutation?
        • Navigating to the another actvity app getting crash in android
        • How to read the particular message format in android and store in sqlite database?
        • Resetting inventory status after order is cancelled
        • Efficiently compute powers of X in SSE/AVX
        • Insert into an external database using ajax and php : POST 500 (Internal Server Error)

        Popular # Hahtags

        javascript python java c# php android html jquery c++ css ios sql mysql r reactjs node.js arrays c asp.net json

        Popular Questions

        • How do I undo the most recent local commits in Git?
        • How can I remove a specific item from an array in JavaScript?
        • How do I delete a Git branch locally and remotely?
        • Find all files containing a specific text (string) on Linux?
        • How do I revert a Git repository to a previous commit?
        • How do I create an HTML button that acts like a link?
        • How do I check out a remote Git branch?
        • How do I force "git pull" to overwrite local files?
        • How do I list all files of a directory?
        • How to check whether a string contains a substring in JavaScript?
        • How do I redirect to another webpage?
        • How can I iterate over rows in a Pandas DataFrame?
        • How do I convert a String to an int in Java?
        • Does Python have a string 'contains' substring method?
        • How do I check if a string contains a specific word?
        .

        Copyright © 2021 Jogjafile Inc.

        • Disclaimer
        • Privacy
        • TOS
        • Homegardensmart
        • Math
        • Aftereffectstemplates