1.0.7 • Published 2 years ago

canvas-marker v1.0.7

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

marker

hook that facilates creating markers on screen on click

NPM JavaScript Style Guide

Install

npm install --save canvas-marker

Usage

import { useMarker } from 'canvas-marker'

const App = () =>{
  const [setShowMarker, XY, setXY, getCoordinates] = useMarker(true);

  /** Remove all markers, i.e save state of markers 
      beforehand if you plan to reuse the again 
  */
  const resetMarker = () => {
    setShowMarker(false);
  }
  
  /** Add default marker points or get points 
      from previous marker session 
   */
  const addDefaultCoordinates = () => {
    setXY([[419,275], [534,308]]);
  }

  const points = XY.map((xy, index) =>
  <span>{`marker`}</span>
);
  return (
    <div className="App">
      <button onClick={resetMarker}>Reset</button>
      <button onClick={addDefaultCoordinates}>add default</button>
      <div className="Canvas" onClick={getCoordinates}>
       {points}
      </div>
    </div>
  );

Example

License

MIT © abdullah-jaffer


This hook is created using create-react-hook.

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago