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

would like to change mirror offset when mirror moves over new container #507

Open
knutesears opened this issue Sep 6, 2021 · 2 comments

Comments

@knutesears
Copy link

knutesears commented Sep 6, 2021

Hi. Feature request here, or at least hope for a hack/workaround.

I have a mirror element that is resized (by my code, not the library). This happens when it moves over certain new containers, and then the offset of the mirror from the cursor is no longer proportional to the mirror size, i.e. the mirror is no longer where I want it relative to the cursor. I have been trying to figure out some hack to let me override or otherwise affect the transform: translate3d action that happens inside the library. It seems that once the mirror options cursorOffsetX and cursorOffsetY are set, there is no way to update them in a manner that affects the already created mirror element. I've tried nesting a wrapper div in there with its own transform: translate function, and many other things. Any bright ideas on a trick I'm missing? If not, consider this a request for a way to change the mirror offset whilst the mirror is moving around.

Thanks.

@bahung1221
Copy link
Contributor

I think this issue is related to #492 , which has a PR that was merged but unfortunately it doesn't release yet.
This project was somehow abandoned, you may want to use the latest code on master branch to have the latest update.

Hope this help. 🍻

@knutesears
Copy link
Author

So, I found a workaround. I listen for the mirror:move event, grab the relevant data from the event object, cancel the event, and then perform basically the same logic that the Draggable library would have used to move the mirror. The difference is that I can change the mirror offset before doing the translate3d transform.

If the library could be made to check if the offset had changed in the mirror options before doing the translate calculation -- rather than having looked at it only once and saved the initial value -- then I wouldn't have to do this. Would it be performance cost prohibitive to have it grab a fresh copy of the offset value each time? I'm sure there are other ways to modify it to do what I want, as well, but this one seems simple.

Anyway, thanks for pointing me at the other related issue, which jogged my brain.

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

2 participants