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

  • SEARCH
  • Home
  • 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 9030825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:35:12+00:00 2026-06-16T07:35:12+00:00

On my site I have hover cards on users’ profile pictures. I’m having two

  • 0

On my site I have hover cards on users’ profile pictures. I’m having two issues.

  1. The first issue I am having is that it doesn’t work that nicely in terms of showing and hiding when you move your mouse on or off of the profile picture. When you move your mouse over a picture quickly (like if you are just moving your mouse across the page) after about a second it still pops up. I don’t see why though it’s doing this though. Only after 1000 milliseconds of hovering should the card pop up.

  2. The second issue I am having is that if you are hovering over one picture and you move to another picture (like one that is right above it) before the other one closes it just won’t work until you move your mouse off the picture and then move it back over it.

I’m wondering if there is just a better way to do the mouseenter and mouseleave events than how I am doing it right now.

hover card screenshot

Here’s my JavaScript for the hover card:

var timeout, timeout2, hovercard_request;
$('.profile-hovercard').live('mouseenter',function() {
if(!$('#hovercard').hasClass('open')) {
    var id = $(this).attr('data-id'),
        pos = $(this).offset(),
        width = $(this).outerWidth(),
        miniprofile_url = $(this).parent().attr('href') + '/mini_profile';
    timeout = setTimeout(function() {
        //$('#hovercard').remove();
        if ($('#hovercard').length <= 0) {
            var hc = '<div id="hovercard" class="open"> \
              <div class="hovercard-loading"><img src="/assets/img/ProgressIndicator.gif" /></div> \
              </div>';
            $('body').append(hc);
            $('#hovercard').css({
                'position': 'absolute',
                'top': pos.top + "px",
                'left': (pos.left + width + 11) + "px"
            });
        }
        else {
            $('#hovercard').css({
                'position': 'absolute',
                'top': pos.top + "px",
                'left': (pos.left + width + 11) + "px"
            }).html('<div class="hovercard-loading"><img src="/assets/img/ProgressIndicator.gif" /></div>').show().addClass('open');
        }
        $.get(miniprofile_url, {}, function(data) {
            $('#hovercard').html('<div class="hovercard-inner"> \
                                  <div class="hovercard-pic"> \
                                     <a href="'+data.url+'"><img src="' + data.img_path + '" alt="' + data.name + '" /></a> \
                                  </div> \
                                 <div class="hovercard-details"> \
                                 <h3><a href="'+data.url+'">' + data.name + ( data.you == 1 ? ' <span style="font-weight:normal">(you)</span>' : '' ) + '</a> ' + ( data.is_online ? '<span class="online-user-icon m" title="'+data.name+' is online."></span>' : '') + '</h3> \
                                 <div class="hovercard-stats"> \
                                     <strong class="points">' + data.points + ' point' + (data.points == 1 ? '' : 's') + '</strong><br /> \
                                     <strong>' + data.questions + '</strong> question' + (data.questions == 1 ? '' : 's') + ' / <strong>' + data.answers + '</strong> answer' + (data.answers == 1 ? '' : 's') + '<!-- / <strong>' + data.comments + '</strong> comment' + (data.comments == 1 ? '' : 's') + '--><br /> \
                                     <span class="location">' + data.location + '</span> \
                                 </div> \
                                 </div> \
                                 <div class="clear"></div> \
                                 </div>');
            if(data.bio !== '') {
                $('#hovercard').append('<div class="hovercard-bio">' + data.bio + '</div>');
            }
            else {
                $('#hovercard').append('<div class="hovercard-bio"><em>This user does not have a bio.</em></div>');
            }
        },'json').fail(function() {
            $('#hovercard').html('<div class="hovercard-loading">The request has failed. Please try again later.</div>');
        }).error(function() {
            $('#hovercard').html('<div class="hovercard-loading">An error has occurred. Please try again later.</div>');
        });
    }, 1000);
} // end if
});
$('.profile-hovercard').live('mouseleave',function() {
    clearTimeout(timeout);
    //hovercard_request.abort();
    timeout2 = setTimeout(function() {
       $('#hovercard').hide().removeClass('open');
    }, 400);
    $('#hovercard').hover(function() {
        clearTimeout(timeout2);
    },function() {
        timeout2 = setTimeout(function() {
            $('#hovercard').hide().removeClass('open');
        }, 300);
    });
});

When you hover over someone’s picture, it pops up a little box next to it showing some of their info. In the above code I have all the timeouts because that is the only way I could get the card to stay open so someone could move their mouse to the card without the card closing.

  • 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-16T07:35:14+00:00Added an answer on June 16, 2026 at 7:35 am

    You could try adding clearTimeout(x); before your setTimeout. This should make sure the timer isn’t started twice.

    Still this code could use some refactoring; the mouseenter handler is so long it makes it harder to understand what it does and to debug.

    var timeout, timeout2, hovercard_request;
    $('.profile-hovercard').live('mouseenter', function() {
        if (!$('#hovercard').hasClass('open')) {
            var id = $(this).attr('data-id'),
                pos = $(this).offset(),
                width = $(this).outerWidth(),
                miniprofile_url = $(this).parent().attr('href') + '/mini_profile';
    
            clearTimeout(timeout);
            timeout = setTimeout(function() {
                //$('#hovercard').remove();
                if ($('#hovercard').length <= 0) {
                    var hc = '<div id="hovercard" class="open"> \
                  <div class="hovercard-loading"><img src="/assets/img/ProgressIndicator.gif" /></div> \
                  </div>';
                    $('body').append(hc);
                    $('#hovercard').css({
                        'position': 'absolute',
                        'top': pos.top + "px",
                        'left': (pos.left + width + 11) + "px"
                    });
                }
                else {
                    $('#hovercard').css({
                        'position': 'absolute',
                        'top': pos.top + "px",
                        'left': (pos.left + width + 11) + "px"
                    }).html('<div class="hovercard-loading"><img src="/assets/img/ProgressIndicator.gif" /></div>').show().addClass('open');
                }
                $.get(miniprofile_url, {}, function(data) {
                    $('#hovercard').html('<div class="hovercard-inner"> \
                                      <div class="hovercard-pic"> \
                                         <a href="' + data.url + '"><img src="' + data.img_path + '" alt="' + data.name + '" /></a> \
                                      </div> \
                                     <div class="hovercard-details"> \
                                     <h3><a href="' + data.url + '">' + data.name + (data.you == 1 ? ' <span style="font-weight:normal">(you)</span>' : '') + '</a> ' + (data.is_online ? '<span class="online-user-icon m" title="' + data.name + ' is online."></span>' : '') + '</h3> \
                                     <div class="hovercard-stats"> \
                                         <strong class="points">' + data.points + ' point' + (data.points == 1 ? '' : 's') + '</strong><br /> \
                                         <strong>' + data.questions + '</strong> question' + (data.questions == 1 ? '' : 's') + ' / <strong>' + data.answers + '</strong> answer' + (data.answers == 1 ? '' : 's') + '<!-- / <strong>' + data.comments + '</strong> comment' + (data.comments == 1 ? '' : 's') + '--><br /> \
                                         <span class="location">' + data.location + '</span> \
                                     </div> \
                                     </div> \
                                     <div class="clear"></div> \
                                     </div>');
                    if (data.bio !== '') {
                        $('#hovercard').append('<div class="hovercard-bio">' + data.bio + '</div>');
                    }
                    else {
                        $('#hovercard').append('<div class="hovercard-bio"><em>This user does not have a bio.</em></div>');
                    }
                }, 'json').fail(function() {
                    $('#hovercard').html('<div class="hovercard-loading">The request has failed. Please try again later.</div>');
                }).error(function() {
                    $('#hovercard').html('<div class="hovercard-loading">An error has occurred. Please try again later.</div>');
                });
            }, 1000);
        } // end if
    });
    $('.profile-hovercard').live('mouseleave', function() {
        clearTimeout(timeout2);
        //hovercard_request.abort();
        timeout2 = setTimeout(function() {
            $('#hovercard').hide().removeClass('open');
        }, 400);
        $('#hovercard').hover(function() {
            clearTimeout(timeout2);
        }, function() {
            clearTimeout(timeout2);
            timeout2 = setTimeout(function() {
                $('#hovercard').hide().removeClass('open');
            }, 300);
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this site, please note that in a:hover put the source as bold.
I have a Wordpress site that uses a JQuery plugin called Hover-Caption ( https://github.com/coryschires/hover-caption
I have a site that changes the content of the page when you hover
I have a small menu logo wiggle on my site when you hover over
So I have site list on certain pages that basically just have links to
In my live site I have php include() and require() that have full path
For example I have site http://localhost/site In IIS I set that 404 error causes
I have a fairly image heavy site and have image rollovers (:hover) on a
I have a site where are two news items on the home page. They
I have created this JavaScript so that when you hover over a div it

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.