Giter Club home page Giter Club logo

Comments (8)

jakubfiala avatar jakubfiala commented on May 30, 2024 1

thanks for submitting the PRs @bencergazda – and sorry I'm getting to this late!

both PRs are looking good – going to approve & merge, then test the changes and publish

from atrament.

jakubfiala avatar jakubfiala commented on May 30, 2024

@Ben76 thanks for submitting the issue. Can you see any errors being thrown in the console? Alternatively, can you create a codepen/jsbin that demonstrates the issue?

from atrament.

bencergazda avatar bencergazda commented on May 30, 2024

@Ben76 @jakubfiala I was having the same issue. In my case, it occured only when we needed to scroll downwards the page to the canvas. In this situation, the scrollTop gets added to the mouse position when drawing (see + document.documentElement.scrollLeft in src/atrament.js#L31). Like this, if we scroll down for 10px, and the start painting, the drawing appears 10px under the mouse cursor/touch point.

See: https://codepen.io/bencergazda/full/OapvVL/

I did a quick test with removing the addition of document.documentElement.scrollLeft. This fixes the issue on Mobile Chrome, and looks like not causing problems in other browsers (Firefox, Desktop Chrome, Mobile Safari)

I can make a pull request with a fix.

from atrament.

jakubfiala avatar jakubfiala commented on May 30, 2024

this is now resolved in #39

from atrament.

viettq1986 avatar viettq1986 commented on May 30, 2024

Hello, I get the same stuck. Can you please check my app.
I can draw perfect on desktop and chrome simulator on desktop and main browser of android. But I can's draw correct on android chrome. It seem i get incorrect coordinate on touch

My app: https://zcolorqa.azurewebsites.net/

Many thanks

from atrament.

jakubfiala avatar jakubfiala commented on May 30, 2024

@viettq1986 thanks for reporting the issue. Could you please let me know how I can replicate the issue in your app? I'm having trouble finding the place where Atrament is used.

Also, what version of Android (and Chrome) are you using?

from atrament.

viettq1986 avatar viettq1986 commented on May 30, 2024

@viettq1986 thanks for reporting the issue. Could you please let me know how I can replicate the issue in your app? I'm having trouble finding the place where Atrament is used.

Also, what version of Android (and Chrome) are you using?

Hello, Sorry for your Atrament.

Please see my step by step:

image

image

image

image

I am using lasted android chrome version

image

My function for get mouse and touch coordinates
getCoordinate = (e, canvas) => {
let coordinate = {
x: 0,
y: 0
};

if (e.touches && e.touches.length > 0) {
let touch = e.touches[0]; //Get the information for finger #1
let rect = canvas.getBoundingClientRect();

//coordinate.x = Math.floor((touch.pageX - rect.left) * (canvas.width / rect.width));
//coordinate.y = Math.floor((touch.pageY - rect.top) * (canvas.height / rect.height));

coordinate.x = Math.floor((touch.pageX - rect.left) * (canvas.width / rect.width));
coordinate.y = Math.floor((touch.pageY - rect.top) * (canvas.height / rect.height));

let matrix = canvas.getContext("2d").getTransform();
let iMatrix = matrix.invertSelf();

coordinate = applyToPoint(iMatrix, coordinate);

} else {
if (e.offsetX) {
coordinate.x = e.offsetX;
coordinate.y = e.offsetY;
} else if (e.layerX) {
coordinate.x = e.layerX;
coordinate.y = e.layerY;
} else if (e.clientX) {
coordinate.x = e.clientX;
coordinate.y = e.clientY;
}
}

return coordinate;
}

Thank you very much

from atrament.

jakubfiala avatar jakubfiala commented on May 30, 2024

@viettq1986 I believe your issue might be solved in v4.0.0 - please feel free to reopen if the issue occurs again

from atrament.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.