File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change 1111// See the License for the specific language governing permissions and
1212// limitations under the License.
1313
14- import { useCallback , useEffect , useRef , useState } from 'react' ;
14+ import { useCallback , useEffect , useRef , useState } from 'react' ;
15+
16+
17+
18+ import { flushSync } from 'react-dom' ;
19+
20+
21+
1522
16- import { flushSync } from 'react-dom' ;
1723
1824const MIN_ZOOM = 1.0 ;
1925const MAX_ZOOM = 20.0 ;
@@ -91,7 +97,18 @@ export const useZoom = (containerRef: React.RefObject<HTMLDivElement | null>): U
9197 const handleWheel = ( e : WheelEvent ) : void => {
9298 if ( ! e . ctrlKey && ! e . metaKey ) return ;
9399 e . preventDefault ( ) ;
94- const newZoom = clampZoom ( zoomLevelRef . current * ( 1 - e . deltaY * WHEEL_ZOOM_SENSITIVITY ) ) ;
100+
101+ let delta = e . deltaY ;
102+ if ( e . deltaMode === 1 ) {
103+ delta *= 20 ;
104+ }
105+
106+ // Limiting the max zoom step per event to 15%, so to fix the huge jumps in Linux OS.
107+ const MAX_FACTOR = 0.15 ;
108+ const rawFactor = - delta * WHEEL_ZOOM_SENSITIVITY ;
109+ const zoomFactor = 1 + Math . max ( - MAX_FACTOR , Math . min ( MAX_FACTOR , rawFactor ) ) ;
110+
111+ const newZoom = clampZoom ( zoomLevelRef . current * zoomFactor ) ;
95112 applyZoom ( newZoom , e . clientX - container . getBoundingClientRect ( ) . left ) ;
96113 } ;
97114
You can’t perform that action at this time.
0 commit comments