fin-hypergrid / core

A canvas-based super high performant grid renderer API
MIT License
897 stars 144 forks source link

Respect style.zoom #811

Closed joneit closed 5 years ago

joneit commented 5 years ago

HTMLElement..style.zoom is non-standard but widely supported. (The only exception is Firefox.)

This PR adds the following support for when a Hypergrid is zoomed by this feature (when any elements from <body> to <canvas> have their zoom style set to something other than 1):

  1. Canvas resolution is now optimized with respect to the zoom settings of all the elements in the chain
  2. Mouse tracking coordinates are now properly adjusted when zoomed

Tested on Chrome, Safari, IE 11 (which needed some special case coding), and regression tested on Firefox where it has no effect.

Added method grid.resetZoom() which should be called:

  1. Any time you set the zoom style of one or more of the elements in the chain. This does two things: Optimizes the canvas resolution; adjusts the mouse coordinates.
  2. After user adjusts browser zoom using ctrl +/- to optimize the resolution. This optimizes the canvas resolution for a sharper image. The mouse coordinates are not adjusted for browser zoom. The only way to tell if browser zoom changed (I believe) is to poll getComputedStyle(htmlElement).zoom (where htmlElement = document.body.parentElement).