Skip to content

Commit 5967597

Browse files
committed
fix chessboard offset
1 parent 35bd806 commit 5967597

File tree

2 files changed

+57
-27
lines changed

2 files changed

+57
-27
lines changed

assets/js/modules/ground.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ function onresize() {
7474
function calculate_width() {
7575
let gc = document.getElementById("game_container");
7676
let gc_width = gc.offsetWidth;
77-
let width = gc_width - 7; // for the numbers on the side of the ground
78-
width -= width % 8; // fix chrome alignment errors; https://github.com/ornicar/lila/pull/3881
77+
let width = gc_width ;//- 7; // for the numbers on the side of the ground
78+
//width -= width % 8; // fix chrome alignment errors; https://github.com/ornicar/lila/pull/3881
79+
// shouldn't be neccessary any longer https://github.com/lichess-org/chessground/pull/191
7980
return width;
8081
}
8182

assets/static/css/chessground.css

Lines changed: 54 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,20 @@
1010
}
1111

1212
.cg-wrap {
13+
box-sizing: content-box;
1314
width: 320px;
1415
height: 320px;
1516
position: relative;
1617
display: block;
1718
}
1819

19-
cg-helper {
20-
position: absolute;
21-
width: 12.5%;
22-
padding-bottom: 12.5%;
23-
display: table; /* hack: round to full pixel size in chrome */
24-
bottom: 0;
25-
}
26-
2720
cg-container {
2821
position: absolute;
29-
width: 800%;
30-
height: 800%;
22+
width: 100%;
23+
height: 100%;
3124
display: block;
32-
bottom: 0;
25+
top: 0;
26+
box-sizing: content-box;
3327
}
3428

3529
cg-board {
@@ -38,12 +32,15 @@ cg-board {
3832
left: 0;
3933
width: 100%;
4034
height: 100%;
35+
box-sizing: content-box;
4136
-webkit-user-select: none;
4237
-moz-user-select: none;
4338
-ms-user-select: none;
4439
user-select: none;
4540
line-height: 0;
4641
background-size: cover;
42+
}
43+
.cg-wrap.manipulable cg-board {
4744
cursor: pointer;
4845
}
4946
cg-board square {
@@ -52,6 +49,7 @@ cg-board square {
5249
left: 0;
5350
width: 12.5%;
5451
height: 12.5%;
52+
box-sizing: content-box;
5553
pointer-events: none;
5654
}
5755
cg-board square.move-dest {
@@ -92,19 +90,20 @@ cg-board square.current-premove {
9290
left: 0;
9391
width: 12.5%;
9492
height: 12.5%;
93+
box-sizing: content-box;
9594
background-size: cover;
9695
z-index: 2;
9796
will-change: transform;
9897
pointer-events: none;
9998
}
10099
cg-board piece.dragging {
101100
cursor: move;
102-
z-index: 9;
101+
z-index: 11 !important;
103102
}
104-
cg-board piece.anim {
103+
piece.anim {
105104
z-index: 8;
106105
}
107-
cg-board piece.fading {
106+
piece.fading {
108107
z-index: 1;
109108
opacity: 0.5;
110109
}
@@ -114,40 +113,70 @@ cg-board piece.fading {
114113
.cg-wrap piece.ghost {
115114
opacity: 0.3;
116115
}
117-
.cg-wrap svg {
116+
.cg-wrap piece svg {
118117
overflow: hidden;
118+
position: relative;
119+
top: 0px;
120+
left: 0px;
121+
width: 100%;
122+
height: 100%;
123+
pointer-events: none;
124+
z-index: 2;
125+
opacity: 0.6;
126+
}
127+
.cg-wrap cg-auto-pieces,
128+
.cg-wrap .cg-shapes,
129+
.cg-wrap .cg-custom-svgs {
130+
overflow: visible;
119131
position: absolute;
120132
top: 0px;
121133
left: 0px;
122134
width: 100%;
123135
height: 100%;
124136
pointer-events: none;
137+
}
138+
.cg-wrap cg-auto-pieces {
125139
z-index: 2;
140+
}
141+
.cg-wrap cg-auto-pieces piece {
142+
opacity: 0.3;
143+
}
144+
.cg-wrap .cg-shapes {
145+
overflow: hidden;
126146
opacity: 0.6;
147+
z-index: 2;
127148
}
128-
.cg-wrap svg image {
129-
opacity: 0.5;
149+
.cg-wrap .cg-custom-svgs {
150+
z-index: 9;
151+
}
152+
.cg-wrap .cg-custom-svgs svg {
153+
overflow: visible;
130154
}
131155
.cg-wrap coords {
132156
position: absolute;
133157
display: flex;
134158
pointer-events: none;
135159
opacity: 0.8;
160+
font-family: sans-serif;
136161
font-size: 9px;
137162
}
138163
.cg-wrap coords.ranks {
139-
right: -15px;
140-
top: 0;
164+
left: 4px;
165+
top: -20px;
141166
flex-flow: column-reverse;
142167
height: 100%;
143168
width: 12px;
144169
}
145170
.cg-wrap coords.ranks.black {
146171
flex-flow: column;
147172
}
173+
.cg-wrap coords.ranks.left {
174+
left: -15px;
175+
align-items: flex-end;
176+
}
148177
.cg-wrap coords.files {
149-
bottom: -16px;
150-
left: 0;
178+
bottom: -4px;
179+
left: 24px;
151180
flex-flow: row;
152181
width: 100%;
153182
height: 16px;
@@ -171,16 +200,16 @@ cg-board piece.fading {
171200
* See https://github.com/ornicar/lila/blob/master/COPYING.md
172201
* License: AGPLv3+
173202
*/
174-
.blue .chessboard {
203+
.blue cg-board {
175204
background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgODAwIDgwMCI+CjxnIGlkPSJicm93bi1ib2FyZCI+CjxnIGlkPSJMaWdodCIgZmlsbD0iI2RlZTNlNiI+CjxyZWN0IHdpZHRoPSI4MDAiIGhlaWdodD0iODAwIi8+CjwvZz4KPGcgaWQ9IkZyYW1lIiBmaWxsPSJub25lIj4KPHJlY3Qgd2lkdGg9IjgwMCIgaGVpZ2h0PSI4MDAiLz4KPC9nPgo8ZyBpZD0iRGFyayIgZmlsbD0iIzhjYTJhZCI+CjxnIGlkPSJyYXoiPgo8ZyBpZD0iZHZhIj4KPGcgaWQ9InRyaSI+CjxyZWN0IHg9IjEwMCIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiLz4KPHJlY3QgeD0iMzAwIiB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIvPgo8cmVjdCB4PSI1MDAiIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIi8+CjxyZWN0IHg9IjcwMCIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiLz4KPC9nPgo8dXNlIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0xMDAsMTAwKSIgeGxpbms6aHJlZj0iI3RyaSIvPgo8L2c+Cjx1c2UgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMCwyMDApIiB4bGluazpocmVmPSIjZHZhIi8+CjwvZz4KPHVzZSB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwLDQwMCkiIHhsaW5rOmhyZWY9IiNyYXoiLz4KPC9nPgo8L2c+Cjwvc3ZnPg==');
176205
}
177-
.brown .chessboard {
206+
.brown cg-board {
178207
background-image: url('/images/boards/brown.svg');
179208
}
180-
.green .chessboard {
209+
.green cg-board {
181210
background-image: url('/images/boards/green.svg');
182211
}
183-
.ic .chessboard {
212+
.ic cg-board {
184213
background-image: url('/images/boards/ic.svg');
185214
}
186215

0 commit comments

Comments
 (0)