@@ -297,6 +297,58 @@ describe('ScrollZoomHandler', () => {
297297
298298 } ) ;
299299
300+ test ( 'Zooms for single mouse wheel tick while in the center of the map, should zoom to center' , ( ) => {
301+ const browserNow = jest . spyOn ( browser , 'now' ) ;
302+ let now = 1555555555555 ;
303+ browserNow . mockReturnValue ( now ) ;
304+
305+ const map = createMap ( ) ;
306+ map . _renderTaskQueue . run ( ) ;
307+ expect ( map . getCenter ( ) . lat ) . toBeCloseTo ( 0 , 10 ) ;
308+ expect ( map . getCenter ( ) . lng ) . toBeCloseTo ( 0 , 10 ) ;
309+
310+ // simulate a single 'wheel' event
311+ simulate . wheel ( map . getCanvas ( ) , { type : 'wheel' , deltaY : - simulate . magicWheelZoomDelta , clientX : 200 , clientY : 150 } ) ;
312+ map . _renderTaskQueue . run ( ) ;
313+
314+ now += 400 ;
315+ browserNow . mockReturnValue ( now ) ;
316+ map . _renderTaskQueue . run ( ) ;
317+
318+ expect ( map . getCenter ( ) . lat ) . toBeCloseTo ( 0 , 10 ) ;
319+ expect ( map . getCenter ( ) . lng ) . toBeCloseTo ( 0 , 10 ) ;
320+ expect ( map . getZoom ( ) ) . toBeCloseTo ( 0.028567106927402726 , 10 ) ;
321+
322+ map . remove ( ) ;
323+ } ) ;
324+
325+ test ( 'Zooms for single mouse wheel tick while not in the center of the map, should zoom according to mouse position' , ( ) => {
326+ const browserNow = jest . spyOn ( browser , 'now' ) ;
327+ let now = 1555555555555 ;
328+ browserNow . mockReturnValue ( now ) ;
329+
330+ const map = createMap ( ) ;
331+ map . _elevateCameraIfInsideTerrain = ( _tr : any ) => ( { } ) ;
332+ map . _renderTaskQueue . run ( ) ;
333+ map . terrain = {
334+ pointCoordinate : ( ) => null
335+ } as any ;
336+
337+ // simulate a single 'wheel' event
338+ simulate . wheel ( map . getCanvas ( ) , { type : 'wheel' , deltaY : - simulate . magicWheelZoomDelta , clientX : 1000 , clientY : 1000 } ) ;
339+ map . _renderTaskQueue . run ( ) ;
340+
341+ now += 400 ;
342+ browserNow . mockReturnValue ( now ) ;
343+ map . _renderTaskQueue . run ( ) ;
344+
345+ expect ( map . getCenter ( ) . lat ) . toBeCloseTo ( - 11.6371 , 3 ) ;
346+ expect ( map . getCenter ( ) . lng ) . toBeCloseTo ( 11.0286 , 3 ) ;
347+ expect ( map . getZoom ( ) ) . toBeCloseTo ( 0.028567106927402726 , 10 ) ;
348+
349+ map . remove ( ) ;
350+ } ) ;
351+
300352 test ( 'Zooms for single mouse wheel tick while not in the center of the map and terrain is on, should zoom according to mouse position' , ( ) => {
301353 const browserNow = jest . spyOn ( browser , 'now' ) ;
302354 let now = 1555555555555 ;
0 commit comments