chessboard-element
Advanced tools
Comparing version
{ | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
"typescript.tsdk": "node_modules/typescript/lib", | ||
"eslint.enable": false | ||
} |
import * as chessUtils from '../../lib/chess-utils.js'; | ||
import * as chessUtils from './chessboard-element.bundled.js'; | ||
export const EXAMPLES = {}; | ||
@@ -4,0 +4,0 @@ export default EXAMPLES; |
export * from './lib/chessboard-element.js'; | ||
export * from './lib/chess-utils.js'; | ||
//# sourceMappingURL=index.d.ts.map |
export * from './lib/chessboard-element.js'; | ||
export * from './lib/chess-utils.js'; | ||
//# sourceMappingURL=index.js.map |
@@ -86,2 +86,23 @@ /** | ||
}; | ||
this._touchmoveWindow = (e) => { | ||
var _a; | ||
// do nothing if we are not dragging a piece | ||
if (!(((_a = this._dragState) === null || _a === void 0 ? void 0 : _a.state) === 'dragging')) { | ||
return; | ||
} | ||
// prevent screen from scrolling | ||
e.preventDefault(); | ||
const touch = e.changedTouches[0]; | ||
this._updateDraggedPiece(touch.clientX, touch.clientY, touch.pageX, touch.pageY); | ||
}; | ||
this._touchendWindow = (e) => { | ||
var _a; | ||
// do nothing if we are not dragging a piece | ||
if (!(((_a = this._dragState) === null || _a === void 0 ? void 0 : _a.state) === 'dragging')) { | ||
return; | ||
} | ||
// get the location | ||
const location = this._isXYOnSquare(e.changedTouches[0].clientX, e.changedTouches[0].clientY); | ||
this._stopDraggedPiece(location); | ||
}; | ||
} | ||
@@ -288,3 +309,3 @@ /** | ||
id="${ifDefined(id)}" | ||
src="${ifDefined(src)}" | ||
src="${(src !== null && src !== void 0 ? src : '')}" | ||
part="piece ${(part !== null && part !== void 0 ? part : '')}" | ||
@@ -455,3 +476,2 @@ piece="${piece}" | ||
_touchstartSquare(e) { | ||
console.log('_touchstartSquare'); | ||
// do nothing if we're not draggable. sparePieces implies draggable | ||
@@ -470,6 +490,6 @@ if (!this.draggablePieces && !this.sparePieces) { | ||
} | ||
e.preventDefault(); | ||
this._beginDraggingPiece(square, this._currentPosition[square], e.changedTouches[0].pageX, e.changedTouches[0].pageY); | ||
} | ||
_touchstartSparePiece(e) { | ||
console.log('_touchstartSparePiece'); | ||
// do nothing if sparePieces is not enabled | ||
@@ -480,27 +500,5 @@ if (!this.sparePieces) | ||
const piece = pieceEl.getAttribute('piece'); | ||
e.preventDefault(); | ||
this._beginDraggingPiece('spare', piece, e.changedTouches[0].pageX, e.changedTouches[0].pageY); | ||
} | ||
_touchmoveWindow(e) { | ||
var _a, _b; | ||
console.log('_touchmoveWindow', (_a = this._dragState) === null || _a === void 0 ? void 0 : _a.state); | ||
// do nothing if we are not dragging a piece | ||
if (!(((_b = this._dragState) === null || _b === void 0 ? void 0 : _b.state) === 'dragging')) { | ||
return; | ||
} | ||
// prevent screen from scrolling | ||
e.preventDefault(); | ||
const touch = e.changedTouches[0]; | ||
this._updateDraggedPiece(touch.clientX, touch.clientY, touch.pageX, touch.pageY); | ||
} | ||
_touchendWindow(e) { | ||
var _a, _b; | ||
console.log('_touchendWindow', (_a = this._dragState) === null || _a === void 0 ? void 0 : _a.state); | ||
// do nothing if we are not dragging a piece | ||
if (!(((_b = this._dragState) === null || _b === void 0 ? void 0 : _b.state) === 'dragging')) { | ||
return; | ||
} | ||
// get the location | ||
const location = this._isXYOnSquare(e.changedTouches[0].pageX, e.changedTouches[0].pageY); | ||
this._stopDraggedPiece(location); | ||
} | ||
// ------------------------------------------------------------------------- | ||
@@ -581,4 +579,6 @@ // Public Methods | ||
window.addEventListener('mouseup', this._mouseupWindow); | ||
window.addEventListener('touchmove', this._touchmoveWindow); | ||
window.addEventListener('touchend', this._touchendWindow); | ||
window.addEventListener('touchmove', this._touchmoveWindow, { | ||
passive: false, | ||
}); | ||
window.addEventListener('touchend', this._touchendWindow, { passive: false }); | ||
} | ||
@@ -585,0 +585,0 @@ disconnectedCallback() { |
@@ -7,3 +7,3 @@ { | ||
"license": "MIT", | ||
"version": "1.0.0-pre.5", | ||
"version": "1.0.0-pre.6", | ||
"repository": { | ||
@@ -17,2 +17,3 @@ "type": "git", | ||
"devDependencies": { | ||
"@rollup/plugin-node-resolve": "^7.0.0", | ||
"@typescript-eslint/eslint-plugin": "^2.10.0", | ||
@@ -29,2 +30,6 @@ "@typescript-eslint/parser": "^2.10.0", | ||
"prettier": "^1.19.1", | ||
"rollup": "^1.29.0", | ||
"rollup-plugin-filesize": "^6.2.1", | ||
"rollup-plugin-minify-html-literals": "^1.2.2", | ||
"rollup-plugin-terser": "^5.1.3", | ||
"typescript": "^3.7.2", | ||
@@ -40,2 +45,3 @@ "uglify-js": "3.6.0", | ||
"lint": "eslint src/lib/*.ts", | ||
"bundle": "rollup -c", | ||
"docs": "node scripts/docs.js" | ||
@@ -42,0 +48,0 @@ }, |
export * from './lib/chessboard-element.js'; | ||
export * from './lib/chess-utils.js'; |
@@ -464,3 +464,3 @@ /** | ||
id="${ifDefined(id)}" | ||
src="${ifDefined(src)}" | ||
src="${src ?? ''}" | ||
part="piece ${part ?? ''}" | ||
@@ -690,3 +690,2 @@ piece="${piece}" | ||
private _touchstartSquare(e: TouchEvent) { | ||
console.log('_touchstartSquare'); | ||
// do nothing if we're not draggable. sparePieces implies draggable | ||
@@ -706,3 +705,3 @@ if (!this.draggablePieces && !this.sparePieces) { | ||
} | ||
e.preventDefault(); | ||
this._beginDraggingPiece( | ||
@@ -717,3 +716,2 @@ square, | ||
private _touchstartSparePiece(e: TouchEvent) { | ||
console.log('_touchstartSparePiece'); | ||
// do nothing if sparePieces is not enabled | ||
@@ -725,2 +723,3 @@ if (!this.sparePieces) return; | ||
e.preventDefault(); | ||
this._beginDraggingPiece( | ||
@@ -734,4 +733,3 @@ 'spare', | ||
private _touchmoveWindow(e: TouchEvent) { | ||
console.log('_touchmoveWindow', this._dragState?.state); | ||
private _touchmoveWindow = (e: TouchEvent) => { | ||
// do nothing if we are not dragging a piece | ||
@@ -751,6 +749,5 @@ if (!(this._dragState?.state === 'dragging')) { | ||
); | ||
} | ||
}; | ||
private _touchendWindow(e: TouchEvent) { | ||
console.log('_touchendWindow', this._dragState?.state); | ||
private _touchendWindow = (e: TouchEvent) => { | ||
// do nothing if we are not dragging a piece | ||
@@ -763,8 +760,8 @@ if (!(this._dragState?.state === 'dragging')) { | ||
const location = this._isXYOnSquare( | ||
e.changedTouches[0].pageX, | ||
e.changedTouches[0].pageY | ||
e.changedTouches[0].clientX, | ||
e.changedTouches[0].clientY | ||
); | ||
this._stopDraggedPiece(location); | ||
} | ||
}; | ||
@@ -871,4 +868,6 @@ // ------------------------------------------------------------------------- | ||
window.addEventListener('mouseup', this._mouseupWindow); | ||
window.addEventListener('touchmove', this._touchmoveWindow); | ||
window.addEventListener('touchend', this._touchendWindow); | ||
window.addEventListener('touchmove', this._touchmoveWindow, { | ||
passive: false, | ||
}); | ||
window.addEventListener('touchend', this._touchendWindow, {passive: false}); | ||
} | ||
@@ -875,0 +874,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
684417
24.73%164
30.16%5496
7.39%19
35.71%