(event: MjolnirWheelEvent)
| 537 | |
| 538 | // Default handler for the `wheel` event. |
| 539 | protected _onWheel(event: MjolnirWheelEvent): boolean { |
| 540 | if (!this.scrollZoom) { |
| 541 | return false; |
| 542 | } |
| 543 | |
| 544 | const pos = this.getCenter(event); |
| 545 | if (!this.isPointInBounds(pos, event)) { |
| 546 | return false; |
| 547 | } |
| 548 | event.srcEvent.preventDefault(); |
| 549 | |
| 550 | const {speed = 0.01, smooth = false} = this.scrollZoom === true ? {} : this.scrollZoom; |
| 551 | const {delta} = event; |
| 552 | |
| 553 | // Map wheel delta to relative scale |
| 554 | let scale = 2 / (1 + Math.exp(-Math.abs(delta * speed))); |
| 555 | if (delta < 0 && scale !== 0) { |
| 556 | scale = 1 / scale; |
| 557 | } |
| 558 | |
| 559 | const transitionProps = smooth |
| 560 | ? {...this._getTransitionProps({around: pos}), transitionDuration: 250} |
| 561 | : NO_TRANSITION_PROPS; |
| 562 | |
| 563 | const newControllerState = this.controllerState.zoom({pos, scale}); |
| 564 | this.updateViewport( |
| 565 | newControllerState, |
| 566 | transitionProps, |
| 567 | { |
| 568 | isZooming: true, |
| 569 | isPanning: true |
| 570 | } |
| 571 | ); |
| 572 | |
| 573 | // When there's no transition (duration = 0), immediately reset interaction state |
| 574 | // since _onTransitionEnd callback won't fire |
| 575 | if (!smooth) { |
| 576 | this._setInteractionState({isZooming: false, isPanning: false}); |
| 577 | } |
| 578 | return true; |
| 579 | } |
| 580 | |
| 581 | protected _onMultiPanStart(event: MjolnirGestureEvent): boolean { |
| 582 | const pos = this.getCenter(event); |
nothing calls this directly
no test coverage detected
searching dependent graphs…