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

Allow clicking source and destination to move piece, in addition to dragging and dropping. #138

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

levi-rocha
Copy link

chessboard.js slightly modified to allow user to click a piece and a square in order to move that piece to that square, as opposed to only being able to move pieces by dragging and dropping. (Dragging and dropping still works as it did).

@efimBistrov
Copy link

Hi there! Is there any reason, why this pull request isn't merged yet?

@levi-rocha
Copy link
Author

I think the repo is abandoned

@oakmac
Copy link
Owner

oakmac commented May 1, 2017

I think the repo is abandoned

This project is not abandoned.

@oakmac
Copy link
Owner

oakmac commented May 1, 2017

Is there any reason why this pull request isn't merged yet?

The quick answer is that I haven't looked at it in depth.

The longer answer is that "click to move" is complex and I haven't considered the impact it will have on the API. I don't think it will be as simple as this in terms of events firing, etc.

@levi-rocha
Copy link
Author

Oh OK then. This was really only a small change I made for it to work with what I was doing, so that's understandable

@starlight93
Copy link

starlight93 commented Nov 14, 2017

https://drive.google.com/file/d/1pzETCeASSfB1rUWuDxkddGisKz--ziRw/view

I made a small changes of the original chessboard.js to move a piece by clicking only.
hope it will be useful,,,, I am just a newbie.

This was referenced Feb 8, 2020
@yarrichar
Copy link

A stepping stone towards this, that might be simpler is to just emit an event whenever a square is clicked.

@justingolden21
Copy link

Chiming in from 2021 here, would really love this feature. Some people prefer to click, others to drag. But either way, it's very difficult on mobile to drag and very easy to click, and most internet traffic is mobile. I think anybody using chessboard.js on a larger project will need this feature and either 1) add it themselves, or 2) use another library

That being said, I understand it's not as simple as clicking the merge PR button to add this, so take your time : )

@justingolden21
Copy link

@oakmac Would you be willing to add this feature to chessboard.js some time? I think it's just about necessary in order for anyone to play a game of chess on a mobile device (over half of the world wide web traffic is mobile) to move with clicking rather than dragging (which scrolls the page or requires a whole lot of finagling.

@oakmac
Copy link
Owner

oakmac commented May 3, 2021

Would you be willing to add this feature to chessboard.js some time?

Yes - I think this feature would be a good addition to the library. I do not have any plans to work on this right now (ie: working on this project compared to other things).

In the meantime, I think it should be pretty doable to "hand code" this by adding a click event on the board square <div>s.

@justingolden21
Copy link

@oakmac Thank you for the response. I think it's a very important feature.

Would you consider checking and merging the PR if @PINO was to make (an updated) one? (Or at least to emit an event when a square is clicked as @yarrichar suggested)

@MBDani
Copy link

MBDani commented Jun 1, 2021

@justingolden21 Hi, did you get the click and drag to work?

@justingolden21
Copy link

@MBDani I haven't done any work on anything in chessboard.js. I'm currently just using it at https://justingolden.me/chess/

@slolo2000
Copy link

Hello,

I would love to see this feature too.
I am working on a personal project on mobile and tablet and it is almost unusable to use it with drag and drop.
I have to made some "hacks" with css and html in order to avoid scrolling and bouncing effect (especially on iOS)

@frederikme
Copy link

Any updates on this?

@dav1312
Copy link

dav1312 commented Dec 5, 2022

This project is not abandoned.

It's been 6 years since this PR was opened...

@ZenLearner
Copy link

ZenLearner commented Dec 5, 2022 via email

@ebadi
Copy link

ebadi commented Dec 6, 2022

I am also subscribed to this post and impatiently hoping for any update.

@levi-rocha would it be possible for you to update your patch so we can use it unofficially?

@oakmac
Copy link
Owner

oakmac commented Dec 6, 2022

I have been working on chessboard2 recently, which will support "tap to move".

@juangocc
Copy link

juangocc commented Feb 2, 2023

I just commented line 1667 and it lets click to move but it repeats pieces when there is no previous piece selected. // if (!isDragging) return

@BinaryInitials
Copy link

I added an event listener on each of the squares to allow this "click to move" behavior. It works for the most part. But if I flip the board via board.flip(), for whatever reason, the event listener on the square doesn't work anymore. I checked to see if the id on the divs were perhaps regenerated but they weren't. Any ideas?

@BinaryInitials
Copy link

OK I think I found a fix. The function in the event listener was anonymous which for whatever reason caused the issue I described above. Not making it anonymous did the trick

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

Successfully merging this pull request may close these issues.

None yet