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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:19:27+00:00 2026-05-15T22:19:27+00:00

I am having an issue getting addEventListener to trigger properly with my canvas element.

  • 0

I am having an issue getting addEventListener to trigger properly with my canvas element.

Issue:
When I add addEventLister onto my canvas element it automatically forces to animation refresh rate to run at the same time the event listener is being triggered.

Basically I have “setInterval(draw, 500);” which updates the canvas every 500 milliseconds. Without the event listener it will constantly refresh at it’s intended rate; however, when I add an action listener it force-refreshes canvas and causes all animations to speed up.

In the source code you will find two functions drawCircle and drawCircleTest which is specifically designed for testing the refresh issue.

hmm, for some reason the source code doesn’t want to paste properly

Source Code: http://home.insightbb.com/~epyonxl1/html5_test.htm

Thanks in advance for taking a look!!!

  • 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-15T22:19:28+00:00Added an answer on May 15, 2026 at 10:19 pm

    Because you’re calling draw on the mouseover event as soon as you move the mouse onto the canvas the next time the setInterval draw() is called the mouseover draw() calls have increased the value of testNum1 by more the number of mouseover events called. I’ve appended testNum1 to the end of the “Console” output here http://jsfiddle.net/uM5VC/ so you can see the affect (oddly this doesn’t work properly in chrome. The link below does).

    The solution is to use a different function for the mouseover event that sets the clientHeight and clientWidth to variables declared outside the scope of draw. See http://jsfiddle.net/aMdRm/3/

    I’ve added these variables before any of the functions

    var clientX, clientY;
    

    and this function to set them

    function changeCoords(e){
        clientX = e.clientX;
        clientY = e.clientY;
    }
    

    the mouseover event now use changeCoords and the draw event references clientX and clientY as opposed to e.clientX and e.clientY.

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

Sidebar

Related Questions

im having issue with getting position of an element. there are 4divs with position
I am having an issue getting observers to trigger when using seed data in
I'm having an issue getting the public keys for some of the .net 4.0
I'm having an issue getting the following syntax to work: <rewriter> <!-- This does
I am having an issue getting my data to return. I have two times
I'm having an issue getting surefire to run Junit4 tests. This same issue was
I'm having an issue getting a COUNT() from a SQL query using Zend_Db_Table_Select, and
I am having an issue getting Hibernate and Windsor to work together. My setup
I'm having an issue getting a LINQ query to work. I have this XML:
I'm having an issue getting some code to work. Is there a way 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.