naver / egjs-axes

A module used to change the information of user action entered by various input devices such as touch screen or mouse into the logical virtual coordinates.
https://naver.github.io/egjs-axes/
MIT License
179 stars 31 forks source link

feat: add holding as reactive property #211

Closed malangfox closed 1 year ago

malangfox commented 1 year ago

Details

Added a new reactive property holding, available in vanilla and all frameworks. holding returns true if at least one input is in progress, such as pressing a mouse button or pressing a key.

Example for react-axes

import React, { useEffect, useRef } from "react";
import { useAxes, PanInput } from "@egjs/react-axes";

export default function Demo() {
  const { x, connect, holding } = useAxes(
    {
      x: {
        range: [0, 360],
        circular: true,
      },
    },
  );

  useEffect(() => {
    connect("x", new PanInput("#area"));
  }, []);

  return (
    <div id="area">
      /* Do something with using {holding} */
    </div>
  );
};