-
-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[html-report] Add panning and wheel zoom for diagram
* add Ctrl + wheel zoom in for diagram only instead of whole page * add panning by mouse left click over the diagram
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
com.archimatetool.reports/templates/html/js/panelBodyScroller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
document.addEventListener('DOMContentLoaded', function () { | ||
const ele = document.getElementsByClassName('root-panel-body')[0]; | ||
ele.style.cursor = 'grab'; | ||
|
||
let pos = { top: 0, left: 0, x: 0, y: 0 }; | ||
let isBlockLink = false; | ||
|
||
[...ele.getElementsByTagName('area')].forEach((e)=> { | ||
e.addEventListener('click', (e)=>{ | ||
if(isBlockLink) e.preventDefault(); | ||
}); | ||
}) | ||
|
||
const mouseDownHandler = function (e) { | ||
e.preventDefault(); | ||
ele.style.cursor = 'grabbing'; | ||
ele.style.userSelect = 'none'; | ||
|
||
pos = { | ||
left: ele.scrollLeft, | ||
top: ele.scrollTop, | ||
// Get the current mouse position | ||
x: e.clientX, | ||
y: e.clientY, | ||
}; | ||
|
||
document.addEventListener('mousemove', mouseMoveHandler); | ||
document.addEventListener('mouseup', mouseUpHandler); | ||
}; | ||
|
||
const mouseMoveHandler = function (e) { | ||
isBlockLink = true; | ||
// How far the mouse has been moved | ||
const dx = e.clientX - pos.x; | ||
const dy = e.clientY - pos.y; | ||
|
||
// Scroll the element | ||
ele.scrollTop = pos.top - dy; | ||
ele.scrollLeft = pos.left - dx; | ||
}; | ||
|
||
const mouseUpHandler = function () { | ||
ele.style.cursor = 'grab'; | ||
ele.style.removeProperty('user-select'); | ||
|
||
document.removeEventListener('mousemove', mouseMoveHandler); | ||
document.removeEventListener('mouseup', mouseUpHandler); | ||
|
||
setTimeout(() => { | ||
isBlockLink = false; | ||
}, 100) | ||
}; | ||
|
||
// Attach the handler | ||
ele.addEventListener('mousedown', mouseDownHandler); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b8c4163
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This blocks selection of text in report documentation frames, e.g. for copy-paste. Can the panning by mouse left click be limited to the Diagram window only?
b8c4163
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for finding this. See #843 (comment)