Thay đổi ngày 20260609
This commit is contained in:
+19
-19
@@ -43,6 +43,17 @@ function renderCustomHotspot(hotSpotDiv, args) {
|
||||
callout.appendChild(title);
|
||||
|
||||
hotSpotDiv.appendChild(callout);
|
||||
|
||||
// Gắn sự kiện chuột phải trực tiếp vào bong bóng callout
|
||||
callout.addEventListener('contextmenu', (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation(); // Ngăn chặn sự kiện lan truyền lên viewer
|
||||
|
||||
// Kiểm tra quyền và mở menu chỉnh sửa hotspot
|
||||
if (typeof window.openHotspotMenu === 'function') {
|
||||
window.openHotspotMenu(args.hotspotData); // Truyền dữ liệu hotspot đầy đủ
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,7 +99,8 @@ function initPanoramaViewer(imageUrl, hotspots = [], ownerId = null, initialPitc
|
||||
createTooltipFunc: renderCustomHotspot,
|
||||
createTooltipArgs: {
|
||||
title: h.title || target?.name || target?.title || "Điểm điều hướng",
|
||||
thumbUrl: thumbUrl
|
||||
thumbUrl: thumbUrl,
|
||||
hotspotData: h // Truyền toàn bộ dữ liệu hotspot vào args để sử dụng trong renderCustomHotspot
|
||||
},
|
||||
id: h._id,
|
||||
clickHandlerFunc: () => {
|
||||
@@ -158,6 +170,7 @@ function applyViewerSecurity() {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
e.stopImmediatePropagation();
|
||||
return false; // Ngăn chặn menu chuột phải mặc định của trình duyệt
|
||||
|
||||
// Nếu viewer đang hoạt động, lấy tọa độ Pitch/Yaw tại điểm click
|
||||
if (activeViewer) {
|
||||
@@ -177,25 +190,12 @@ function applyViewerSecurity() {
|
||||
const pitch = coords[0];
|
||||
const yaw = coords[1];
|
||||
|
||||
// Kiểm tra xem có hotspot nào gần điểm click không (ngưỡng 2 độ)
|
||||
const existing = currentHotspots.find(h =>
|
||||
Math.abs((h.coordinates?.pitch || h.pitch) - pitch) < 2 &&
|
||||
Math.abs((h.coordinates?.yaw || h.yaw) - yaw) < 2
|
||||
);
|
||||
|
||||
// Nếu không được phép, dừng xử lý và chặn menu mặc định
|
||||
if (!isAuthorized) return false;
|
||||
|
||||
if (existing) {
|
||||
// ĐÃ CÓ Hotspot -> Hiện Menu: [Sửa Hotspot] / [Xóa Hotspot]
|
||||
if (typeof window.openHotspotMenu === 'function') {
|
||||
window.openHotspotMenu(existing);
|
||||
}
|
||||
} else {
|
||||
// CHƯA CÓ Hotspot -> Hiện Form: [Tạo mới Hotspot]
|
||||
if (typeof window.handleHotspotCreation === 'function') {
|
||||
window.handleHotspotCreation(pitch, yaw, null);
|
||||
}
|
||||
// Nếu click chuột phải vào vùng trống, mở form tạo hotspot mới
|
||||
if (typeof window.handleHotspotCreation === 'function') {
|
||||
window.handleHotspotCreation(pitch, yaw, null);
|
||||
}
|
||||
console.log(`Coordinates captured: Pitch ${pitch}, Yaw ${yaw}`);
|
||||
}
|
||||
@@ -203,8 +203,8 @@ function applyViewerSecurity() {
|
||||
};
|
||||
|
||||
// Sử dụng capture phase (true) để bắt sự kiện trước khi nó chạm đến Pannellum
|
||||
container.addEventListener('contextmenu', handleContextMenu, true);
|
||||
panoramaViewer.addEventListener('contextmenu', handleContextMenu, true);
|
||||
// container.addEventListener('contextmenu', handleContextMenu, true); // Bỏ gắn sự kiện này
|
||||
// panoramaViewer.addEventListener('contextmenu', handleContextMenu, true); // Bỏ gắn sự kiện này
|
||||
|
||||
// Block drag and drop
|
||||
container.addEventListener('dragstart', (e) => {
|
||||
|
||||
Reference in New Issue
Block a user