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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:51:43+00:00 2026-06-06T03:51:43+00:00

Does that title sound confusing? I thought it might well anyways. When I person

  • 0

Does that title sound confusing? I thought it might well anyways.

When I person clicks on the page I want them to be able to me a little line shorter and long.

You can see what I mean here:

http://jsfiddle.net/shawn31313/HKLhE/9/show/

Do a Mousedown and them move your move to the right. It works fine.
But now, move you mouse to the left. See the problem? It goes the same direction as it did when you dragged to the right. I know this is because i’m using width and obviously width on goes one way.

This is my code so far:

$(document).ready(function() {
    var dragStatus = 0,
        getPos, giveRandomID;
    $(document).mousedown(function(event) {
        dragStatus = 0;
        getPos = {
            top: event.clientY,
            left: event.clientX
        };
        giveRandomID = Math.floor(Math.random() * 99999);
    });
    $(document).mousemove(function() {
        var line = $('#line' + giveRandomID);
        if (dragStatus == 0) {
            $('body').append("<div id='line" + giveRandomID + "' class='line' style='position:absolute;top:" + getPos.top + "px;left:" + getPos.left + "px;background:black;width:2px;height:5px'></div>");
            dragStatus = 1;
        }
        if (dragStatus == 1) {
            if (event.clientX > line.offset().left) {
                line.css({
                    width: event.clientX - line.offset().left
                });
            } else {
                line.css({
                    width: line.offset().left - event.clientX
                });
            }
            //for DEG  "-" Top-Math.abs(DEG*2) for Deg "+" Top+(DEG*2)
        }
    });
    $(document).mouseup(function() {
        dragStatus = 2;
    });
});​

I hope someone can help me out with this. Maybe a complete different way to set this up. Just something to fix this issue

  • 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-06T03:51:44+00:00Added an answer on June 6, 2026 at 3:51 am

    To make the line stretch to the left, you have to update the left property:

            if (event.clientX > getPos.left) {
                line.css({
                    left: getPos.left,
                    width: event.clientX - getPos.left
                });
            } else {
                line.css({
                    left: event.clientX,
                    width: getPos.left - event.clientX
                });
            }
    

    jsFiddle: http://jsfiddle.net/HKLhE/16/

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

Sidebar

Related Questions

I know that the title might sound a little contradictory, but what I'm asking
Ok this might sound a little vague from the title, but that's because I
Does DOM API provide HTMLTitle Object that implements Node interface? document.title returns only string
What the title says. Are they the same? I've noticed that the first does
I have a page title on a page. When I hover that title, I
Wow, that title was a mouthful... I'm sure that sounds very confusing at first
I know, the title does not sound good however I will explain it clearly.
What does that mean? Getting this in the console during usage of my app
There are a few things that the custom grid does that you cannot do
xmpp is federated. does that mean that as long as i connected to one

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.