canvas

Disable Right Click in React.JS

落爺英雄遲暮 提交于 2020-08-06 08:40:28
问题 How to disable right click in canvas in ReactJS. Here is what I tried which is still not working: let Canvas = <canvas onContextMenu={(e)=> {e.preventDefault(); return false;}} height={500} width={500} ref="canvas"/>; A warning is also shown in browser console. Warning: Returning false from an event handler is deprecated and will be ignored in a future release. Instead, manually call e.stopPropagation() or e.preventDefault(), as appropriate. EDIT: Yes it did stop the right click functionality

Disable Right Click in React.JS

≡放荡痞女 提交于 2020-08-06 08:39:28
问题 How to disable right click in canvas in ReactJS. Here is what I tried which is still not working: let Canvas = <canvas onContextMenu={(e)=> {e.preventDefault(); return false;}} height={500} width={500} ref="canvas"/>; A warning is also shown in browser console. Warning: Returning false from an event handler is deprecated and will be ignored in a future release. Instead, manually call e.stopPropagation() or e.preventDefault(), as appropriate. EDIT: Yes it did stop the right click functionality

Canvas: Detect if it is visible in browser

一世执手 提交于 2020-08-06 05:19:13
问题 I have a list of charts. I use Chart.js to create those charts. Since my list can have 1 to 100 or more entries initializing all charts at once would not be smart because that would make the ui freeze for a long time. So instead I thought it would be much better to only initialize those charts which are visible inside the view bounds of the browser so that for example only the first chart is getting initialized and when the user scrolls down and the second canvas becomes visible the second is

Canvas: Detect if it is visible in browser

两盒软妹~` 提交于 2020-08-06 05:18:48
问题 I have a list of charts. I use Chart.js to create those charts. Since my list can have 1 to 100 or more entries initializing all charts at once would not be smart because that would make the ui freeze for a long time. So instead I thought it would be much better to only initialize those charts which are visible inside the view bounds of the browser so that for example only the first chart is getting initialized and when the user scrolls down and the second canvas becomes visible the second is

Getting mouse location in canvas [duplicate]

不羁岁月 提交于 2020-07-24 08:45:32
问题 This question already has answers here : How do I get the coordinates of a mouse click on a canvas element? (22 answers) Closed last year . Is there a way to get the location mouse inside a <canvas> tag? I want the location relative to to the upper right corner of the <canvas> , not the entire page. 回答1: Easiest way is probably to add a onmousemove event listener to the canvas element, and then you can get the coordinates relative to the canvas from the event itself. This is trivial to

Getting mouse location in canvas [duplicate]

馋奶兔 提交于 2020-07-24 08:45:13
问题 This question already has answers here : How do I get the coordinates of a mouse click on a canvas element? (22 answers) Closed last year . Is there a way to get the location mouse inside a <canvas> tag? I want the location relative to to the upper right corner of the <canvas> , not the entire page. 回答1: Easiest way is probably to add a onmousemove event listener to the canvas element, and then you can get the coordinates relative to the canvas from the event itself. This is trivial to

Send offscreencanvas to webworker more than once

梦想的初衷 提交于 2020-07-22 08:33:48
问题 I want to be able to send my canvas offscreen to a webworker more than once. Here's an example code: render() { const worker = new Worker("some url"); const offscreen = this.canvasRef.current.transferControlToOffscreen(); this.worker.postMessage({ offscreen }, [offscreen]); return ( <canvas ref={this.canvasRef} height="800" width="1000" /> ); } The idea is to be able to kill the web worker if user decides to cancel the drawing. Put when I repost the message to a new web worker, I get the

WPF - is there a way to remove specific child from Canvas.Children?

五迷三道 提交于 2020-07-19 03:51:09
问题 I am working on a charting control where I am plotting the "analysis range," which is just two vertical lines on the chart. A problem arises when I want to change the analysis range, because I don't know how to remove only the two analysis range lines, so I end up clearing the chart and plotting the actual data values and whatnot again. Is there a way to tag these UI elements (i.e. analysis range is a gridline UI element) so that I can remove them specifically? I suppose I could save the

CORS on canvas not working on Chrome and Safari

…衆ロ難τιáo~ 提交于 2020-07-18 17:00:12
问题 I'm trying to display images on a canvas. The images are hosted on S3. CORS is set up on AWS, and the CrossOrigin attribute is set to anonymous in the script. Everything works fine on Firefox — but images are not being loaded on Chrome and Safari. Errors Safari: Origin https://www.example.com is not allowed by Access-Control-Allow-Origin. http://mybucket.s3.amazonaws.com/bubble/foo.PNG [Error] Failed to load resource: Origin https://www.example.com is not allowed by Access-Control-Allow

Is there a way to send video data from a video tag/MediaStream to an OffscreenCanvas?

余生长醉 提交于 2020-07-16 07:40:34
问题 Basically I want to be able to perform effectively this same code: const video = document.getElementById('video'); const canvas = document.getElementById('canvas'); const context = canvas.getContext('2d'); const draw = () => { context.drawImage(video, 0, 0); requestAnimationFrame(draw); } video.onplay = () => { requestAnimationFrame(draw); } only using an offscreen canvas. I can send images over messages to the worker the offscreen canvas is on, but not video as it's directly tied to an