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 8561651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:32:54+00:00 2026-06-11T16:32:54+00:00

For some reason, I’m having trouble getting an accurate height value for elements in

  • 0

For some reason, I’m having trouble getting an accurate height value for elements in an each() loop when the page loads, but when I try the exact same height() function on mouseleave, it works fine. See what I mean? It’s supposed to be getting the height of the description div, and using that to determine the initial position.

I thought this might have to do with the images needing to load before the height was set, so the load() was an attempt to delay until after that. It does seem to make the height larger than without it, but still smaller than the actual height. Any ideas?

jQuery(document).ready(function() {

var total = jQuery('.portfolio-item-holder figure').length;
var numLoaded = 0;

jQuery('.portfolio-item-holder img').one('load', function() {
  numLoaded++;
  if (numLoaded == total) {

    jQuery('.portfolio-item-holder figure').each(function(e) {
      var desc = jQuery(this).find('.description').outerHeight(true);
      console.log(desc);
      jQuery(this).find('figcaption').animate( { 'bottom' : -1 * desc }, 400, 'easeInOutQuart' );
    });

  }
}).each(function(){
  if(this.complete) jQuery(this).trigger('load');
});

jQuery('.portfolio-item-holder figure').bind('mouseenter', function(e) {

  var title = jQuery(e.currentTarget).find('h3').position();
  jQuery(e.currentTarget).find('figcaption').animate( { 'bottom' : '0', 'queue' : false }, 400, 'easeInOutQuart' ); 

}).mouseleave(function(e) {
  var desc = jQuery(e.currentTarget).find('.description').outerHeight(true);

  jQuery(e.currentTarget).find('figcaption').animate( { 'bottom' : -1 * desc, 'queue' : false }, 400, 'easeInOutQuart' ); 

});

});
  • 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-11T16:32:55+00:00Added an answer on June 11, 2026 at 4:32 pm

    Sometimes, when it doesn’t work one way, try to make it work some other way. This is what I recommend:

    1) In your CSS, 1a) set the .description class to display:none; and 1b) set the .portfolio-item-holder figcaption class to bottom:0px;

    2) Set-up the mouse event handlers:

    function PortfolioImageHandler() {
    
        $('#portfolio-item-holder').on({
    
              mouseenter: function () { ShowPortfolioDescription($(this)); },
              mouseleave: function () { HidePortfolioDescription($(this)); }
    
        }, '.portfolio-item');
    }
    

    3) Implement the event handlers:

    function ShowPortfolioDescription(ThePortfolioItem) {
        ThePortfolioItem.find('.description').stop().slideDown(500);
    }
    
    function HidePortfolioDescription(ThePortfolioItem) {
        ThePortfolioItem.find('.description').stop().slideUp(200);
    }
    

    4) Change your code structure to this:

    $(document).ready(function () {
      //you should only have calls to other functions, no actual implementations
      //should be coded in the document.ready function; keep the handlers out of here
      PortfolioImageHandler();
    });
    
    function PortfolioImageHandler() {...}
    function ShowPortfolioDescription (ThePortfolioItem) {...}
    function HidePortfolioDescription (ThePortfolioItem) {...}
    

    This will considerably reduce your code down to a few lines of code. Note that the .stop() function helps prevent the yoyo effect when the user repeatedly fires the mouseenter/mouseleave events: each event first cancels any ongoing animation before doing a slideUp or slideDown. Let me know how this works; here are 2 pics showing the result by manually modifying the settings in Chrome’s inspector. BTW, if you look at the site in IE8, the way you had it setup wasn’t going to work; the recommended implementation should work fine.

    enter image description here

    enter image description here

    Follow-up: I’m seeing Ellen all the way. Is the output on your browser any different?

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, this line of code is returning undefined for $(this).attr(href) $(a).attr(href, javascript:page('
For some reason, my spec isn't passing. It appears that @categories isn't getting to
For some reason, I am getting a weird overlapping dropdown menu glitch. It works
For some reason beyond me my html page is not finding my stylesheet. I'm
For some reason when I run the test method, I am getting a false
For some reason @store object with three attributes won't assign the third value(generated token
For some reason my code works for all the 10 digit numbers but not
For some reason I am getting the number or rows and not the results
For some reason I thought this should work but its eluding me I have
For some reason this page won't work in Opera + Safari http://dev.reggi.com/clients/mike2/ this is

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.