Skip to content

Commit

Permalink
je scrollbars
Browse files Browse the repository at this point in the history
  • Loading branch information
stevewirts committed Oct 20, 2015
1 parent 7881a95 commit 61948bd
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 58 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/build
/deploy
/bower_components
/docs
src/scripts/templates.js
node_modules
.DS_Store
112 changes: 60 additions & 52 deletions examples/bclys/fin-hypergrid.dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -13905,7 +13905,7 @@
isRightClick: this.isRightClick(e)
}
}));
console.log('dblclick', this.currentKeys);
//console.log('dblclick', this.currentKeys);
},

getCharMap: function() {
Expand Down Expand Up @@ -15002,7 +15002,6 @@
};

Polymer('fin-hypergrid-renderer',{ /* jslint ignore:line */

//the shared single item "pooled" cell object for drawing each cell
cell: {
x: 0,
Expand All @@ -15011,6 +15010,8 @@
height: 0
},

scrollHeight: 0,
viewHeight: 0,
/**
* @function
* @instance
Expand Down Expand Up @@ -15066,6 +15067,7 @@

this.columnEdges[0] = 0;
this.rowEdges[0] = 0;
this.scrollHeight = 0;

this.visibleColumns.length = 0;
this.visibleRows.length = 0;
Expand Down Expand Up @@ -15126,6 +15128,7 @@
this.visibleRows[r] = vy;
this.rowEdgesIndexMap[vy] = r;
}
this.viewHeight = viewHeight;
this.dataWindow = grid.rectangles.rectangle.create(firstVX, firstVY, lastVX - firstVX, lastVY - firstVY);
},

Expand Down Expand Up @@ -15193,6 +15196,13 @@
return this.visibleRows.length - 1;
},

getVisibleScrollHeight: function() {
var grid = this.getGrid();
var frh = grid.getFixedRowsHeight();
var height = this.viewHeight - frh;
return height;
},

/**
* @function
* @instance
Expand Down Expand Up @@ -15901,22 +15911,29 @@
* #### returns: integer
*/
getPageUpRow: function() {
if (this.rowEdges.length === 0) {
return;
}
var behavior = this.getBehavior();
var h = this.renderedHeight;
var topRow = this.visibleRows[0];
while (h > 0 && topRow >= 1) {
topRow--;
var eachHeight = behavior.getRowHeight(topRow);
h = h - eachHeight;
}
if (topRow === 0) {
return 0;
var scrollHeight = this.getVisibleScrollHeight();
var headerRows = this.getGrid().getFixedRowCount();
var top = this.dataWindow.origin.y - headerRows;
var scanHeight = 0;
while (scanHeight < scrollHeight && top > -1) {
scanHeight = scanHeight + behavior.getRowHeight(top);
top--;
}
return topRow + 1;
return top + 1;
},

/**
* @function
* @instance
* @description
answer the row to goto for a page down
* #### returns: integer
*/
getPageDownRow: function() {
var headerRows = this.getGrid().getFixedRowCount();
var rowNum = this.dataWindow.corner.y - headerRows - 1;
return rowNum;
},

/**
Expand All @@ -15943,21 +15960,6 @@
return this.getGrid().getRowCount();
},

/**
* @function
* @instance
* @description
answer the row to goto for a page down
* #### returns: integer
*/
getPageDownRow: function() {
if (this.rowEdges.length === 0) {
return;
}
var row = this.visibleRows[this.visibleRows.length - 1] + 1;
return row;
},

/**
* @function
* @instance
Expand Down Expand Up @@ -35677,7 +35679,7 @@
* @param {integer} offsetY - scroll in the y direction this much
*/
scrollVBy: function(offsetY) {
var max = this.sbVScrollConfig.rangeStop;
var max = this.sbVScroller.range.max;
var oldValue = this.getVScrollValue();
var newValue = Math.min(max, Math.max(0, oldValue + offsetY));
if (newValue === oldValue) {
Expand All @@ -35695,7 +35697,7 @@
* @param {integer} offsetX - scroll in the x direction this much
*/
scrollHBy: function(offsetX) {
var max = this.sbHScrollConfig.rangeStop;
var max = this.sbHScroller.range.max;
var oldValue = this.getHScrollValue();
var newValue = Math.min(max, Math.max(0, oldValue + offsetX));
if (newValue === oldValue) {
Expand Down Expand Up @@ -36169,7 +36171,8 @@
* @param {integer} newValue - the new value
*/
setVScrollValue: function(y) {
var max = this.sbVScrollConfig.rangeStop;
y = Math.round(y);
var max = this.sbVScroller.range.max;
y = Math.min(max, Math.max(0, y));
var self = this;
if (y === this.vScrollValue) {
Expand Down Expand Up @@ -36206,7 +36209,8 @@
* @param {integer} newValue - the new value
*/
setHScrollValue: function(x) {
var max = this.sbHScrollConfig.rangeStop;
x = Math.round(x);
var max = this.sbHScroller.range.max;
x = Math.min(max, Math.max(0, x));
var self = this;
if (x === this.hScrollValue) {
Expand Down Expand Up @@ -36298,7 +36302,8 @@
onchange: function(idx) {
self.setHScrollValue(idx);
},
cssStylesheetReferenceElement: scrollbarHolder
cssStylesheetReferenceElement: scrollbarHolder,
content: this.canvas
});

var vertBar = new FinBar({
Expand All @@ -36308,7 +36313,16 @@
},
onchange: function(idx) {
self.setVScrollValue(idx);
}
},
paging: {
up: function() {
return self.pageUp();
},
down: function() {
return self.pageDown();
},
},
content: this.canvas
});

this.sbHScroller = horzBar;
Expand All @@ -36330,28 +36344,20 @@
*/
setVScrollbarValues: function(max) {
var self = this;
max++;
this.sbVScroller.range = {
min: 0,
max: max
};
this.sbVScroller.index = Math.min(this.sbVScroller.index, max);
// setTimeout(function() {
// self.sbVScroller.resize();
// }, 100);
},

setHScrollbarValues: function(max) {
var self = this;
max++;
this.sbHScroller.range = {
min: 0,
max: max
};
this.sbHScroller.index = Math.min(this.sbHScroller.index, max);
// setTimeout(function() {
// self.sbHScroller.resize();
// }, 100);
},

scrollValueChangedNotification: function() {

if (this.hScrollValue === this.sbPrevHScrollValue && this.vScrollValue === this.sbPrevVScrollValue) {
Expand Down Expand Up @@ -36448,14 +36454,14 @@
}
}

this.sbHScrollConfig.rangeStop = Math.max(0, numColumns - numFixedColumns - lastPageColumnCount);
this.setHScrollbarValues(this.sbHScrollConfig.rangeStop);
var hMax = Math.max(0, numColumns - numFixedColumns - lastPageColumnCount);
this.setHScrollbarValues(hMax);

this.sbVScrollConfig.rangeStop = Math.max(0, numRows - numFixedRows - lastPageRowCount);
this.setVScrollbarValues(this.sbVScrollConfig.rangeStop);
var vMax = Math.max(0, numRows - numFixedRows - lastPageRowCount);
this.setVScrollbarValues(vMax);

this.setVScrollValue(Math.min(this.getVScrollValue(), this.sbVScrollConfig.rangeStop));
this.setHScrollValue(Math.min(this.getHScrollValue(), this.sbHScrollConfig.rangeStop));
this.setHScrollValue(Math.min(this.getHScrollValue(), hMax));
this.setVScrollValue(Math.min(this.getVScrollValue(), vMax));

this.computeCellsBounds();
this.repaint();
Expand Down Expand Up @@ -36875,6 +36881,7 @@
pageUp: function() {
var rowNum = this.getRenderer().getPageUpRow();
this.setVScrollValue(rowNum);
return rowNum;
},

/**
Expand All @@ -36888,6 +36895,7 @@
pageDown: function() {
var rowNum = this.getRenderer().getPageDownRow();
this.setVScrollValue(rowNum);
return rowNum;
},

/**
Expand Down
8 changes: 4 additions & 4 deletions examples/bclys/fin-hypergrid.min.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion fin-hypergrid.dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -13890,7 +13890,7 @@
isRightClick: this.isRightClick(e)
}
}));
console.log('dblclick', this.currentKeys);
//console.log('dblclick', this.currentKeys);
},

getCharMap: function() {
Expand Down
2 changes: 1 addition & 1 deletion fin-hypergrid.min.html

Large diffs are not rendered by default.

0 comments on commit 61948bd

Please sign in to comment.