Cleanup + editor positioning fix
This commit is contained in:
parent
dfa396031e
commit
580ece0352
|
@ -182,7 +182,7 @@ export default class TextAnnotator extends Component {
|
|||
<Editor
|
||||
readOnly={this.props.readOnly}
|
||||
bounds={this.state.selectionBounds}
|
||||
containerEl={this.props.containerEl}
|
||||
wrapperEl={this.props.wrapperEl}
|
||||
annotation={this.state.selectedAnnotation}
|
||||
onAnnotationCreated={this.onCreateOrUpdateAnnotation('onAnnotationCreated')}
|
||||
onAnnotationUpdated={this.onCreateOrUpdateAnnotation('onAnnotationUpdated')}
|
||||
|
|
|
@ -21,7 +21,7 @@ const Editor = props => {
|
|||
setCurrentAnnotation(props.annotation);
|
||||
|
||||
if (element.current)
|
||||
setPosition(props.containerEl, element.current, props.bounds);
|
||||
setPosition(props.wrapperEl, element.current, props.bounds);
|
||||
}, [ props.annotation ]);
|
||||
|
||||
const onAppendBody = body => setCurrentAnnotation(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** Sets the editor position and determines a proper orientation **/
|
||||
const setPosition = (containerEl, editorEl, annotationBounds) => {
|
||||
const setPosition = (wrapperEl, editorEl, annotationBounds) => {
|
||||
// Container element offset
|
||||
const { offsetLeft, offsetTop } = containerEl;
|
||||
const { offsetLeft, offsetTop } = wrapperEl;
|
||||
const { scrollX, scrollY } = window;
|
||||
|
||||
// Re-set orientation class
|
||||
|
@ -20,10 +20,10 @@ const setPosition = (containerEl, editorEl, annotationBounds) => {
|
|||
editorEl.style.left = `${right - defaultOrientation.width + scrollX - offsetLeft}px`;
|
||||
}
|
||||
|
||||
if (defaultOrientation.bottom > window.innerHeight) {
|
||||
if (defaultOrientation.bottom > window.innerHeight - scrollY) {
|
||||
// Flip vertically
|
||||
const annotationTop = top + scrollY; // Annotation top relative to parents
|
||||
const containerBounds = containerEl.getBoundingClientRect();
|
||||
const containerBounds = wrapperEl.getBoundingClientRect();
|
||||
const containerHeight = containerBounds.height + containerBounds.top + scrollY;
|
||||
|
||||
editorEl.classList.add('align-bottom');
|
||||
|
|
Loading…
Reference in New Issue