How to use the panzoom function in panzoom

To help you get started, we’ve selected a few panzoom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github anvaka / sayit / src / lib / createRenderer.js View on Github external
export default function createRenderer(progress) {
  const scene = document.querySelector('#scene');
  const nodeContainer = scene.querySelector('#nodes');
  const edgeContainer = scene.querySelector('#edges');
  let lastPanTime = 0;
  let lastTouchEndTime = 0;
  let clickTimeout;

  const panzoom = createPanZoom(scene);
  const defaultRectangle = { left: -500, right: 500, top: -500, bottom: 500 };
  panzoom.showRectangle(defaultRectangle);

  // maps node id to node ui
  let nodes = new Map();

  let layout,
    graph,
    currentLayoutFrame = 0,
    linkAnimator;
  let textMeasure = createTextMeasure(scene);
  bus.on('graph-ready', onGraphReady);

  return {
    render,
    dispose
github ballerina-platform / ballerina-lang / composer / packages / diagram / src / diagram / diagram.tsx View on Github external
private createPanZoom() {
        if (!this.panZoomRootRef.current) {
            return;
        }

        this.panZoomRootRefCurrent = this.panZoomRootRef.current;
        this.panZoomComp = panzoom(this.panZoomRootRef.current, {
            beforeWheel: (e) => {
                // allow wheel-zoom only if ctrl is down.
                return !e.ctrlKey;
            },
            smoothScroll: false,
        });
        if (this.props.setPanZoomComp) {
            this.props.setPanZoomComp(this.panZoomComp, this.panZoomRootRef.current);
        }
    }
github anvaka / playground / vs / src / lib / createRenderer.js View on Github external
export default function createRenderer(progress) {
  const scene = document.querySelector('#scene');
  const nodeContainer = scene.querySelector('#nodes');
  const edgeContainer = scene.querySelector('#edges');
  const hideTooltipArgs = {isVisible: false};

  const panzoom = createPanZoom(scene);
  const defaultRectangle = {left: -500, right: 500, top: -500, bottom: 500}
  panzoom.showRectangle(defaultRectangle);

  // maps node id to node ui
  let nodes = new Map();

  let layout, graph, currentLayoutFrame = 0, linkAnimator;
  let textMeasure = createTextMeasure(scene);
  bus.on('graph-ready', onGraphReady);

  return {
    render,
    dispose
  }

  function dispose() {
github anvaka / fieldplay / src / lib / scene.js View on Github external
function initPanzoom() {
    let initializedPanzoom = makePanzoom(gl.canvas, {
      realPinch: true,
      zoomSpeed: 0.025,
      controller: wglPanZoom(gl.canvas, updateBoundingBox)
    });

    return initializedPanzoom;
  }
github anvaka / w-gl / src / scene.js View on Github external
getClientCoordinate,
    getTransform,
    getRoot,
    removeChild,
    setViewBox,
    setClearColor,
    dispose,
    renderFrame,

    getPixelRatio,
    setPixelRatio
  });

  var wglController = wglPanZoom(canvas, sceneRoot, api);

  var panzoom = makePanzoom(canvas, {
    zoomSpeed: 0.025,
    controller: wglController 
  });

  sceneRoot.bindScene(api);

  var disposeClick;
  listenToEvents();

  renderFrame();

  return api;

  function getPixelRatio() {
    return pixelRatio;
  }
github guildai / guildai / guild / view / src / components / guild-image-viewer.vue View on Github external
reset() {
      this.$refs.content.removeAttribute('style');
      if (this.pz) {
        this.pz.dispose();
        this.pz = undefined;
      }
      const opts = {
        maxZoom: 5.0,
        minZoom: 1.0,
        smoothScroll: false
      };
      this.pz = panzoom(this.$refs.content, opts);
    }
  }
github anvaka / yasiv-youtube / src / components / GraphView.vue View on Github external
mounted() {
    const { scene } = this.$refs;
    this.zoomHandle = panZoom(scene);
    const rect = this.$el.getBoundingClientRect();
    this.zoomHandle.moveTo(rect.width / 2, rect.height / 2);
    this.initEvents(scene);
    this.initializeGraph(this.graph);
  },

panzoom

Extensible, mobile friendly pan and zoom framework (supports DOM and SVG).

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis