Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8250189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:48:04+00:00 2026-06-07T23:48:04+00:00

I’m having a slight problem with my script when the mouse hover out function

  • 0

I’m having a slight problem with my script when the mouse “hover out” function should be called. What’s happening is the “hover over” function gets called and a transition on an image is performed. But if you “hover out” before the transition has finished, the “hover out” function doesn’t get called.

I’m quite new to JavaScript so if anyone can find a silly mistake in my script that is easily rectified to get the intended functionality, I would very much appreciate it.

$(function () {
    var easing = 'swing';

    var transitions = ['fadeToRight', 'fadeToLeft', 'fadeToTop', 'fadeToBottom'];
    var transitionSpeed = 300;

    var $product_container = $('#product_container');
    var $product_areas = $product_container.find('.product_area');
    var $product_images = $product_container.find('img');
    var imageCount = 0;

    $product_images.each(function () {
        var $this = $(this);
        $('<img/>').load(function () {
            ++imageCount;
            if (imageCount == $product_images.length) {
                $product_areas.each(function () {
                    $(this).hover(
                        function () {
                            var $currImage = $(this).find('img');

                            var transition = transitions[Math.floor(Math.random() * transitions.length)];

                            switch (transition) {
                                case 'fadeToRight':
                                    $currImage.animate(
                                        {
                                            'left': $currImage.width() + 'px',
                                            'opacity': '0'
                                        },
                                        transitionSpeed,
                                        easing,
                                        function () {
                                            $currImage.hide().css(
                                                {
                                                    'z-index': '1',
                                                    'left': '0px',
                                                    'opacity': '1'
                                                });
                                        });
                                    break;

                                case 'fadeToLeft':
                                    $currImage.animate(
                                        {
                                            'left': -$currImage.width() + 'px',
                                            'opacity': '0'
                                        },
                                        transitionSpeed,
                                        easing,
                                        function () {
                                            $currImage.hide().css(
                                                {
                                                    'z-index': '1',
                                                    'left': '0px',
                                                    'opacity': '1'
                                                });
                                        });
                                    break;

                                case 'fadeToTop':
                                    $currImage.animate(
                                        {
                                            'top': -$currImage.height() + 'px',
                                            'opacity': '0'
                                        },
                                        transitionSpeed,
                                        easing,
                                        function () {
                                            $currImage.hide().css(
                                                {
                                                    'z-index': '1',
                                                    'top': '0px',
                                                    'opacity': '1'
                                                });
                                        });
                                    break;

                                case 'fadeToBottom':
                                    $currImage.animate(
                                        {
                                            'top': $currImage.height() + 'px',
                                            'opacity': '0'
                                        },
                                        transitionSpeed,
                                        easing,
                                        function () {
                                            $currImage.hide().css(
                                                {
                                                    'z-index': '1',
                                                    'top': '0px',
                                                    'opacity': '1'
                                                });
                                        });
                                    break;

                                default:
                                    $currImage.animate(
                                        {
                                            'left': -$currImage.width() + 'px'
                                        },
                                        transitionSpeed,
                                        easing,
                                        function () {
                                            $currImage.hide().css(
                                                {
                                                    'z-index': '1',
                                                    'left': '0px'
                                                });
                                        });
                                    break;
                            }
                        },
                        function () {
                            var $currImage = $(this).find('img');
                            $currImage.show();
                        });
                });
            }
        }).attr('src', $this.attr('src'));
    });
});

I would also like to say that the “hover out” function does get called if the transition is finished and you then move the mouse out of the container for the image. It just seems really weird that it doesn’t automatically go to the other function when you are no longer hovering.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:48:06+00:00Added an answer on June 7, 2026 at 11:48 pm

    This most likely is not an issue of your mouseout function not getting called (actually it get’s called like you observed when you let the animation finish) but your animation messing up your plans. By continuing after you left the element it simply overrides the rules you declare in the mouseout function.

    Add stop() in the mouseout function to stop the running animation and proceed afterwards:

          function () {
              var $currImage = $(this).find('img');
              $currImage.stop().show();
          });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I need a function that will clean a strings' special characters. I do NOT
I want to construct a data frame in an Rcpp function, but when I
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.