简体   繁体   中英

Jquery with mouseover that works only on hover

i'm having some difficulty with the jquery mouseover.

I simply want to have the distortion effect happen when the mouse hovers over the image, and not when the mouse leaves. I am using mgGlitch for the effect and using jquery for the hover. I appreciate the help!

JQUERY

$(".glitch-img").hover(function() {
    $( ".glitch-img" ).mgGlitch({
      // set 'true' to stop the plugin
              destroy : false,
      // set 'false' to stop glitching
      glitch: true,
      // set 'false' to stop scaling
      scale: true,
      // set 'false' to stop glitch blending
      blend : true,
      // select blend mode type
      blendModeType : 'hue',
      // set min time for glitch 1 elem
      glitch1TimeMin : 200,
      // set max time for glitch 1 elem
      glitch1TimeMax : 400,
      // set min time for glitch 2 elem
      glitch2TimeMin : 10,
      // set max time for glitch 2 elem
      glitch2TimeMax : 100,
    }),


    // .mouseout(function() {
    //      $(".glitch-img").myGlitch({
    //          // set 'true' to stop the plugin
    //                destroy : false,
    //          // set 'false' to stop glitching
    //          glitch: false,
    //          // set 'false' to stop scaling
    //          scale: false,
    //          // set 'false' to stop glitch blending
    //          blend : false,
    // })

});

From the JQuery Docs :

The .hover() method binds handlers for both mouseenter and mouseleave events.

What you want to do instead is bind the event to the mouseover() function. Reference

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM