🐛 Coordinate conversion is hard

This commit is contained in:
Antonio Scandurra
2015-12-02 16:26:10 +01:00
parent 5bcdcbeef6
commit e10fdc234b
3 changed files with 10 additions and 10 deletions

View File

@@ -97,7 +97,7 @@ describe("LineTopIndex", function () {
expect(lineTopIndex.rowForTopPixelPosition(0)).toBe(0)
expect(lineTopIndex.rowForTopPixelPosition(40)).toBe(4)
expect(lineTopIndex.rowForTopPixelPosition(44)).toBe(4)
expect(lineTopIndex.rowForTopPixelPosition(46)).toBe(5)
expect(lineTopIndex.rowForTopPixelPosition(46)).toBe(4)
expect(lineTopIndex.rowForTopPixelPosition(50)).toBe(5)
expect(lineTopIndex.rowForTopPixelPosition(120)).toBe(12)
expect(lineTopIndex.rowForTopPixelPosition(130)).toBe(12)
@@ -123,7 +123,7 @@ describe("LineTopIndex", function () {
expect(lineTopIndex.rowForTopPixelPosition(6)).toBe(0)
expect(lineTopIndex.rowForTopPixelPosition(10)).toBe(0)
expect(lineTopIndex.rowForTopPixelPosition(12)).toBe(0)
expect(lineTopIndex.rowForTopPixelPosition(17)).toBe(1)
expect(lineTopIndex.rowForTopPixelPosition(17)).toBe(0)
expect(lineTopIndex.rowForTopPixelPosition(20)).toBe(1)
expect(lineTopIndex.rowForTopPixelPosition(30)).toBe(2)
expect(lineTopIndex.rowForTopPixelPosition(40)).toBe(3)
@@ -131,10 +131,10 @@ describe("LineTopIndex", function () {
expect(lineTopIndex.rowForTopPixelPosition(80)).toBe(5)
expect(lineTopIndex.rowForTopPixelPosition(90)).toBe(5)
expect(lineTopIndex.rowForTopPixelPosition(95)).toBe(5)
expect(lineTopIndex.rowForTopPixelPosition(105)).toBe(6)
expect(lineTopIndex.rowForTopPixelPosition(106)).toBe(5)
expect(lineTopIndex.rowForTopPixelPosition(110)).toBe(6)
expect(lineTopIndex.rowForTopPixelPosition(160)).toBe(11)
expect(lineTopIndex.rowForTopPixelPosition(166)).toBe(12)
expect(lineTopIndex.rowForTopPixelPosition(166)).toBe(11)
expect(lineTopIndex.rowForTopPixelPosition(170)).toBe(12)
expect(lineTopIndex.rowForTopPixelPosition(240)).toBe(12)

View File

@@ -191,17 +191,17 @@ describe "TextEditorPresenter", ->
expect(stateFn(presenter).tiles[6].top).toBe((20 + 40) + (20 + 30) + 20 + 1)
expect(stateFn(presenter).tiles[8]).toBeUndefined()
presenter.setScrollTop(22)
presenter.setScrollTop(21)
expect(stateFn(presenter).tiles[0]).toBeUndefined()
expect(stateFn(presenter).tiles[2].height).toBe(20 + 30)
expect(stateFn(presenter).tiles[2].top).toBe(-1)
expect(stateFn(presenter).tiles[2].top).toBe(0)
expect(stateFn(presenter).tiles[4].height).toBe(20 + 40)
expect(stateFn(presenter).tiles[4].top).toBe(30 + 20 - 1)
expect(stateFn(presenter).tiles[4].top).toBe(30 + 20)
expect(stateFn(presenter).tiles[6].height).toBe(20)
expect(stateFn(presenter).tiles[6].top).toBe((20 + 40) + (20 + 30) - 1)
expect(stateFn(presenter).tiles[6].top).toBe((20 + 40) + (20 + 30))
expect(stateFn(presenter).tiles[8].height).toBe(20)
expect(stateFn(presenter).tiles[8].top).toBe((20 + 40) + (20 + 30) + 20 - 1)
expect(stateFn(presenter).tiles[8].top).toBe((20 + 40) + (20 + 30) + 20)
expect(stateFn(presenter).tiles[10]).toBeUndefined()
it "includes state for all tiles if no external ::explicitHeight is assigned", ->

View File

@@ -84,7 +84,7 @@ class LineTopIndex {
let nextBlocksHeight = blocksHeight + block.height
let linesHeight = block.row * this.defaultLineHeight
if (nextBlocksHeight + linesHeight > top) {
while (lastRow < block.row && lastTop + this.defaultLineHeight < top) {
while (lastRow < block.row && lastTop + this.defaultLineHeight <= top) {
lastTop += this.defaultLineHeight
lastRow++
}