Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can i make this work on reactjs #33

Open
ionutale opened this issue Aug 22, 2018 · 7 comments
Open

how can i make this work on reactjs #33

ionutale opened this issue Aug 22, 2018 · 7 comments

Comments

@ionutale
Copy link

how can i make this work on reactjs ?

@itsmichaeldiego
Copy link

@jhonyourangel +1, I would love to use this library in web!

@ovidiudinu
Copy link

Me to pleeeease.

@nithin-aktivolabs
Copy link

badly need this lib in react JS...

@Quentinb
Copy link

Quentinb commented Jan 3, 2023

I've cloned this package and got it working in ReactJS. Just having some trouble with the "sliding" or "scrolling" of the start and end icons. It works, but does not follow the mouse quite as well as expected yet.
image

@ionutale
Copy link
Author

ionutale commented Jan 3, 2023 via email

@Quentinb
Copy link

Quentinb commented Jan 3, 2023

I'll play around some more with it today and then push the updates to git possibly tomorrow. It relates to calculating the new angle and length via the mouse X and Y. The old code does the calcs here, but I'm not quite sure what actual values moveX and moveY provide here. Are the relative to screen X/Y, or component X/Y etc...

onPanResponderMove: (evt, { moveX, moveY }) => {
  const { circleCenterX, circleCenterY } = this.state;
  const { angleLength, startAngle, onUpdate } = this.props;
  
  const currentAngleStop = (startAngle + angleLength) % (2 * Math.PI);
  let newAngle = Math.atan2(moveY - circleCenterY, moveX - circleCenterX) + Math.PI / 2;
  
  if (newAngle < 0) {
    newAngle += 2 * Math.PI;
  }
  
  let newAngleLength = currentAngleStop - newAngle;
  if (newAngleLength < 0) {
    newAngleLength += 2 * Math.PI;
  }

  onUpdate({ startAngle: newAngle, angleLength: newAngleLength % (2 * Math.PI) });
}

@Quentinb
Copy link

Quentinb commented Jan 8, 2023

I've pushed a working version to https://github.com/Quentinb/react-web-circular-slider and published it on NPM https://www.npmjs.com/package/react-web-circular-slider.

Still needs a bit of work and cleanup but us currently in a functioning state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants