0.1.0 • Published 2 years ago

@dream07312/vue3-pinch-scroll-zoom v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

vue-pinch-scroll-zoom

Vue component that provides content scrolling and zooming using mouse events or two fingers pinch on a mobile devices

original_repo: https://github.com/coddicat/vue-pinch-scroll-zoom/tree/main_vue3

example:

https://vue-pinch-scroll-zoom.coddicat.com/

Installation

npm i @dream07312/vue3-pinch-scroll-zoom

Usage

template:

<PinchScrollZoom
  ref="zoomer"
  :width="300"
  :height="400"
  :scale="scale"
  @scaling="scalingHandler"
  style="border: 1px solid black"
>
  <img src="https://picsum.photos/600/1000" width="300" height="400" />
</PinchScrollZoom>

type script:

import { Component, Vue } from "vue-property-decorator";
import PinchScrollZoom, { PinchScrollZoomEmitData, PinchScrollZoomRef } from "@dream07312/vue3-pinch-scroll-zoom";

@Component({
  name: "PinchScrollZoomExample",
  components: {
    PinchScrollZoom
  }
})
export default class PinchScrollZoomExample extends Vue {
  private scale = 2;
  public scalingHandler(e: PinchScrollZoomEmitData): void {
    console.log(e);
  },
  public reset() {
    (this.$refs.zoomer as PinchScrollZoomRef).setData({
      scale: 1,
      originX: 0,
      originY: 0,
      translateX: 0,
      translateY: 0        
    });
  }
}

Props

the following properties don't support the ".async" modifier

namerequireddescriptiondefault
widthyesvisible area width
heightyesvisible area height
contentWidthnoshould be defined when content width larger than container width
contentHeightnoshould be defined when content height larger than container height
minScalenominimum allowable scaling0.3
maxScalenomaximum allowable scaling5
withinnolimit scrolling of content to its borderstrue
wheelVelocitynozoom velocity when mouse wheel0.001
scalenoscale of the content1
origin-xnotransform-origin-xwidth/2
origin-ynotransform-origin-yheight/2
translate-xnotransform: translateX0
translate-ynotransform: translateY0
throttleDelaynorendering delay (milliseconds)25
draggablenodraggable of/offtrue
enableScalingnofor enable listener scaling eventtrue
enableStartDragnofor enable listener startDrag eventtrue
enableStopDragnofor enable listener stopDrag eventtrue
enableDraggingnofor enable listener dragging eventtrue

Events

the following events are emitted with the argument:

export interface PinchScrollZoomEmitData {
  x: number;
  y: number;
  scale: number;
  originX: number;
  originY: number;
  translateX: number;
  translateY: number;  
}
  • startDrag
  • stopDrag
  • dragging
  • scaling

Methods

.SetData(data: PinchScrollZoomSetData);

export interface PinchScrollZoomSetData {
    scale: number;
    originX: number;
    originY: number;
    translateX: number;
    translateY: number;
}
0.1.0

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago