-
Notifications
You must be signed in to change notification settings - Fork 49
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
[Feature request] Twisty Player onclick event #344
Comments
This sounds pretty reasonable. I don't know when I could get around to implementing it, but I'd be happy to review a PR. |
@Dave2ooo, could I ask you to describe more about your use case? I've been thinking about how to adapt your PR, but it's much larger in scope than the use cases in this issue. I think the appropriate way forward definitely depends on the scope of use cases. |
For my F2L Trainer, I want the users to be able to get the next scramble by pressing (clicking) the cube. Right now, the user has to press a separate button to get the next scramble. Pressing the cube would be more comfortable than pressing the smaller button. You can try it.
One more thing: |
Sounds to me like the main feature you need are:
The former should certainly already be possible, and you can even change the cursor using CSS. For the latter, that sounds like a useful feature, but I'd like to hear a feature request from more people before designing such a feature it at this time. However, for now it should be possible for you to at least listen for when the orientation is not the default orientation. I'll see if I can prepare some sample code for you to do this. |
Okay, I think this will do what you want: import { TwistyPlayer } from "cubing/twisty";
const player = document.body.appendChild(new TwistyPlayer());
const resetButton = document.body.appendChild(document.createElement("button"));
resetButton.textContent = "🔄 Reset view";
player.experimentalModel.twistySceneModel.orbitCoordinatesRequest.addFreshListener(
(v) => {
resetButton.disabled = (v === "auto"); // Could also toggle `.hidden`
},
);
resetButton.addEventListener("click", () => {
player.experimentalModel.twistySceneModel.orbitCoordinatesRequest.set("auto");
}); |
Goal
In Twisty Player, I want to be able to detect when the user clicks on the element where the puzzle is shown, i.e.
div.visualisation-wrapper
is clicked.Dragging the puzzle could also be detected separately.
In my F2L Trainer, I would like to get to the next training case by clicking on the cube in Twisty Player.
Adding a
click
event listener to the whole Twisty Player would make the controls of Twisty Player unusable.I imagine using this feature like that:
Possible solution
Add a
click
event listener tovisualizationWrapperElem
that triggers a new eventpuzzle-click
.I don't know if it would be that simple.
Alternatives
Add the posibility to make the
#shadow-root
of Twisty Player open.The text was updated successfully, but these errors were encountered: