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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:55:12+00:00 2026-06-12T08:55:12+00:00

I´m trying to write with finger in canvas element. It works on desktop browsers

  • 0

I´m trying to write with finger in canvas element. It works on desktop browsers but not in the ipad.
I try with touchstart, touchend, touchmove event too, but it doesn´t work on ipad.

var pizarra_canvas
var pizarra_context

function init(){            
    pizarra_canvas = document.getElementById("pizarra");
    pizarra_context = pizarra_canvas.getContext("2d");
    pizarra_context.strokeStyle = "#000";
    pizarra_canvas.addEventListener('mousedown',empezarPintar,false);
    pizarra_canvas.addEventListener('mouseup',terminarPintar,false);
    }   

function empezarPintar(e){
pizarra_context.beginPath();
pizarra_context.moveTo(e.clientX-pizarra_canvas.offsetLeft,e.clientY-pizarra_canvas.offsetTop);
pizarra_canvas.addEventListener('mousemove',pintar,false)
}

function terminarPintar(e){
pizarra_canvas.removeEventListener('mousemove',pintar,false);
}

function pintar(e) {
pizarra_context.lineTo(e.clientX-pizarra_canvas.offsetLeft,e.clientY-pizarra_canvas.offsetTop);
pizarra_context.stroke();
}
  • 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-12T08:55:13+00:00Added an answer on June 12, 2026 at 8:55 am

    You need to cancel the default event (which is scrolling). Additionally, it is better that you trigger mouseup/touchend on the document because if you leave the dragging area and release the button then the canvas doesn’t know it should stop drawing.

    var pizarra_canvas
    var pizarra_context
    
    function init(){            
        pizarra_canvas = document.getElementById("pizarra");
        pizarra_context = pizarra_canvas.getContext("2d");
        pizarra_context.strokeStyle = "#000";
        pizarra_canvas.addEventListener('mousedown',empezarPintar,false);
        pizarra_canvas.addEventListener('touchstart',empezarPintar,false);
        document.addEventListener('mouseup',terminarPintar,false);
        document.addEventListener('touchend',terminarPintar,false);
        }   
    
    function empezarPintar(e){
      e.preventDefault();
      pizarra_context.beginPath();
      pizarra_context.moveTo(e.pageX-pizarra_canvas.offsetLeft,e.pageY-pizarra_canvas.offsetTop);
      pizarra_canvas.addEventListener('mousemove',pintar,false)
      pizarra_canvas.addEventListener('touchmove',pintar,false)
    }
    
    function terminarPintar(e){
      e.preventDefault();
      pizarra_canvas.removeEventListener('mousemove',pintar,false);
      pizarra_canvas.addEventListener('touchmove',pintar,false)
    }
    
    function pintar(e) {
      e.preventDefault();
      pizarra_context.lineTo(e.clientX-pizarra_canvas.offsetLeft,e.clientY-pizarra_canvas.offsetTop);
      pizarra_context.stroke();
    }
    init();
    

    Also, your css should have something like this on touch devices:

    body, html {
      height: 100%;
      overflow: hidden;
    }​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying write a function that generates simulated data but if the simulated
Trying to write out syslog entries containing strings but they don't register. // person.name
Trying to write a GLOBAL CBT HOOK, this is My code, but my hooking
I am trying write a script where when a user clicks on a link,
I m trying write code that after reset set up rrpmax as 3000. It
Trying to write app for service technicians that will display open service calls within
Trying to write a couple of functions that will encrypt or decrypt a file
Trying to write a chat, like on facebook, I wondered if two clients can
Trying to write a function to see how often an object exists and give
Trying to write a code at the moment that basically tests to see if

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.