stop the incoming call box from scrolling off the screen

This commit is contained in:
Matthew Hodgson 2015-12-17 14:56:09 +00:00
parent bb184c12a1
commit 5c999fe1ab

View file

@ -259,15 +259,24 @@ module.exports = React.createClass({
if (firstTime) { if (firstTime) {
// scroll to make sure the callbox is on the screen... // scroll to make sure the callbox is on the screen...
if (top < 10) { if (top < 10) { // 10px of vertical margin at top of screen
scroll.scrollTop = incomingCallBox.parentElement.offsetTop - 10; scroll.scrollTop = incomingCallBox.parentElement.offsetTop - 10;
} }
else if (top > scroll.clientHeight - incomingCallBox.offsetHeight) { else if (top > scroll.clientHeight - incomingCallBox.offsetHeight + 50) {
scroll.scrollTop = incomingCallBox.parentElement.offsetTop - scroll.offsetHeight + incomingCallBox.offsetHeight; scroll.scrollTop = incomingCallBox.parentElement.offsetTop - scroll.offsetHeight + incomingCallBox.offsetHeight - 50;
} }
// recalculate top in case we clipped it. // recalculate top in case we clipped it.
top = (scroll.offsetTop + incomingCallBox.parentElement.offsetTop - scroll.scrollTop); top = (scroll.offsetTop + incomingCallBox.parentElement.offsetTop - scroll.scrollTop);
} }
else {
// stop the box from scrolling off the screen
if (top < 10) {
top = 10;
}
else if (top > scroll.clientHeight - incomingCallBox.offsetHeight + 50) {
top = scroll.clientHeight - incomingCallBox.offsetHeight + 50;
}
}
incomingCallBox.style.top = top + "px"; incomingCallBox.style.top = top + "px";
incomingCallBox.style.left = scroll.offsetLeft + scroll.offsetWidth + "px"; incomingCallBox.style.left = scroll.offsetLeft + scroll.offsetWidth + "px";