mleibman / SlickGrid

A lightning fast JavaScript grid/spreadsheet
http://wiki.github.com/mleibman/SlickGrid
MIT License
6.81k stars 1.98k forks source link

What's leftPx/rightPx in the return object of slickgird.getViewport()? #1089

Closed royling closed 8 years ago

royling commented 8 years ago

I posted a question in google group - https://groups.google.com/forum/#!topic/slickgrid/8aRagN6TM9Y but don't know if the group is still active for discussion or not, so repost it here (sorry for that - I know it's not the right place for a question).

Can anyone help?

My original question: from the documentation - https://github.com/mleibman/SlickGrid/wiki/Slick.Grid#getViewport, it says grid.getViewport() returns an object with leftPx and rightPx properties, and they are:

the pixel offsets for left/right scrolling. { top: [rowIndex], bottom: [rowIndex], leftPx: [numPixels], rightPx: [numPixels] }

what's the meaning of left/right scrolling offset? Does it mean leftPx for vertical scrolling while rightPx for horizontal scrolling or the opposite?

I tried to log the result and compare them against the clientHeight/clientWidth of the canvas node element, it sounds so. Does anyone know about this or confirm if my guess is right?

Thanks!

6pac commented 8 years ago

Sorry for the silence. The real answer is: I don't know - I haven't delved into the rendering code of the grid for a while. But having a quick look over it, I'd say the rowIndex properties are fairly self explanatory, since the grid only displays whole rows. It appears to use the viewport element height to work out how many rows to display. The leftPx property is basically just the scrollLeft property of the viewport element and rightPx is leftPx plus the viewport width (including scroll bar, if present).

royling commented 8 years ago

@6pac thanks for answering, got the answer from the source - https://github.com/mleibman/SlickGrid/blob/2.1/slick.grid.js#L1665-L1666