Skip to content

Commit

Permalink
Renamed event args of forEach loops in handlers.drag type metho…
Browse files Browse the repository at this point in the history
…ds of `alert()` to `eventType` for better clarity ↞ [auto-sync from https://github.com/KudoAI/chatgpt.js]
  • Loading branch information
kudo-sync-bot committed Dec 23, 2024
1 parent 22ace92 commit ae5ab19
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions starters/chrome/extension/lib/chatgpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ const chatgpt = {
chatgpt.draggableElem = event.currentTarget
chatgpt.draggableElem.style.cursor = 'grabbing'
event.preventDefault(); // prevent sub-elems like icons being draggable
['mousemove', 'mouseup'].forEach(event => document.addEventListener(event, handlers.drag[event]))
['mousemove', 'mouseup'].forEach(eventType =>
document.addEventListener(eventType, handlers.drag[eventType]))
const draggableElemRect = chatgpt.draggableElem.getBoundingClientRect()
handlers.drag.offsetX = event.clientX - draggableElemRect.left +21
handlers.drag.offsetY = event.clientY - draggableElemRect.top +12
Expand All @@ -114,8 +115,8 @@ const chatgpt = {

mouseup() { // remove listeners, reset chatgpt.draggableElem
chatgpt.draggableElem.style.cursor = 'inherit';
['mousemove', 'mouseup'].forEach(event =>
document.removeEventListener(event, handlers.drag[event]))
['mousemove', 'mouseup'].forEach(eventType =>
document.removeEventListener(eventType, handlers.drag[eventType]))
chatgpt.draggableElem = null
}
}
Expand Down

0 comments on commit ae5ab19

Please sign in to comment.