# Circle radius increase decrease pointer behaves abnormally

Moderator Tag
Go to solution Solved by Rodrigo,

## Recommended Posts

Hello Everyone I hope you are doing well. I have a problem relating to the circle radius increase decrease pointer. so it works like when you drag the pointer away from the circle's center point it increases its radius and decreases when dragging towards the center point. it works fine but the pointer moves away from the circle border when you drag your mouse away from the pointer on the x-axis. I have provided the code pen so you can check it out thankyou ❤️.

##### Share on other sites

• Solution

Hi,

The problem is in the math you're doing for calculating the distance constant. In an ellipse you'll need both the values on the X and Y axis for that, but a triangle circumscribed in a circle it's always an Isosceles triangle, that means both sizes are equal an the angles are 45 degrees:

On top of that you are overcomplicating this quite a bit IMHO. This is far simpler, cleaner, seems to work the way you intend and you don't have to worry about the user dragging on the X axis:

```let radius = gsap.getProperty(table, "r");
const changeCircleSize = Draggable.create(dot, {
type: "y",
onDragStart: function () {
dragCircle[0].disable();
},
onDrag: function () {
},
onDragEnd: function () {
dragCircle[0].enable();
}
});```

Here is a fork of your demo:

See the Pen poxOpLN by GreenSock (@GreenSock) on CodePen

Hopefully this helps.

Happy Tweening!

• 5
##### Share on other sites

On 5/16/2023 at 9:00 PM, Rodrigo said:

Hi,

The problem is in the math you're doing for calculating the distance constant. In an ellipse you'll need both the values on the X and Y axis for that, but a triangle circumscribed in a circle it's always an Isosceles triangle, that means both sizes are equal an the angles are 45 degrees:

On top of that you are overcomplicating this quite a bit IMHO. This is far simpler, cleaner, seems to work the way you intend and you don't have to worry about the user dragging on the X axis:

```let radius = gsap.getProperty(table, "r");
const changeCircleSize = Draggable.create(dot, {
type: "y",
onDragStart: function () {
dragCircle[0].disable();
},
onDrag: function () {
},
onDragEnd: function () {
dragCircle[0].enable();
}
});```

Here is a fork of your demo:

Hopefully this helps.

Happy Tweening!

Man that was smooth. I didn't think about it that way thank you so much.  And more favour hwo to prevent the radius decrease upto only 20 radius it shouldn't be able to decrease than 20.

##### Share on other sites

Sounds like a good use case for clamp()

See the Pen da853be09052e3296cc321b566e75353 by PointC (@PointC) on CodePen

• 5