chessboardjs icon indicating copy to clipboard operation
chessboardjs copied to clipboard

Touch devices dragging problem

Open marvinIsSacul opened this issue 7 years ago • 8 comments

Hi Mr Chris Oakman,

I have noticed that when chessboard.js is viewed and used on a touch screen device, piece dragging becomes a problem - it is quite annoying because as you'd try to drag a certain piece, the entire view gets dragged and scrolls. And as a result, the piece you want to move doesn't end up at another board rank/file.

As a work-around I did the following via jQuery

jQuery('#chess_board').on('scroll touchmove touchend touchstart contextmenu', function(e){
e.preventDefault();
});

marvinIsSacul avatar Oct 09 '18 13:10 marvinIsSacul

Hi marvinIsSacul, Where did you use the statement above? I'm pretty new to JS and JQuery and do not really know where should I place your code. Thanks, Jon.

jonsubs avatar Aug 02 '19 13:08 jonsubs

After initializing the chess board.

marvinIsSacul avatar Aug 02 '19 13:08 marvinIsSacul

Any updates on this bug? I've seen a couple of PRs for fixing it but no-one has looked at them and both now have conflicts against Master. We're moving to devices that have touch and are running into this issue so would be nice to fixed. Plus more and more devices are touch-enabled so would be a sensible feature to have.

psoleckimoj avatar Oct 02 '19 14:10 psoleckimoj

I agree chessboard.js needs better support for touch devices. It has been in the back of my mind to update; just has not been a priority lately ;)

oakmac avatar Oct 08 '19 03:10 oakmac

@marvinIsSacul thanks a lot, this solve the issue I was having.

dngo avatar Nov 25 '19 17:11 dngo

If nothing works, a temporary way of making it work is using on touchstart, make the piece have absolutely position, move it at touch position every touch move and finally, on touchend, run a for loop checking every square and then see if the piece overlaps any, and if more that one, which one the most. Whew!

s-mv avatar Apr 14 '20 15:04 s-mv

Is there a way to avoid having to drag pieces and instead just clicking on the squares?

PorroJoaquin avatar Aug 02 '20 02:08 PorroJoaquin