diff --git a/modules/core/src/controllers/controller.ts b/modules/core/src/controllers/controller.ts index 0b5e0261596..fa531b0db1a 100644 --- a/modules/core/src/controllers/controller.ts +++ b/modules/core/src/controllers/controller.ts @@ -546,6 +546,12 @@ export default abstract class Controller t.end(); }); +test('OrthographicController scroll zoom resets isZooming state', t => { + const timeline = new Timeline(); + const view = new OrthographicView({controller: true}); + const baseProps = { + id: 'test-view', + x: 0, + y: 0, + width: 100, + height: 100, + target: [0, 0, 0], + zoom: 0, + scrollZoom: true + }; + const controllerProps = {...view.controller, ...baseProps}; + const ControllerClass = controllerProps.type; + + let currentProps = {...controllerProps}; + const interactionStates: any[] = []; + + const controller = new ControllerClass({ + timeline, + onViewStateChange: ({viewState}) => { + currentProps = {...currentProps, ...viewState}; + controller.setProps(currentProps); + }, + onStateChange: state => { + interactionStates.push({...state}); + }, + makeViewport: viewState => + view.makeViewport({width: currentProps.width, height: currentProps.height, viewState}) + }); + + controller.setProps(currentProps); + + const wheelEvent = { + type: 'wheel', + offsetCenter: {x: 50, y: 50}, + delta: -1, + srcEvent: {preventDefault() {}}, + stopPropagation: () => {} + }; + + controller.handleEvent(wheelEvent as any); + + // Verify we get exactly 2 state changes for non-smooth scroll zoom + t.is(interactionStates.length, 2, 'scroll zoom triggers exactly 2 state changes'); + + // Verify first state has isZooming: true + t.is(interactionStates[0].isZooming, true, 'isZooming is set to true at start'); + t.is(interactionStates[0].isPanning, true, 'isPanning is set to true at start'); + + // Verify last state has isZooming: false + t.is(interactionStates[1].isZooming, false, 'isZooming is reset to false at end'); + t.is(interactionStates[1].isPanning, false, 'isPanning is reset to false at end'); + + t.end(); +}); + test('FirstPersonController', async t => { await testController( t,