generated from microsoft/AL-Go-PTE
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add navigation and zooming functionality to control addin
Related to #47 Add navigation and zoom functionality to the control addin. - **MarkdownViewerANJ.ControlAddin.al**: Add `Navigate` and `Zoom` procedures. Update the `Scripts` section to include new JavaScript files for navigation and zooming. - **Scripts.js**: Add functions for handling navigation and zooming of the image. Update the `Draw` function to include navigation and zooming capabilities. - **Start.js**: Initialize navigation and zooming capabilities in the startup script. - **Style.css**: Add styles for navigation and zooming controls. Change background color while zooming. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/NovoaDev/Dependency-Graph-BCExt/issues/47?shareId=XXXX-XXXX-XXXX-XXXX).
- Loading branch information
Showing
4 changed files
with
153 additions
and
15 deletions.
There are no files selected for viewing
18 changes: 6 additions & 12 deletions
18
Dependency-Graph/src/ControlAddinViewer/MarkdownViewerANJ.ControlAddin.al
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 |
---|---|---|
@@ -1,25 +1,19 @@ | ||
/// <summary> | ||
/// ControlAddIn "MarkdownViewer_ANJ." | ||
/// </summary> | ||
namespace ANJ.Tools.Graph; | ||
controladdin MarkdownViewer_ANJ | ||
{ | ||
HorizontalShrink = true; | ||
RequestedHeight = 600; | ||
RequestedWidth = 650; | ||
Scripts = 'src\ControlAddinViewer\Scripts.js', 'https://cdnjs.cloudflare.com/ajax/libs/mermaid/9.3.0/mermaid.min.js'; | ||
Scripts = 'src\ControlAddinViewer\Scripts.js', 'https://cdnjs.cloudflare.com/ajax/libs/mermaid/9.3.0/mermaid.min.js', 'src\ControlAddinViewer\Navigation.js', 'src\ControlAddinViewer\Zoom.js'; | ||
Check failure on line 7 in Dependency-Graph/src/ControlAddinViewer/MarkdownViewerANJ.ControlAddin.al GitHub Actions / Build . (Default) / . (Default)
|
||
StartupScript = 'src\ControlAddinViewer\Start.js'; | ||
StyleSheets = 'src\ControlAddinViewer\Style.css'; | ||
VerticalShrink = true; | ||
|
||
/// <summary> | ||
/// Ready. | ||
/// </summary> | ||
event Ready(); | ||
|
||
/// <summary> | ||
/// Draw. | ||
/// </summary> | ||
/// <param name="Markdown">Text.</param> | ||
procedure Draw(Markdown: Text) | ||
} | ||
|
||
procedure Navigate(Direction: Text) | ||
|
||
procedure Zoom(Level: Decimal) | ||
} |
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 |
---|---|---|
@@ -1,3 +1,47 @@ | ||
HTMLContainer = document.getElementById("controlAddIn"); | ||
mermaid.initialize({ startOnLoad: false }); | ||
Microsoft.Dynamics.NAV.InvokeExtensibilityMethod("Ready", []); | ||
Microsoft.Dynamics.NAV.InvokeExtensibilityMethod("Ready", []); | ||
|
||
function initializeNavigationAndZoom() { | ||
const svgElement = document.querySelector('.MermaidDiv svg'); | ||
if (!svgElement) return; | ||
|
||
svgElement.setAttribute('preserveAspectRatio', 'xMidYMid meet'); | ||
svgElement.setAttribute('viewBox', `0 0 ${svgElement.clientWidth} ${svgElement.clientHeight}`); | ||
|
||
let isPanning = false; | ||
let startX, startY, startViewBox; | ||
|
||
svgElement.addEventListener('mousedown', (e) => { | ||
isPanning = true; | ||
startX = e.clientX; | ||
startY = e.clientY; | ||
startViewBox = svgElement.getAttribute('viewBox').split(' ').map(Number); | ||
}); | ||
|
||
svgElement.addEventListener('mousemove', (e) => { | ||
if (!isPanning) return; | ||
const dx = (startX - e.clientX) * (startViewBox[2] / svgElement.clientWidth); | ||
const dy = (startY - e.clientY) * (startViewBox[3] / svgElement.clientHeight); | ||
svgElement.setAttribute('viewBox', `${startViewBox[0] + dx} ${startViewBox[1] + dy} ${startViewBox[2]} ${startViewBox[3]}`); | ||
}); | ||
|
||
svgElement.addEventListener('mouseup', () => { | ||
isPanning = false; | ||
}); | ||
|
||
svgElement.addEventListener('mouseleave', () => { | ||
isPanning = false; | ||
}); | ||
|
||
svgElement.addEventListener('wheel', (e) => { | ||
e.preventDefault(); | ||
const scale = e.deltaY > 0 ? 1.1 : 0.9; | ||
const [x, y, width, height] = svgElement.getAttribute('viewBox').split(' ').map(Number); | ||
const newWidth = width * scale; | ||
const newHeight = height * scale; | ||
const newX = x - (newWidth - width) / 2; | ||
const newY = y - (newHeight - height) / 2; | ||
svgElement.setAttribute('viewBox', `${newX} ${newY} ${newWidth} ${newHeight}`); | ||
}); | ||
} |
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