-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #334 from jp7677/svg-pan-zoom2
Add pan and zoom for diagrams
- Loading branch information
Showing
10 changed files
with
137 additions
and
15 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
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
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
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
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
9 changes: 5 additions & 4 deletions
9
src/main/kotlin/nl/avisi/structurizr/site/generatr/site/views/RawHtml.kt
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
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
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,48 @@ | ||
let pz = undefined; | ||
|
||
function resetPz() { | ||
if (pz) { | ||
pz.resize(); | ||
pz.center(); | ||
pz.reset(); | ||
} | ||
} | ||
|
||
function openModal(id, svgId) { | ||
document.getElementById(id).classList.add('is-active') | ||
|
||
const svgElement = document.getElementById(svgId).firstElementChild; | ||
svgElement.classList.add('modal-svg') | ||
|
||
pz = svgPanZoom(svgElement, { | ||
zoomEnabled: true, | ||
controlIconsEnabled: true, | ||
fit: true, | ||
center: true, | ||
minZoom: 1, | ||
maxZoom: 5 | ||
}); | ||
resetPz(); | ||
|
||
// Reset position on window resize | ||
window.addEventListener('resize', resetPz); | ||
} | ||
|
||
function closeModal(id) { | ||
if (pz) { | ||
pz.destroy(); | ||
} | ||
window.removeEventListener('resize', resetPz); | ||
document.getElementById(id).classList.remove('is-active'); | ||
} | ||
|
||
// Add a keyboard event to close all modals | ||
document.addEventListener('keydown', (event) => { | ||
if (event.code === 'Escape') { | ||
(document.querySelectorAll('.modal') || []).forEach((modal) => { | ||
if (modal.classList.contains('is-active')) { | ||
closeModal(modal.id); | ||
} | ||
}); | ||
} | ||
}); |
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
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