Skip to content

Commit

Permalink
Merge pull request #143 from guidobouman/develop
Browse files Browse the repository at this point in the history
Release 2019-07-03
  • Loading branch information
guidobouman authored Jul 4, 2019
2 parents 0b08823 + 9f15780 commit bbb7494
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/panelsnap.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 13 additions & 8 deletions src/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@ export function getScrollEventContainer(container) {
}

function getContainerRect(container) {
return container === document.body ? {
top: 0,
left: 0,
bottom: window.innerHeight,
right: window.innerWidth,
height: window.innerHeight,
width: window.innerWidth,
} : container.getBoundingClientRect();
if (container === document.body) {
const htmlElement = document.documentElement;
return {
top: 0,
left: 0,
bottom: htmlElement.clientHeight,
right: htmlElement.clientWidth,
height: htmlElement.clientHeight,
width: htmlElement.clientWidth,
};
}

return container.getBoundingClientRect();
}

export function getTargetScrollOffset(container, element, toBottom = false, toRight = false) {
Expand Down
4 changes: 2 additions & 2 deletions src/utilities.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
const SCREEN_WIDTH = 800;
const SCREEN_HEIGHT = 600;

window.innerWidth = SCREEN_WIDTH;
window.innerHeight = SCREEN_HEIGHT;
Object.defineProperty(document.documentElement, 'clientWidth', { value: SCREEN_WIDTH });
Object.defineProperty(document.documentElement, 'clientHeight', { value: SCREEN_HEIGHT });

describe('getScrolllingElement', () => {
test('returns same element when container is not body', () => {
Expand Down

0 comments on commit bbb7494

Please sign in to comment.