mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 21:11:30 +08:00 
			
		
		
		
	client-ts: Port services/app/components/zoom
This commit is contained in:
		
							parent
							
								
									6c7a272edc
								
							
						
					
					
						commit
						047c3eea69
					
				| @ -11,7 +11,10 @@ class ZoomComponent extends Component { | ||||
| 
 | ||||
|         if (utils.isElectron()) { | ||||
|             options.initializedPromise.then(() => { | ||||
|                 this.setZoomFactor(options.getFloat('zoomFactor')); | ||||
|                 const zoomFactor = options.getFloat('zoomFactor'); | ||||
|                 if (zoomFactor) { | ||||
|                     this.setZoomFactor(zoomFactor); | ||||
|                 } | ||||
|             }); | ||||
| 
 | ||||
|             window.addEventListener("wheel", event => { | ||||
| @ -22,14 +25,13 @@ class ZoomComponent extends Component { | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     setZoomFactor(zoomFactor) { | ||||
|         zoomFactor = parseFloat(zoomFactor); | ||||
| 
 | ||||
|     setZoomFactor(zoomFactor: string | number) { | ||||
|         const parsedZoomFactor = (typeof zoomFactor !== "number" ? parseFloat(zoomFactor) : zoomFactor); | ||||
|         const webFrame = utils.dynamicRequire('electron').webFrame; | ||||
|         webFrame.setZoomFactor(zoomFactor); | ||||
|         webFrame.setZoomFactor(parsedZoomFactor); | ||||
|     } | ||||
| 
 | ||||
|     async setZoomFactorAndSave(zoomFactor) { | ||||
|     async setZoomFactorAndSave(zoomFactor: number) { | ||||
|         if (zoomFactor >= MIN_ZOOM && zoomFactor <= MAX_ZOOM) { | ||||
|             zoomFactor = Math.round(zoomFactor * 10) / 10; | ||||
| 
 | ||||
| @ -57,7 +59,7 @@ class ZoomComponent extends Component { | ||||
|         this.setZoomFactorAndSave(1); | ||||
|     } | ||||
|      | ||||
|     setZoomFactorAndSaveEvent({zoomFactor}) { | ||||
|     setZoomFactorAndSaveEvent({ zoomFactor }: { zoomFactor: number }) { | ||||
|         this.setZoomFactorAndSave(zoomFactor); | ||||
|     } | ||||
| } | ||||
| @ -1,10 +1,10 @@ | ||||
| 
 | ||||
| import server from "./server.js"; | ||||
| 
 | ||||
| type OptionValue = string; | ||||
| type OptionValue = string | number; | ||||
| 
 | ||||
| class Options { | ||||
|     private initializedPromise: Promise<void>; | ||||
|     initializedPromise: Promise<void>; | ||||
|     private arr!: Record<string, OptionValue>; | ||||
| 
 | ||||
|     constructor() { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran