How to use referentiel - 3 common examples

To help you get started, we’ve selected a few referentiel 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 dungeon-revealer / dungeon-revealer / src / player-area.js View on Github external
const longPressProps = useLongPress(ev => {
    if (!mapCanvasDimensions.current) {
      return;
    }

    let input = null;
    // ev can be a touch or click event
    if (ev.touches) {
      input = [ev.touches[0].pageX, ev.touches[0].pageY];
    } else {
      input = [ev.pageX, ev.pageY];
    }

    // calculate coordinates relative to the canvas
    const ref = new Referentiel(panZoomRef.current.getDragContainer());
    const [x, y] = ref.global_to_local(input);
    const { ratio } = mapCanvasDimensions.current;

    socket.emit("mark area", { x: x / ratio, y: y / ratio });
  }, 500);
github dungeon-revealer / dungeon-revealer / src / dm-area / dm-map.js View on Github external
pageCoordinates => {
      const ref = new Referentiel(panZoomRef.current.dragContainer.current);
      const [x, y] = ref.global_to_local([
        pageCoordinates.x,
        pageCoordinates.y
      ]);
      const { ratio } = mapCanvasDimensions;
      return { x: x / ratio, y: y / ratio };
    },
    [mapCanvasDimensions]
github dungeon-revealer / dungeon-revealer / src / dm-area / dm-map.js View on Github external
onStateChange={() => {
          panZoomReferentialRef.current = new Referentiel(
            panZoomRef.current.dragContainer.current
          );
        }}
        ref={panZoomRef}

referentiel

Convert position relative to a html element.

MIT
Latest version published 8 months ago

Package Health Score

42 / 100
Full package analysis

Popular referentiel functions

Similar packages