File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 21
21
<script >
22
22
import widget from ' ../plugins/widget'
23
23
import { move } from ' ../mixins'
24
- import { cumulativeOffset } from ' ../utils/offset'
24
+ import { cumulativeOffset , checkInView } from ' ../utils/offset'
25
25
26
26
export default {
27
27
mixins: [move],
@@ -58,7 +58,7 @@ export default {
58
58
})
59
59
let viewport = document .querySelector (' #viewport' )
60
60
let target = viewport .querySelector (` [data-uuid='${ item .uuid } ']` )
61
- if (target) {
61
+ if (target && ! checkInView (target) ) {
62
62
viewport .scrollTop = (cumulativeOffset (target).top - 50 ) * this .zoom / 100
63
63
}
64
64
}
Original file line number Diff line number Diff line change @@ -13,3 +13,12 @@ export function cumulativeOffset (element) {
13
13
left : left
14
14
}
15
15
}
16
+
17
+ export function checkInView ( el ) {
18
+ let rect = el . getBoundingClientRect ( )
19
+ return (
20
+ rect . top < window . innerHeight &&
21
+ ( rect . left < window . innerWidth &&
22
+ rect . right > 0 )
23
+ )
24
+ }
You can’t perform that action at this time.
0 commit comments