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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:58:00+00:00 2026-05-26T17:58:00+00:00

My code is working fine, but Im getting a few problems. The first problem

  • 0

My code is working fine, but Im getting a few problems. The first problem regards to the browsers ability to drag images around, when it happens a “stop signal” appears, and it breaks the code. Sometimes the signal appears (firefox), sometimes not. I dont know why. The second problem regards to the text outside the div. When the user drag the image, the text outside gets selected. Who can I solve it?

If you run the code, you need a 140px width image.

The code:

<div style="position: relative; height: 100px; width: 100px; overflow: hidden;" class="img-profile">
    <div id="crop" style="position: absolute; width: 140px; left: -20px; height: 140px; top: 0px; background: url(/image/user/teste.jpg) no-repeat; cursor: move;"></div>
</div>

var x = 0; 
var y = 0;

$(document).ready(function () {

    $("#crop").mousedown(function () {

        var crop = $(this);

        $(document).mousemove(function (e) {

        var x_movement = 0;
            var y_movement = 0;

            if (x == e.pageX || x == 0) {
                x = e.pageX;
            } else {
                x_movement = e.pageX - x;
                x = e.pageX;
            }

            if (y == e.pageY || y == 0) {
                y = e.pageY;
            } else {
                y_movement = e.pageY - y;
                y = e.pageY;
            }

            var left = parseFloat(crop.css("left")) + x_movement;
            var min_left = 0;
            var max_left = -40;
            if (left >= min_left) left = min_left;
            if (left <= max_left) left = max_left;
            crop.css("left", left);

            var top = parseFloat(crop.css("top")) + y_movement;
            var min_top = 0;
            var max_top = (parseFloat(crop.css("height")) - 100) * -1;
            if (top >= min_top) top = min_top;
            if (top <= max_top) top = max_top;
            crop.css("top", top);

        });

    });

    $(document).mouseup(function () {

        x = 0;
        y = 0;
        $(document).unbind("mousemove");

    });

});
  • 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-26T17:58:01+00:00Added an answer on May 26, 2026 at 5:58 pm

    Just noted that changing the crop div to a input solved both problems.

    <input type="button" id="crop" style="position: absolute; width: 140px; left: -20px; height: 140px; top: 0px; background: url(/image/user/teste.jpg) no-repeat; cursor: move; border: 0px;" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off my code was working fine on simulator but it does not work
This is really strange but this code is working fine unless the value entered
I have jquery validation code which is working fine in ff but the same
I'using the following code to create thumbnails using ffmpeg but it was working fine
I created an ASMX file with a code behind file. It's working fine, but
Here is my code, everything is working fine the only problem is with the
I’m trying to issue web requests asynchronously. I have my code working fine except
So basically this code was working fine before. I had some computer issues and
My code was working absolutely fine before the launch of iPhone SDK 3.0 ,
Hi Javascript gurus, I have this Javascript code which is working fine on Firefox

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.