Skip to content

Commit

Permalink
update scroll-into-view-if-needed and do not scroll body (#2804) (#2805)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-wer authored Jun 27, 2018
1 parent f844866 commit e9449e7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import * as React from "react";
import { scrollIntoViewIfNeeded } from "scroll-into-view-if-needed";
import scrollIntoViewIfNeeded from "scroll-into-view-if-needed";
import classNames from "classnames";
import Store from "oxalis/store";
import { setActiveNodeAction } from "oxalis/model/actions/skeletontracing_actions";
Expand All @@ -25,7 +25,11 @@ class Comment extends React.PureComponent<Props> {
ensureVisible() {
if (this.props.isActive) {
// use polyfill as so far only chrome supports this functionality
scrollIntoViewIfNeeded(this.comment, { centerIfNeeded: true });
scrollIntoViewIfNeeded(this.comment, {
block: "center",
scrollMode: "if-needed",
boundary: document.body,
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import classNames from "classnames";
import Comment from "oxalis/view/right-menu/comment_tab/comment";
import Utils from "libs/utils";
import { enforceSkeletonTracing } from "oxalis/model/accessors/skeletontracing_accessor";
import { scrollIntoViewIfNeeded } from "scroll-into-view-if-needed";
import scrollIntoViewIfNeeded from "scroll-into-view-if-needed";
import type { OxalisState, TreeType, SkeletonTracingType, CommentType } from "oxalis/store";

type OwnProps = {
Expand Down Expand Up @@ -47,7 +47,11 @@ class TreeCommentList extends React.PureComponent<TreeCommentListProps, State> {
this.props.tree.treeId === this.props.skeletonTracing.activeTreeId &&
!this.activeNodeHasComment()
) {
scrollIntoViewIfNeeded(this.treeDomElement, { centerIfNeeded: true });
scrollIntoViewIfNeeded(this.treeDomElement, {
block: "center",
scrollMode: "if-needed",
boundary: document.body,
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"react-virtualized": "^9.18.5",
"redux": "^3.6.0",
"redux-saga": "^0.14.3",
"scroll-into-view-if-needed": "1.4.1",
"scroll-into-view-if-needed": "2.2.8",
"shelljs": "^0.8.2",
"stats.js": "^1.0.0",
"three": "^0.87.0",
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9069,9 +9069,9 @@ scoped-regex@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/scoped-regex/-/scoped-regex-1.0.0.tgz#a346bb1acd4207ae70bd7c0c7ca9e566b6baddb8"

scroll-into-view-if-needed@1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/scroll-into-view-if-needed/-/scroll-into-view-if-needed-1.4.1.tgz#763580091fb8e0bd4dc2d68b475d755f66574a0e"
scroll-into-view-if-needed@2.2.8:
version "2.2.8"
resolved "https://registry.yarnpkg.com/scroll-into-view-if-needed/-/scroll-into-view-if-needed-2.2.8.tgz#c22ffbddce5c8a31949ab3e01c27a6c29ba7b979"

semver-compare@^1.0.0:
version "1.0.0"
Expand Down

0 comments on commit e9449e7

Please sign in to comment.