-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into sm-react-license-page
- Loading branch information
Showing
137 changed files
with
1,961 additions
and
1,230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
.../public/application/apps/main/components/doc_table/lib/should_load_next_doc_patch.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { shouldLoadNextDocPatch } from './should_load_next_doc_patch'; | ||
|
||
describe('shouldLoadNextDocPatch', () => { | ||
test('next patch should not be loaded', () => { | ||
const scrollingDomEl = { | ||
scrollHeight: 500, | ||
scrollTop: 100, | ||
clientHeight: 100, | ||
} as HTMLElement; | ||
|
||
expect(shouldLoadNextDocPatch(scrollingDomEl)).toBeFalsy(); | ||
}); | ||
|
||
test('next patch should be loaded', () => { | ||
const scrollingDomEl = { | ||
scrollHeight: 500, | ||
scrollTop: 350, | ||
clientHeight: 100, | ||
} as HTMLElement; | ||
|
||
expect(shouldLoadNextDocPatch(scrollingDomEl)).toBeTruthy(); | ||
}); | ||
|
||
test("next patch should be loaded even there's a decimal scroll height", () => { | ||
const scrollingDomEl = { | ||
scrollHeight: 500, | ||
scrollTop: 350.34234234, | ||
clientHeight: 100, | ||
} as HTMLElement; | ||
|
||
expect(shouldLoadNextDocPatch(scrollingDomEl)).toBeTruthy(); | ||
}); | ||
}); |
26 changes: 26 additions & 0 deletions
26
...cover/public/application/apps/main/components/doc_table/lib/should_load_next_doc_patch.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
// use a buffer to start rendering more documents before the user completely scrolles down | ||
const verticalScrollBuffer = 100; | ||
|
||
/** | ||
* Helper function to determine if the next patch of 50 documents should be loaded | ||
*/ | ||
export function shouldLoadNextDocPatch(domEl: HTMLElement) { | ||
// the height of the scrolling div, including content not visible on the screen due to overflow. | ||
const scrollHeight = domEl.scrollHeight; | ||
// the number of pixels that the div is is scrolled vertically | ||
const scrollTop = domEl.scrollTop; | ||
// the inner height of the scrolling div, excluding content that's visible on the screen | ||
const clientHeight = domEl.clientHeight; | ||
|
||
const consumedHeight = scrollTop + clientHeight; | ||
const remainingHeight = scrollHeight - consumedHeight; | ||
return remainingHeight < verticalScrollBuffer; | ||
} |
Oops, something went wrong.