Skip to content

Commit

Permalink
p
Browse files Browse the repository at this point in the history
  • Loading branch information
fujioka committed Jul 22, 2024
1 parent 052dc03 commit 9ae3408
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ class Tray {
titleElement.setAttribute('contenteditable', 'false');
titleElement.style.pointerEvents = 'none';
}
this.setupEventListeners(tray);

return tray;
}
static templates = {
Expand Down Expand Up @@ -386,7 +388,34 @@ formatCreatedTime() {
saveToLocalStorage(); // ラベル追加後に保存
return id;
}
setupEventListeners(element) {
let longPressTimer;
let startX, startY;
const longPressDuration = 500;

element.addEventListener('touchstart', (e) => {
startX = e.touches[0].clientX;
startY = e.touches[0].clientY;

longPressTimer = setTimeout(() => {
this.showContextMenu(e);
}, longPressDuration);
});

element.addEventListener('touchmove', (e) => {
const threshold = 10;
if (Math.abs(e.touches[0].clientX - startX) > threshold ||
Math.abs(e.touches[0].clientY - startY) > threshold) {
clearTimeout(longPressTimer);
}
});

element.addEventListener('touchend', () => {
clearTimeout(longPressTimer);
});

// ... 他のイベントリスナー ...
}
updateLabels() {
let labelContainer = this.element.querySelector('.tray-labels');
if (!labelContainer) {
Expand Down

0 comments on commit 9ae3408

Please sign in to comment.