Skip to content

Incompatibility with Card Tokens module #45

@shemetz

Description

@shemetz

Quoting from discord:

you are overriding MouseManager.prototype._onWheel my module just sets the events for the canvas

Hooks.on('canvasReady', (canvas)=>{
  canvas._onMouseWheel = function(event) {
    if ( event.altKey) {
      let degrees = 5;
      if (event.ctrlKey) degrees = 15;
      if (event.shiftKey) degrees = 45;
      canvas.stage.rotation = (event.delta < 0 ? (canvas.stage.rotation + Math.toRadians(degrees)) : (canvas.stage.rotation - Math.toRadians(degrees))) % (2*Math.PI);
      canvas.hud.align();
      Hooks.call('canvasPan', canvas, {});
      return;
    }
    let dz = ( event.delta < 0 ) ? 1.05 : 0.95;
    this.pan({scale: dz * canvas.stage.scale.x});
  }

  canvas.hud.align = function() {
    const hud = this.element[0];
    const {x, y} = canvas.primary.getGlobalPosition();
    const scale = canvas.stage.scale.x;
    hud.style.left = `${x}px`;
    hud.style.top = `${y}px`;
    hud.style.transform = `scale(${scale}) rotate(${Math.round(Math.toDegrees(canvas.stage.rotation)/5)*5}deg)`;
  }
});

I think your override prevents the event from ever reaching the canvas

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions