Disable image dragging
This commit is contained in:
parent
319fab3da9
commit
50434ae7d2
|
@ -4,6 +4,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
$button = $modal.querySelector("button"),
|
||||
cls = 'is-active';
|
||||
|
||||
// Disable context menu on all images.
|
||||
(document.querySelectorAll('img, video') || []).forEach(node => {
|
||||
node.addEventListener('contextmenu', (e) => {
|
||||
$modal.classList.add(cls);
|
||||
|
@ -11,6 +12,15 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
});
|
||||
});
|
||||
|
||||
// Make images not draggable.
|
||||
(document.querySelectorAll('img') || []).forEach(node => {
|
||||
node.addEventListener('dragstart', (e) => {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
});
|
||||
node.setAttribute("draggable", "false");
|
||||
});
|
||||
|
||||
$button.addEventListener('click', () => {
|
||||
$modal.classList.remove(cls);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user