Skip to content

Commit fcf4426

Browse files
committed
Update Dynamsoft Document Viewer to v3.0.0
1 parent 4e77432 commit fcf4426

File tree

2 files changed

+17
-31
lines changed

2 files changed

+17
-31
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"angular-barcode-mrz-document-scanner": "file:",
2222
"dwt": "^19.1.0",
2323
"dynamsoft-capture-vision-bundle": "^3.0.3001",
24-
"dynamsoft-document-viewer": "^2.1.0",
24+
"dynamsoft-document-viewer": "^3.0.0",
2525
"dynamsoft-capture-vision-data": "^1.0.1",
2626
"rxjs": "~7.5.0",
2727
"tslib": "^2.3.0",
@@ -41,4 +41,4 @@
4141
"karma-jasmine-html-reporter": "~1.7.0",
4242
"typescript": "~4.6.2"
4343
}
44-
}
44+
}

src/app/document-viewer/document-viewer.component.ts

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -139,35 +139,7 @@ export class DocumentViewerComponent implements OnInit {
139139
uiConfig: this.isMobile() ? this.mobileEditViewerUiConfig : this.pcEditViewerUiConfig
140140
});
141141
this.editViewer.displayMode = "single";
142-
143-
// Load the dropdown menu
144-
let button: HTMLElement | null;
145-
if (this.isMobile()) {
146-
button = document.querySelector("#edit-viewer > div > div.ddv-layout.ddv-edit-viewer-footer-mobile > div.ddv-button.ddv-button.ddv-load-image");
147-
}
148-
else {
149-
button = document.querySelector("#edit-viewer > div > div.ddv-layout.ddv-edit-viewer-header-desktop > div:nth-child(1) > div.ddv-button.ddv-button.ddv-load-image");
150-
}
151-
152-
if (button) {
153-
button.addEventListener("click", (event) => {
154-
event.stopPropagation();
155-
156-
// Create dropdown if not exists
157-
if (!this.dropdown) {
158-
this.dropdown = this.createDropdownMenu();
159-
this.dropdown.style.position = "absolute";
160-
}
161-
162-
// Toggle visibility
163-
this.dropdown.style.display = this.dropdown.style.display === "block" ? "none" : "block";
164-
165-
// Position the dropdown below the button
166-
const rect = button!.getBoundingClientRect();
167-
this.dropdown.style.left = `${rect.left}px`;
168-
this.dropdown.style.top = `${rect.bottom + 5}px`;
169-
});
170-
}
142+
this.editViewer.on("toggleDropdown", this.toggleDropdown);
171143

172144
Dynamsoft.DWT.CreateDWTObjectEx({ "WebTwainId": "container" }, (obj) => {
173145
this.dwtObject = obj;
@@ -227,6 +199,20 @@ export class DocumentViewerComponent implements OnInit {
227199

228200
}
229201

202+
toggleDropdown = (e: any) => {
203+
e[0].stopPropagation();
204+
if (!this.dropdown) {
205+
this.dropdown = this.createDropdownMenu();
206+
this.dropdown.style.position = "absolute";
207+
}
208+
209+
// Toggle visibility
210+
this.dropdown.style.display = this.dropdown.style.display === "block" ? "none" : "block";
211+
const rect = e[0].target.getBoundingClientRect();
212+
this.dropdown.style.left = `${rect.left}px`;
213+
this.dropdown.style.top = `${rect.bottom + 5}px`;
214+
}
215+
230216
async convertToBlobAsync(dwtObject: any, indices: number[], imageType: any): Promise<Blob> {
231217
return new Promise((resolve, reject) => {
232218
dwtObject.ConvertToBlob(indices, imageType, (result: Blob) => {

0 commit comments

Comments
 (0)