skip to Main Content

Html – Missing pointerup event in child element after setting pointerCapture on parent

I want to implement a drag effect on an element, so I used setPointerCapture in its pointerdown event handler like this: ele.addEventListener('pointerdown', (e)=>{ e.currentTarget.onpointermove = dosomething() e.currentTarget.setPointerCapture(e.pointerId) }) ele.addEventListener('pointerup', (e)=>{ e.currentTarget.onpointermove = null e.currentTarget.releasePointerCapture(e.pointerId) }) However, I run into problems…

VIEW QUESTION

Javascript – How to convert mouse position to canvas coordinate using object-fit: contain

Using object-fit: contain allow to resize a canvas to fit inside a container. This snippet is drawing a circle using mouse event position : canvas.width=1920; canvas.height=1200; const ctx=canvas.getContext("2d"); ctx.lineWidth = 10; ctx.strokeRect(0,0,canvas.width,canvas.height); canvas.onmousemove = (e) => { ctx.clearRect(0,0,canvas.width,canvas.height); ctx.strokeRect(0,0,canvas.width,canvas.height); ctx.beginPath();…

VIEW QUESTION

Html – How to get the hyperlink in a tag using javascript?

Here I have an html with javascript: document.addEventListener('mousedown', function(event) { let elem = event.target; let jsonObject = { Key: 'mousedown', Value: event.button }; if (event.button == 2) { console.log(elem.outerHTML); } }); <span style="font-size:xx-large"> <a href="https://microsoft.com" target="_blank" rel="noreferrer noopener" shape="rect" style="color:rgb(17,85,204)">…

VIEW QUESTION
Back To Top
Search