Skip to content

fix(scroll): Fix scroll-to-annotation behavior if page isn't rendered#495

Merged
jstoffan merged 1 commit intobox:masterfrom
jstoffan:fix-scroll-to
May 23, 2020
Merged

fix(scroll): Fix scroll-to-annotation behavior if page isn't rendered#495
jstoffan merged 1 commit intobox:masterfrom
jstoffan:fix-scroll-to

Conversation

@jstoffan
Copy link
Collaborator

@jstoffan jstoffan commented May 21, 2020

Todo

  • Cross-browser testing
  • Unit tests

@jstoffan jstoffan requested a review from a team as a code owner May 21, 2020 20:45
@jstoffan jstoffan marked this pull request as draft May 21, 2020 20:45
@mickr
Copy link
Collaborator

mickr commented May 22, 2020

This is looking great!

@jstoffan jstoffan marked this pull request as ready for review May 23, 2020 00:44

// Called by box-content-preview
init(scale: number): void {
public init(scale: number): void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to have a default value, like 1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, this is up to the Preview SDK to manage and is consistent with the prior versions of box-annotations.

Comment on lines +15 to +32
export const centerShape = (shape: Shape): Position => {
const { height, width } = shape;

return {
x: width / 2,
y: height / 2,
};
};

export const centerRegion = (shape: Shape): Position => {
const { x: shapeX, y: shapeY } = shape;
const { x: centerX, y: centerY } = centerShape(shape);

return {
x: centerX + shapeX,
y: centerY + shapeY,
};
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we combine these two functions into one? centerShape is only used once and its logic is pretty simple.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to disable prettier for a couple lines if I combine them due to poor parenthesis handling in Prettier@1.x.

return;
}

const canSmoothScroll = 'scrollBehavior' in this.annotatedEl.style;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable seems only used once.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but the variable name helps describe its purpose better than the code does, I think.

@jstoffan jstoffan merged commit f23d2ba into box:master May 23, 2020
@jstoffan jstoffan deleted the fix-scroll-to branch May 23, 2020 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants