mirror of
https://github.com/michivonah/click-guide.git
synced 2025-12-22 22:16:28 +01:00
add first version of coordinate saving to add-on #4
This commit is contained in:
parent
5efe19df58
commit
94fb124a40
3 changed files with 16 additions and 3 deletions
|
|
@ -73,6 +73,12 @@ document.addEventListener('click', function(){
|
|||
viewportX, viewportY, croppedWidth, croppedHeight,
|
||||
0, 0, croppedWidth, croppedHeight
|
||||
);
|
||||
|
||||
// calculate coordinates of the clicked element
|
||||
const elementStartX = Math.max((rect.left - (parentRect.left - pixelPadding / 2)), 0);
|
||||
const elementStartY = Math.max((rect.top - (parentRect.top - pixelPadding / 2)), 0);
|
||||
const elementEndX = elementStartX + rect.width;
|
||||
const elementEndY = elementStartY + rect.height;
|
||||
|
||||
const croppedDataUrl = canvas.toDataURL("image/jpeg");
|
||||
chrome.runtime.sendMessage({
|
||||
|
|
@ -80,7 +86,13 @@ document.addEventListener('click', function(){
|
|||
image: croppedDataUrl,
|
||||
stepLabel: elementText,
|
||||
stepElement: elementSelector,
|
||||
triggerName: "click"
|
||||
triggerName: "click",
|
||||
elementPosition: {
|
||||
startX: elementStartX,
|
||||
startY: elementStartY,
|
||||
endX: elementEndX,
|
||||
endY: elementEndY
|
||||
}
|
||||
}, (response) => {
|
||||
console.log(response);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue