X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FBoard.vue;h=b7b7f11053558ba68f36d79f3e060f43f45a5837;hb=2d4ec1779f50f6a479276edc9297b4323e0d42bb;hp=818b2a3f834985b0a2737eaa4d8c4f7f95b342ff;hpb=0a6fbd3d0effcb12294dc2ba8f356a820c91b2ad;p=vchess.git diff --git a/client/src/components/Board.vue b/client/src/components/Board.vue index 818b2a3f..b7b7f110 100644 --- a/client/src/components/Board.vue +++ b/client/src/components/Board.vue @@ -43,46 +43,6 @@ export default { const offset = (!!boardElt ? [boardElt.offsetTop, boardElt.offsetLeft] : [0, 0]); - const choices = h( - 'div', - { - attrs: { "id": "choices" }, - 'class': { 'row': true }, - style: { - "display": (this.choices.length > 0 ? "block" : "none"), - "top": (offset[0] + (sizeY/2)*squareWidth-squareWidth/2) + "px", - "left": (offset[1] + squareWidth*(sizeY - this.choices.length)/2) + "px", - "width": (this.choices.length * squareWidth) + "px", - "height": squareWidth + "px", - }, - }, - this.choices.map(m => { //a "choice" is a move - return h('div', - { - 'class': { - 'board': true, - ['board'+sizeY]: true, - }, - style: { - 'width': (100/this.choices.length) + "%", - 'padding-bottom': (100/this.choices.length) + "%", - }, - }, - [h('img', - { - attrs: { "src": '/images/pieces/' + - V.getPpath(m.appear[0].c+m.appear[0].p) + '.svg' }, - 'class': { 'choice-piece': true }, - on: { - "click": e => { this.play(m); this.choices=[]; }, - // NOTE: add 'touchstart' event to fix a problem on smartphones - //"touchstart": e => { this.play(m); this.choices=[]; }, - }, - }) - ] - ); - }) - ); // Create board element (+ reserves if needed by variant or mode) const lm = this.lastMove; const showLight = this.settings.highlight && this.vname != "Dark"; @@ -170,7 +130,48 @@ export default { }) ); const playingColor = this.userColor || "w"; //default for an observer - let elementArray = [choices, gameDiv]; + let elementArray = [gameDiv]; + if (this.choices.length > 0) + { + const choices = h( + 'div', + { + attrs: { "id": "choices" }, + 'class': { 'row': true }, + style: { + "top": (offset[0] + (sizeY/2)*squareWidth-squareWidth/2) + "px", + "left": (offset[1] + squareWidth*(sizeY - this.choices.length)/2) + "px", + "width": (this.choices.length * squareWidth) + "px", + "height": squareWidth + "px", + }, + }, + this.choices.map(m => { //a "choice" is a move + return h('div', + { + 'class': { + 'board': true, + ['board'+sizeY]: true, + }, + style: { + 'width': (100/this.choices.length) + "%", + 'padding-bottom': (100/this.choices.length) + "%", + }, + }, + [h('img', + { + attrs: { "src": '/images/pieces/' + + V.getPpath(m.appear[0].c+m.appear[0].p) + '.svg' }, + 'class': { 'choice-piece': true }, + on: { + "click": e => { this.play(m); this.choices=[]; }, + }, + }) + ] + ); + }) + ); + elementArray.unshift(choices); + } if (!!this.vr.reserve) { const shiftIdx = (playingColor=="w" ? 0 : 1); @@ -246,19 +247,31 @@ export default { ); elementArray.push(reserves); } - return h( - 'div', - { - // NOTE: click = mousedown + mouseup + let onEvents = {}; + // NOTE: click = mousedown + mouseup + if ('ontouchstart' in window) + { + onEvents = { + on: { + touchstart: this.mousedown, + touchmove: this.mousemove, + touchend: this.mouseup, + }, + }; + } + else + { + onEvents = { on: { mousedown: this.mousedown, mousemove: this.mousemove, mouseup: this.mouseup, - //touchstart: this.mousedown, - //touchmove: this.mousemove, - //touchend: this.mouseup, }, - }, + }; + } + return h( + 'div', + onEvents, elementArray ); },