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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:04:02+00:00 2026-06-02T18:04:02+00:00

What I am doing is drawing rectangle in a div (#gd_graphics_grid) with divs acting

  • 0

What I am doing is drawing rectangle in a div (“#gd_graphics_grid”) with divs acting as pixels. The problem is it’s kinda slow. On Chrome it might be ok (a bit slow) but on IE it’s a nightmare (I know it’s normal, because IE JavaScript engine is slow). I want to know if there’s a way to optimize this code (tried to, but didn’t succeed) :

here’s the html/php that generate the divs:

<div id="gd_graphics">
    <p id="gd_loader">Veuillez patienter!</p>
    <div id="gd_graphics_grid">
         <?php for($row = 0; $row < 73; $row++) : ?>
         <div class="gd_grid_row">
             <?php for($block = 0; $block < 130; $block++) : ?>
             <div class="gd_grid_block"><div class="gd_grid_block_wrap"></div></div>
            <?php endfor; ?>
            <div class="gd_hidden"></div>
         </div>
         <?php endfor; ?>
    </div>
</div>

And here’s the javascript (only the part that refresh (and that slow my code) :

function RefreshDrag()
{
    $(".gd_selected_block").removeClass("gd_selected_block");

    if(startX <= endingX)
    {
        var minX = startX;
        var maxX = endingX;
    }
    else
    {
        var minX = endingX;
        var maxX = startX;
    }

    if(startY <= endingY)
    {
        var minY = startY;
        var maxY = endingY;
    }
    else
    {
        var minY = endingY;
        var maxY = startY;
    }

    var $row = null;
    var $block = null;
    var $left = null;
    var $right = null;
    var $this = null;
    var rowIndex = null;

    $(".gd_grid_row").slice(minY, maxY+1).each(function() {
        $row = $(this);
        rowIndex = $row.index();

        if(rowIndex == minY || rowIndex == maxY)
        {
            $row.children(".gd_grid_block").slice(minX, maxX+1).find(".gd_grid_block_wrap").each(function() {
                $this = $(this);

                $this.addClass("gd_selected_block");
            });
        }
        else
        {
            $left  = $row.children(".gd_grid_block").eq(minX).find(".gd_grid_block_wrap");
            $right = $row.children(".gd_grid_block").eq(maxX).find(".gd_grid_block_wrap");

            $left.addClass("gd_selected_block");

            $right.addClass("gd_selected_block");
        }
    });

}

.gd_selected_block is a class that change de background color of the div (to act as a line). Thanks in advance.

  • 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-02T18:04:04+00:00Added an answer on June 2, 2026 at 6:04 pm

    Why are you doing this, in 2012?

    Use some SVG library like Raphael or use HTML canvas element.

    If you want to stick with your style, try to use div borders as line, or an img as line and re-position them, though I am not sure what exactly you are trying to achieve

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

Sidebar

Related Questions

i'm doing an finger drawing app. I'm using Apple's example [here][1]. But i want
What am I doing wrong here? Im trying to save a canvas drawing by
Doing the below will reproduce my problem: New WPF Project Add ListView Name the
Doing some jquery animation. I have certain divs set up with an attribute of
Doing a simple Squeryl database lookup, but trying to exclude a value. I've tried:
The problem I have an array of java.awt.Rectangle s. For those who are not
I am doing a Drawing App. I have saved the color fill image as
I am doing some drawing on a CALayer and want to be able to
I'm a newbie to Graphics.I'm drawing a rectangle which will change its color after
I've narrowed a problem I have drawing on TImage.Canvas in Delphi 2009 down to

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.