viewerjs icon indicating copy to clipboard operation
viewerjs copied to clipboard

Enable to force to zoom image at image center

Open YaoKaiLun opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe. Currently, the library enable users to zoom an image by wheel and touch event, and the zoom origin is depending on the mousestart or touchstart event position. what i need is to force the zoom origin at the image center, ignore the mousestart or touchstart event position.

Describe the solution you'd like Add a additional config option to force to zoom image at image center, like "zoomAtCenter", and it's default value is "false".

YaoKaiLun avatar Jul 26 '22 02:07 YaoKaiLun

You can override it by the zoom event:

new Viewer(image, {
  zoom(event) {
    if (event.detail.originalEvent) {
      event.preventDefault();
      this.viewer.zoomTo(event.detail.ratio);
    }
  }
});

fengyuanchen avatar Jul 28 '22 11:07 fengyuanchen