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 to `eventType` for better clarity ↞ [auto-sync from https://github.com/KudoAI/chatgpt.js-chrome-starter]
  • Loading branch information
kudo-sync-bot committed Dec 23, 2024
1 parent fbc4681 commit 010454c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions starters/chrome/extension/components/modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ window.modals = {
modals.dragHandlers.draggableElem = event.currentTarget
modals.dragHandlers.draggableElem.style.cursor = 'grabbing'
event.preventDefault(); // prevent sub-elems like icons being draggable
['mousemove', 'mouseup'].forEach(event => document.addEventListener(event, modals.dragHandlers[event]))
['mousemove', 'mouseup'].forEach(eventType =>
document.addEventListener(eventType, modals.dragHandlers[eventType]))
const draggableElemRect = modals.dragHandlers.draggableElem.getBoundingClientRect()
modals.dragHandlers.offsetX = event.clientX - draggableElemRect.left +21
modals.dragHandlers.offsetY = event.clientY - draggableElemRect.top +12
Expand All @@ -113,8 +114,8 @@ window.modals = {

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

0 comments on commit 010454c

Please sign in to comment.