Skip to content

Commit bfd0f78

Browse files
committed
- fix bug: selection out of range isn't rendered correctly if current view is closer to origin point.
- bump version
1 parent 657491e commit bfd0f78

File tree

8 files changed

+45
-31
lines changed

8 files changed

+45
-31
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Logs
22

3+
## v0.5.6
4+
5+
- fix bug: selection out of range isn't rendered correctly if current view is closer to origin point.
6+
7+
38
## v0.5.5
49

510
- support `menu.on` and `menu.off` event

dist/index.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@
10041004
var r, x, y, ref$, base;
10051005
opt == null && (opt = {});
10061006
r = opt.roughly;
1007-
if (opt.col != null) {
1007+
if (opt.col != null || opt.row != null) {
10081008
if (opt.col < this.frozen.col) {
10091009
x = opt.col;
10101010
} else if (opt.col - this.pos.col < this.frozen.col) {
@@ -1053,7 +1053,7 @@
10531053
: this._editing = !!v;
10541054
},
10551055
renderSelection: function(sel, o){
1056-
var ref$, sc, ec, sr, er, rbox, c0, c1, c2, c3, c4, b0, b1, b2, b3, b4, x1, y1, colOut, rowOut, x2, y2, w, h, snode, sbox, dom;
1056+
var ref$, sc, ec, sr, er, rbox, c0, c1, c2, c3, c4, c5, b0, b1, b2, b3, b4, b5, x1, y1, colOut, rowOut, x2, y2, w, h, snode, sbox, dom;
10571057
o == null && (o = {});
10581058
if (!sel) {
10591059
sel = this.les;
@@ -1092,25 +1092,29 @@
10921092
row: er,
10931093
roughly: true
10941094
});
1095-
ref$ = [c0, c1, c2, c3, c4].map(function(it){
1095+
c5 = this.cell({
1096+
col: this.pos.col + this.dim.col - 2,
1097+
row: this.pos.row + this.dim.row - 2
1098+
});
1099+
ref$ = [c0, c1, c2, c3, c4, c5].map(function(it){
10961100
if (it) {
10971101
return it.getBoundingClientRect();
10981102
} else {
10991103
return null;
11001104
}
1101-
}), b0 = ref$[0], b1 = ref$[1], b2 = ref$[2], b3 = ref$[3], b4 = ref$[4];
1105+
}), b0 = ref$[0], b1 = ref$[1], b2 = ref$[2], b3 = ref$[3], b4 = ref$[4], b5 = ref$[5];
11021106
b0.width = 0;
11031107
b0.height = 0;
1104-
x1 = (b1 || b2 || b0).x - rbox.x;
1105-
y1 = (b1 || b3 || b0).y - rbox.y;
1108+
x1 = (b1 || b2 || (sc > this.pos.col ? b5 : b0)).x - rbox.x;
1109+
y1 = (b1 || b3 || (sr > this.pos.row ? b5 : b0)).y - rbox.y;
11061110
colOut = ec - this.pos.col < 0;
11071111
rowOut = er - this.pos.row < 0;
1108-
x2 = (b3 || b4 || b0).x + (colOut
1112+
x2 = (b3 || b4 || b5 || b0).x + (colOut
11091113
? 0
1110-
: (b3 || b4 || b0).width) - rbox.x;
1111-
y2 = (b2 || b4 || b0).y + (rowOut
1114+
: (b3 || b4 || b5 || b0).width) - rbox.x;
1115+
y2 = (b2 || b4 || b5 || b0).y + (rowOut
11121116
? 0
1113-
: (b2 || b4 || b0).height) - rbox.y;
1117+
: (b2 || b4 || b5 || b0).height) - rbox.y;
11141118
w = x2 - x1 + 1;
11151119
h = y2 - y1 + 1;
11161120
if (ec == null) {

dist/index.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "@plotdb/sheet",
44
"license": "MIT",
55
"description": "spreadsheet",
6-
"version": "0.5.5",
6+
"version": "0.5.6",
77
"style": "dist/index.min.css",
88
"browser": "dist/index.min.js",
99
"main": "dist/index.min.js",

src/index.ls

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ sheet.prototype = Object.create(Object.prototype) <<< do
498498
499499
cell: (opt = {}) ->
500500
r = opt.roughly
501-
if opt.col? =>
501+
if opt.col? or opt.row? =>
502502
if opt.col < @frozen.col => x = opt.col
503503
else if opt.col - @pos.col < @frozen.col =>
504504
if r => x = @frozen.col else return null
@@ -534,14 +534,15 @@ sheet.prototype = Object.create(Object.prototype) <<< do
534534
c2 = @cell {col: sc, row: er, roughly: true}
535535
c3 = @cell {col: ec, row: sr, roughly: true}
536536
c4 = @cell {col: ec, row: er, roughly: true}
537-
[b0,b1,b2,b3,b4] = [c0,c1,c2,c3,c4].map -> if it => it.getBoundingClientRect! else null
537+
c5 = @cell {col: @pos.col + @dim.col - 2, row: @pos.row + @dim.row - 2}
538+
[b0,b1,b2,b3,b4,b5] = [c0,c1,c2,c3,c4,c5].map -> if it => it.getBoundingClientRect! else null
538539
b0 <<< {width: 0, height: 0}
539-
x1 = (b1 or b2 or b0).x - rbox.x
540-
y1 = (b1 or b3 or b0).y - rbox.y
540+
x1 = (b1 or b2 or (if sc > @pos.col => b5 else b0)).x - rbox.x
541+
y1 = (b1 or b3 or (if sr > @pos.row => b5 else b0)).y - rbox.y
541542
col-out = ec - @pos.col < 0
542543
row-out = er - @pos.row < 0
543-
x2 = (b3 or b4 or b0).x + (if col-out => 0 else (b3 or b4 or b0).width) - rbox.x
544-
y2 = (b2 or b4 or b0).y + (if row-out => 0 else (b2 or b4 or b0).height) - rbox.y
544+
x2 = (b3 or b4 or b5 or b0).x + (if col-out => 0 else (b3 or b4 or b5 or b0).width) - rbox.x
545+
y2 = (b2 or b4 or b5 or b0).y + (if row-out => 0 else (b2 or b4 or b5 or b0).height) - rbox.y
545546
w = x2 - x1 + 1
546547
h = y2 - y1 + 1
547548

web/static/assets/lib/@plotdb/sheet/dev/index.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@
10041004
var r, x, y, ref$, base;
10051005
opt == null && (opt = {});
10061006
r = opt.roughly;
1007-
if (opt.col != null) {
1007+
if (opt.col != null || opt.row != null) {
10081008
if (opt.col < this.frozen.col) {
10091009
x = opt.col;
10101010
} else if (opt.col - this.pos.col < this.frozen.col) {
@@ -1053,7 +1053,7 @@
10531053
: this._editing = !!v;
10541054
},
10551055
renderSelection: function(sel, o){
1056-
var ref$, sc, ec, sr, er, rbox, c0, c1, c2, c3, c4, b0, b1, b2, b3, b4, x1, y1, colOut, rowOut, x2, y2, w, h, snode, sbox, dom;
1056+
var ref$, sc, ec, sr, er, rbox, c0, c1, c2, c3, c4, c5, b0, b1, b2, b3, b4, b5, x1, y1, colOut, rowOut, x2, y2, w, h, snode, sbox, dom;
10571057
o == null && (o = {});
10581058
if (!sel) {
10591059
sel = this.les;
@@ -1092,25 +1092,29 @@
10921092
row: er,
10931093
roughly: true
10941094
});
1095-
ref$ = [c0, c1, c2, c3, c4].map(function(it){
1095+
c5 = this.cell({
1096+
col: this.pos.col + this.dim.col - 2,
1097+
row: this.pos.row + this.dim.row - 2
1098+
});
1099+
ref$ = [c0, c1, c2, c3, c4, c5].map(function(it){
10961100
if (it) {
10971101
return it.getBoundingClientRect();
10981102
} else {
10991103
return null;
11001104
}
1101-
}), b0 = ref$[0], b1 = ref$[1], b2 = ref$[2], b3 = ref$[3], b4 = ref$[4];
1105+
}), b0 = ref$[0], b1 = ref$[1], b2 = ref$[2], b3 = ref$[3], b4 = ref$[4], b5 = ref$[5];
11021106
b0.width = 0;
11031107
b0.height = 0;
1104-
x1 = (b1 || b2 || b0).x - rbox.x;
1105-
y1 = (b1 || b3 || b0).y - rbox.y;
1108+
x1 = (b1 || b2 || (sc > this.pos.col ? b5 : b0)).x - rbox.x;
1109+
y1 = (b1 || b3 || (sr > this.pos.row ? b5 : b0)).y - rbox.y;
11061110
colOut = ec - this.pos.col < 0;
11071111
rowOut = er - this.pos.row < 0;
1108-
x2 = (b3 || b4 || b0).x + (colOut
1112+
x2 = (b3 || b4 || b5 || b0).x + (colOut
11091113
? 0
1110-
: (b3 || b4 || b0).width) - rbox.x;
1111-
y2 = (b2 || b4 || b0).y + (rowOut
1114+
: (b3 || b4 || b5 || b0).width) - rbox.x;
1115+
y2 = (b2 || b4 || b5 || b0).y + (rowOut
11121116
? 0
1113-
: (b2 || b4 || b0).height) - rbox.y;
1117+
: (b2 || b4 || b5 || b0).height) - rbox.y;
11141118
w = x2 - x1 + 1;
11151119
h = y2 - y1 + 1;
11161120
if (ec == null) {

web/static/assets/lib/@plotdb/sheet/dev/index.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)