From b256e1c8cec6192bedcc9ea47d906bc6f872ce12 Mon Sep 17 00:00:00 2001 From: jos Date: Thu, 5 Jan 2017 15:04:39 +0100 Subject: [PATCH] Better scrollTo offset --- src/components/TreeMode.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/TreeMode.js b/src/components/TreeMode.js index 60e2892..58f5425 100644 --- a/src/components/TreeMode.js +++ b/src/components/TreeMode.js @@ -397,9 +397,10 @@ export default class TreeMode extends Component { const name = compileJSONPointer(path) const container = this.refs.contents const elem = container.querySelector('div[name="' + name + '"]') + const offset = -(container.getBoundingClientRect().height / 4) if (elem) { - jump(elem, { container, offset: -100, duration: 400 }) + jump(elem, { container, offset, duration: 400 }) } }