Skip to content

Handle some cases when dragging columns #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eclipsetrading/hypergrid",
"version": "4.0.0-alpha.4",
"version": "4.0.0-alpha.5",
"description": "Canvas-based high-performance grid",
"main": "src/Hypergrid",
"repository": {
Expand Down
13 changes: 10 additions & 3 deletions src/behaviors/Behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -1088,9 +1088,16 @@ var Behavior = Base.extend('Behavior', {
*/
swapColumns: function(source, target) {
var columns = this.columns;
var tmp = columns[source];
columns[source] = columns[target];
columns[target] = tmp;
var sourceColumn = columns[source];
if (sourceColumn === undefined) {
return;
}
var targetColumn = columns[target];
columns[source] = targetColumn;
if (sourceColumn === undefined) {
return;
}
columns[target] = sourceColumn;
this.changed();
},

Expand Down
5 changes: 3 additions & 2 deletions src/features/ColumnMoving.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ var ColumnMoving = Feature.extend('ColumnMoving', {
style.borderTop = '1px solid ' + grid.properties.lineColor;
style.backgroundColor = grid.properties.backgroundColor;

var startX = grid.renderer.visibleColumns[columnIndex - scrollLeft].left * hdpiRatio;
var foundCol = grid.renderer.visibleColumns[columnIndex - scrollLeft];
var startX = (foundCol ? foundCol.left : 0) * hdpiRatio;

floatColumnCTX.scale(hdpiRatio, hdpiRatio);

Expand Down Expand Up @@ -511,7 +512,7 @@ var ColumnMoving = Feature.extend('ColumnMoving', {
x = Math.max(minX - 15, x);

//am I at my lower bound
var atMin = x < minX && dragColumnIndex !== 0;
var atMin = x < minX; // && dragColumnIndex !== 0;

//am I at my upper bound
var atMax = x > maxX;
Expand Down