fix(scroll): Fix scroll-to-annotation behavior if page isn't rendered#495
fix(scroll): Fix scroll-to-annotation behavior if page isn't rendered#495jstoffan merged 1 commit intobox:masterfrom
Conversation
|
This is looking great! |
|
|
||
| // Called by box-content-preview | ||
| init(scale: number): void { | ||
| public init(scale: number): void { |
There was a problem hiding this comment.
Do we want to have a default value, like 1?
There was a problem hiding this comment.
Nope, this is up to the Preview SDK to manage and is consistent with the prior versions of box-annotations.
| 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, | ||
| }; | ||
| }; |
There was a problem hiding this comment.
Should we combine these two functions into one? centerShape is only used once and its logic is pretty simple.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
This variable seems only used once.
There was a problem hiding this comment.
Yeah, but the variable name helps describe its purpose better than the code does, I think.
Todo