File tree 1 file changed +8
-3
lines changed
packages/s2-core/src/ui/hd-adapter
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -17,12 +17,14 @@ export class HdAdapter {
17
17
18
18
private spreadsheet : SpreadSheet ;
19
19
20
- private isDevicePixelRatioChange = false ;
20
+ private isDevicePixelRatioChange ;
21
21
22
22
private zoomOffsetLeft : number | undefined ;
23
23
24
24
constructor ( spreadsheet : SpreadSheet ) {
25
25
this . spreadsheet = spreadsheet ;
26
+ this . isDevicePixelRatioChange = false ;
27
+ this . zoomOffsetLeft = 0 ;
26
28
}
27
29
28
30
public init = ( ) => {
@@ -146,10 +148,13 @@ export class HdAdapter {
146
148
* 如果是触控板双指缩放触发的 resize 事件, offsetLeft 可以获取到值
147
149
* 如果是浏览器窗口的放大缩小 (command +/-), offsetLeft 始终是 0
148
150
*/
149
- const isTouchPadZoom = this . zoomOffsetLeft !== target . offsetLeft ;
151
+ const isTouchPadZoom =
152
+ ( this . zoomOffsetLeft || 0 ) !== ( target ?. offsetLeft || 0 ) ;
150
153
151
154
if ( ratio >= 1 && isTouchPadZoom && ! this . isDevicePixelRatioChange ) {
152
- await this . renderByDevicePixelRatio ( ratio ) ;
155
+ const maxDPR = Math . max ( ratio , window . devicePixelRatio ) ;
156
+
157
+ await this . renderByDevicePixelRatio ( maxDPR ) ;
153
158
this . zoomOffsetLeft = target . offsetLeft ;
154
159
}
155
160
} , 350 ) ;
You can’t perform that action at this time.
0 commit comments