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

Not working Clicked and drop? #175

Closed
KGPARMAR opened this issue Jul 26, 2019 · 4 comments
Closed

Not working Clicked and drop? #175

KGPARMAR opened this issue Jul 26, 2019 · 4 comments

Comments

@KGPARMAR
Copy link

I have play this example but here only working drag and drop but not working,
see example: https://play.google.com/store/apps/details?id=org.petero.droidfish
move like this

@theostavrides
Copy link

It would be really great if this was implemented. I see that someone made a pull request to integrate click moves but it wasn't working for me.

@vesper8
Copy link

vesper8 commented Feb 8, 2020

I forked the project and made click-and-drop work with 1.0 using as inspiration this PR: #138 by @PINO

It works really well and the modification was very simple. I want to create a PR but because this file https://github.com/oakmac/chessboardjs/blob/master/lib/chessboard.js has a "mixed line endings issue", as you can see from the warning if you try to edit it on Github. I cannot create a PR without causing the entire file to become one big diff. I reported this to Github so we'll see what they say. @oakmac please consider fixing the issue with the mixed line endings, and please consider adding the below modifications as a very simple click-to-move that doesn't break anything and still triggers the same checks as the normal drag-and-drop alternative

Anyway here are the modifications.. very simple stuff

replace

    var squareSize = 16

by

    var squareSize = 16
    var clickMove = false

replace

    function dropDraggedPieceOnSquare (square) {

      removeSquareHighlights()

by

    function dropDraggedPieceOnSquare (square) {

      // if destination is same as source, piece stays picked up and is dropped at the next clicked square.
      if (clickMove == false) {
        if (square === draggedPieceSource) {
          clickMove = true;
          return;
        }
      }

      clickMove = false;

      removeSquareHighlights()

replace

    function stopDraggedPiece (location) {
      // determine what the action should be
      var action = 'drop'

      if (location === 'offboard' && config.dropOffBoard === 'snapback') {
        action = 'snapback'
      }

by

    function stopDraggedPiece (location) {
      // determine what the action should be
      var action = 'drop'

      if (location === 'offboard' && config.dropOffBoard === 'snapback') {
        action = 'snapback'
        clickMove = false;
      } else {
        if (clickMove == false) {
          // pick up spare piece and put it down on next clicked square
          clickMove = true;
          return;
        } else {
          // drop piece back on its origin square
          clickMove = false;
        }
      }

and voila.. that's it.. works perfectly for me on 1.0

Just download the zip from the website and apply these modifications to the non-minified version

@larskuerten
Copy link

I follow the instructions, it works to move but not capturing.

@KGPARMAR
Copy link
Author

Thanks brother it's working find!

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

4 participants