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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:23:13+00:00 2026-06-03T10:23:13+00:00

tl;dr displaying a 2nd canvas element means user’s touch is lost – I don’t

  • 0

tl;dr

displaying a 2nd canvas element means user’s touch is lost – I don’t want user to have to touch screen again


I’m building an HTML5 Canvas game (the game displays a picture, slices it into puzzle pieces and then displays the pieces in a random order ready for the user to put the pieces back together again).

The source code (for my development branch) can be seen here:

https://github.com/Integralist/HTML5-Image-Slider-Game/tree/dragdrop

One key part of the game is that if the user clicks on a puzzle piece then that selected piece moves into any available space in the puzzle. If the user holds their click for more than a few milliseconds I assume they want to drag their selected puzzle piece instead of it automatically moving for them.

The way I do this, is by having another canvas sitting on top of the original canvas. This 2nd canvas is only ever used for the ‘drag and drop’ facility. The reason I went this route is that otherwise, while dragging my puzzle piece I would have needed to store the current puzzle state and then redraw it constantly – something I didn’t want to do for performance reasons.

What I’ve got so far works fine on mouse based computers because after I set up the piece to be dragged on the 2nd canvas I have a mousemove event which just fires and lets the user drag the piece around the canvas.

The problem I’m having is on touch devices, where because there is no mousemove event I’m using a touchmove event, but when I show the 2nd canvas and begin the drag process I have to touch the screen again to trigger the touchmove listener. As far as a user is concerned that is terrible because they have clicked and held their finger down on their device, but the 2nd canvas being displayed has caused that finger touch to lose focus and so they’ll be a bit disappointed that they now need to touch the screen again to start dragging.

I tried working around this by triggering a touchmove event manually but this didn’t work. If you download the code (see above) and try this on a touch device you’ll see what I mean. The puzzle piece suddenly jumps to the top left corner of the canvas for some reason? and also still requires me to touch the screen again for the touchmouse event to start triggering.

I’m really hoping this is just a minor issue and someone has a really clever work around for it.

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-03T10:23:14+00:00Added an answer on June 3, 2026 at 10:23 am

    What about this strategy? Try always having the second transparent canvas on top of the bottom one. When a user touches/clicks down, they are doing so on the top canvas, not the bottom one, and you just immediately erase the piece from the bottom canvas and draw it into the top canvas, then let them continue to keep moving it around?

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

Sidebar

Related Questions

i have two views 1st one is displaying list (uitableview used), user will select
I have application which uses fragments. Depending on screen size and orientation I'm displaying
Displaying Spring Dropdown in JSP if user does NOT have value in it.. I
Displaying Type here to ... until the user enters text into a TextBox is
There's a dropdown displaying 1-10 from where the user selects the number of textboxes
When windows is displaying the files through Window Explorer I need to have the
I'm displaying user messages through templates using RequestContext in Django, which gives access to
I have a datagrid with paging enabled. I am displaying the results in datagrid
displaying html problem with php & mysql Hi basically i have a quick mysql_fetch_array
I have two table views displaying the data from a Sqlite database. I can

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.