@@ -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