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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:11:41+00:00 2026-05-30T21:11:41+00:00

I am trying to get this resizing object to work properly. When MouseDown (holding),

  • 0

I am trying to get this resizing object to work properly.

  1. When MouseDown (holding), object resizes to 80px.

  2. When release, I want the object to resize back to normal.

Problem:
As the object resizes from 100px to 80px on MouseDown, it may happen that the mouse is no more in the object itself, so releasing the mouse won’t trigger the “resize back to normal” animation again.

That’s why I tried to do a workaround with this:

 if (global.mouseup) and ($('#myimage').width('80px'))

Complete code at:
http://jsfiddle.net/G8Ste/568/

Thanks for any help !

  • 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-05-30T21:11:42+00:00Added an answer on May 30, 2026 at 9:11 pm

    Bind a mouseup handler to the document that resizes the img back to normal:

    $('#myimage').mousedown(function() {
        var img = $(this);
        img.stop().animate({
            width: ['80px', 'swing'],
            height: ['80px', 'swing'],
        }, 50, 'swing');
        $(document).one("mouseup", function(){
            img.css({width:"",height:""});
        });
    });
    

    Working demo: http://jsfiddle.net/G8Ste/569/

    A couple of notes about your code.

    • You don’t have a global variable defined, so you are getting an error there.
    • Instead of and, you must mean &&.

    Edit: You can, of course, use the animation as you have in your original code. Demo here: http://jsfiddle.net/G8Ste/574/. The limitation of that is that you have to duplicate code, specifying the default width and height in the CSS and in the JavaScript. You can resolve that any number of ways, such as using the technique I describe in this answer, or using jQuery-UI’s .switchClass() and related methods. Example using jQuery-UI:

    $('#myimage').mousedown(function() {
        var img = $(this);
        img.stop().addClass("small", 50);
        $(document).one("mouseup", function(){
            img.stop().switchClass("small", "large", 150, function() {
                img.removeClass("large", 1000);
            });
        });
    });
    

    Demo: http://jsfiddle.net/G8Ste/576/

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

Sidebar

Related Questions

Trying to get this to work, with no luck: [DataMember] public Type ParameterType {
I've been trying to get this code to work for hours! All I need
I'm trying to get this css layout to work with IE7 and I'm a
I've been trying to get this module to work and no matter what I've
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get
I'm trying to get this simple PowerShell script working, but I think something is
I'm trying to get this sample for AJAX to WCF working, with the following
I'm trying to get this piece of code working a little better. I suspect
I'm trying to get this sitemap clas s working. It appears to use LINQ,
I am trying to get this awesome JQuery plugin working with SQL Server. I

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.