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

Configure handle size via CSS #37

Open
IlyaSemenov opened this issue Apr 10, 2024 · 0 comments
Open

Configure handle size via CSS #37

IlyaSemenov opened this issue Apr 10, 2024 · 0 comments

Comments

@IlyaSemenov
Copy link

Currently, the handle size is configured via style attributes and manual pixel value calculations:

tm: {
top: `${offset}px`,
left: `calc(50% - ${center}px)`,
},

That makes it very inconvenient to override it with CSS. For instance, I wanted the handle to increase slightly on hover, but that's not directly possible as you're not only hardcoding fixed width in a style but also use it to calculate fixed pixel offsets (see above).

I propose to get rid of handleInfo completely, and use CSS for handle size, and replace hardcoded values inside calc with translate for centering:

.handle {
  width: 8px;
  height: 8px;
  &-tl {
    top: 0;
    left: 0;
    transform: translate(-50%, -50%);
  }
  &-tr {
    top: 0;
    right: 0;
    transform: translate(50%, -50%);
  }
  &-bl {
    bottom: 0;
    left: 0;
    transform: translate(-50%, 50%);
  }
  &-br {
    bottom: 0;
    right: 0;
    transform: translate(50%, 50%);
  }
  &-rot {
    top: 0;
    left: 50%;
    transform: translate(-50%, -50%);
  }
}

This is what I actually ended up doing, passing :handle-info="{ size: 0, offset: 0, switch: true }" to get rid of the hardcoded offsets. My point is that's how the library should work in the first place.

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

1 participant