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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:12:07+00:00 2026-05-26T23:12:07+00:00

I’m working in a proyect based on Netron (A graph editing library written in

  • 0

I’m working in a proyect based on Netron (A graph editing library written in JavaScript using the HTML5 canvas element. Double-click to edit an element. Drag connection points to draw connections.) But I need to put the Canvas into a DIV to add the scrollbar possibility when the canvas is bigger than the DIV.

All works fine in Firefox, Opera, Safari, Chrome… but Internet Explorer when I scroll (for example down) and click on this area into the canvas the Scroll is reset to initial position.

It’s an extraction of the failure code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Dynamics</title>
    <script type="text/javascript">
        var Graph = function (element) 
        {
            this.canvas = element;
            this.canvas.focus();
            this.context = this.canvas.getContext("2d");

            this.mouseDownHandler = this.mouseDown.bind(this);
            this.canvas.addEventListener("mousedown", this.mouseDownHandler, false);
        };

        // Acciones a realizar en el canvas segun los eventos de teclado y de mouse
        Graph.prototype.dispose = function () 
        {
            if (this.canvas !== null) 
            {
                this.canvas.removeEventListener("mousedown", this.mouseDownHandler);
            }
        };

        Graph.prototype.mouseDown = function (e) 
        {
            e.preventDefault();
            this.canvas.focus(); 
        };
    </script>

    <script type="text/javascript">
        function document_load() 
        {   
            graph = new Graph(document.getElementById("canvas"));

            // Draw a Circle
            var centerX = 300;
            var centerY = 800;
            var radius = 10;

            graph.context.beginPath();
            graph.context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);

            graph.context.fillStyle = "red";
            graph.context.fill();
            graph.context.lineWidth = 2;
            graph.context.strokeStyle = "black";
            graph.context.stroke();
        }
    </script>
</head>

<body onload="document_load();">
    <br/>

    <div id="canvas-div" style="width:800px;height:600px;background-color:#fff000;">
        <canvas id="canvas" tabindex="1" width="600" height="1000" style="border:solid 5px black;"></canvas>
    </div>
</body>
</html>

You can reproduce the error doing scroll down and click on red circle (or in the white are around the red circle). Yellow represent the DIV area.

EventLister is required, because is used to add elements to the canvas (example: Add Person in this page).

Sorry mi English isn’t very good. Thanks for all help you may provide.

  • 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-26T23:12:08+00:00Added an answer on May 26, 2026 at 11:12 pm

    I found a solution.

    Commenting the focus line.

    //this.canvas.focus();
    

    Without this instruction the canvas lose the focus then don’t move the scrollbar, but the rapid access key (like ctrl+z) defined don’t work. I change the other “Key” EventListener from “this.canvas” to “document” and works again.

    From:

    this.canvas.addEventListener("keydown", this.keyDownHandler, false);
    this.canvas.addEventListener("keypress", this.keyPressHandler, false);
    this.canvas.addEventListener("keyup", this.keyUpHandler, false);
    

    To:

    document.addEventListener("keydown", this.keyDownHandler, false);
    document.addEventListener("keypress", this.keyPressHandler, false);
    document.addEventListener("keyup", this.keyUpHandler, false);
    

    Thanks! I hope this solution can help others!

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

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
Configuring TinyMCE to allow for tags, based on a customer requirement. My config 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.