About mouse slide events in vue

the following figure shows that if you want to make a mouse slide over the picture, the mesh box moves along with the mouse. Encountered a very strange problem, figure 1 is normal, but when I move the mouse again, it becomes figure 2. If you move continuously, the mesh box will flash. To put it bluntly, the first second mesh box will follow the mouse, but the next second the mesh box will return to the upper left corner. Figure 3

11

22

divleft3

3 figure 3

here is the code

template

<div 
    class="goods_description_pic"
    @mouseenter="showcheckeddetailelement=true"
    @mouseleave="showcheckeddetailelement=false"
    @mousemove="checkeddetailproduct($event)">
    <img :src="productinformation.productimg">
    <span
        v-show="showcheckeddetailelement"
        @mouseenter="showcheckeddetailelement=true"
        class="goods_description_detailed_see"
        :style="{ left: followcheckedx+"px", top: followcheckedy+"px"}"></span>
</div>

js

export default{
    data(){
        return {
            followcheckedx: 0,
            followcheckedy: 0
        }
    },
    methods: {
        checkeddetailproduct (e){
            // offsetX
            // e.clientX - e.offsetX 
            this.followcheckedx = e.offsetX - 75;
            this.followcheckedy = e.offsetY - 75;
            if(this.followcheckedx>=150){
                this.followcheckedx=150;
            }
            if(this.followcheckedy>=150){
                this.followcheckedy=150;
            }
            if(this.followcheckedx<0){
                this.followcheckedx=0;
            }
            if(this.followcheckedy<0){
                this.followcheckedy=0;
            }
            console.log("left:" + this.followcheckedx)
            }
    }
}

there must be something negligent. Thank you for taking a look at it for me. Let"s learn and make progress together

the main problem has been found. If you add a mousemove event to the outermost div, it is tantamount to adding a mousemove event to img and span, respectively, and they will relocate their elements according to the mouse, resulting in a situation where the first second is here and the next second is in another place.

the problem has been solved. Thank you for your help. I will try several other methods

Mar.05,2021

offsetX , offsetY is the XMagi Y coordinate of the mouse relative to event source element (event source: the element of the current operation is the event source)

while in div , there are also img and span , which will become the event source, and it will GG. I don't know which one to refer to.

what to do? Change the @ mousemove event to @ mousemove.self , and then delete img (if the mouse event is only for div, moving the mouse over the img will not trigger the div mouse event), and then you will find that it is "normal"

.

but! This is also flawed, when the mouse moves slightly over the mask, the mask will not follow, because the span (mask) will also prevent the mouse event from being triggered! (mouse contact with div,span will only follow the past when it moves by a large amount)

so let's use the following method to follow the mouse movement. I've written you an example for reference only, and you need to write it yourself for edge judgment.

  

this can only be used with mouse sliding. Is mouse sliding suitable for

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e43663-44a3d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e43663-44a3d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?