chessboardjs icon indicating copy to clipboard operation
chessboardjs copied to clipboard

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

Open levi-rocha opened this issue 8 years ago • 22 comments

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).

levi-rocha avatar Dec 09 '16 21:12 levi-rocha

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

efimBistrov avatar May 01 '17 14:05 efimBistrov

I think the repo is abandoned

levi-rocha avatar May 01 '17 19:05 levi-rocha

I think the repo is abandoned

This project is not abandoned.

oakmac avatar May 01 '17 19:05 oakmac

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.

oakmac avatar May 01 '17 19:05 oakmac

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

levi-rocha avatar May 01 '17 19:05 levi-rocha

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.

starlight93 avatar Nov 14 '17 04:11 starlight93

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

yarrichar avatar May 28 '20 12:05 yarrichar

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 avatar Mar 05 '21 04:03 justingolden21

@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.

justingolden21 avatar May 02 '21 02:05 justingolden21

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.

oakmac avatar May 03 '21 16:05 oakmac

@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)

justingolden21 avatar May 03 '21 22:05 justingolden21

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

MBDani avatar Jun 01 '21 16:06 MBDani

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

justingolden21 avatar Jun 01 '21 22:06 justingolden21

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)

slolo2000 avatar Jun 20 '21 20:06 slolo2000

Any updates on this?

frederikme avatar Dec 28 '21 10:12 frederikme

This project is not abandoned.

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

dav1312 avatar Dec 05 '22 09:12 dav1312

It would be important for iPads….Sent from my iPadFernando SemprunOn 5 Dec 2022, at 10:55, dav1312 @.***> wrote:

This project is not abandoned.

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

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

ZenLearner avatar Dec 05 '22 10:12 ZenLearner

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?

ebadi avatar Dec 06 '22 18:12 ebadi

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

oakmac avatar Dec 06 '22 18:12 oakmac

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

juangocc avatar Feb 02 '23 19:02 juangocc

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 avatar May 15 '23 02:05 BinaryInitials

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

BinaryInitials avatar May 15 '23 03:05 BinaryInitials