Panscale

API

Scaler Class

Constructor

new Scaler(callback: (values: ScalerValues) => void, options?: Partial<ScalerOptions>)

Methods

  • setDimensions(clientW, clientH, contentW, contentH) — Set viewport/content size
  • setPosition(left, top) — Set element position in document
  • setSnapSize(width, height) — Set grid snap cell size
  • scrollTo(left, top, animate?) — Scroll to absolute position
  • scrollBy(dx, dy, animate?) — Scroll by relative delta
  • zoomTo(level, animate?, originX?, originY?) — Zoom to absolute level
  • zoomBy(factor, animate?, originX?, originY?) — Zoom by relative factor
  • getValues(): ScalerValues — Get current transform values
  • doTouchStart(touches, timeStamp) — Handle touch start
  • doTouchMove(touches, timeStamp) — Handle touch move
  • doTouchEnd(timeStamp) — Handle touch end
  • doMouseZoom(wheelDelta, timeStamp, pageX, pageY) — Handle mouse wheel zoom
  • activatePullToRefresh(height, callbacks) — Enable pull-to-refresh
  • finishPullToRefresh() — Complete pull-to-refresh cycle
  • destroy() — Clean up resources

ScalerValues

interface ScalerValues {
  matrix: Matrix;
  translateX: number;
  translateY: number;
  zoom: number;
  scrollLeft: number;
  scrollTop: number;
}

ScalerOptions

interface ScalerOptions {
  scrollingX: boolean;      // default: true
  scrollingY: boolean;      // default: true
  animating: boolean;       // default: true
  bouncing: boolean;        // default: true
  locking: boolean;         // default: true
  paging: boolean;          // default: false
  snapping: boolean;        // default: false
  zooming: boolean;         // default: false
  minZoom: number;          // default: 0.5
  maxZoom: number;          // default: 3
  deceleration: number;     // default: 0.95
  animationProvider: AnimationProvider | null; // default: null (auto-detect)
}

On this page