Skip to content

Commit

Permalink
fix(inspector): tree horitonal scroll, related to #1126
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed May 24, 2021
1 parent ee6005c commit 51c7e74
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default defineComponent({
scrollIntoView(el, {
scrollMode: 'if-needed',
block: 'center',
inline: 'center',
inline: 'nearest',
behavior: 'smooth'
})
}
Expand All @@ -98,10 +98,10 @@ export default defineComponent({
</script>

<template>
<div>
<div class="min-w-max">
<div
ref="toggleEl"
class="font-mono cursor-pointer relative overflow-hidden z-10 rounded whitespace-nowrap flex items-center pr-2 text-sm selectable-item"
class="font-mono cursor-pointer relative z-10 rounded whitespace-nowrap flex items-center pr-2 text-sm selectable-item"
:class="{
selected,
'opacity-50': instance.inactive,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default defineComponent({
scrollIntoView(el, {
scrollMode: 'if-needed',
block: 'center',
inline: 'center',
inline: 'nearest',
behavior: 'smooth'
})
}
Expand All @@ -79,10 +79,10 @@ export default defineComponent({
</script>

<template>
<div>
<div class="min-w-max">
<div
ref="toggleEl"
class="font-mono cursor-pointer relative overflow-hidden z-10 rounded whitespace-nowrap flex items-center pr-2 text-sm selectable-item"
class="font-mono cursor-pointer relative z-10 rounded whitespace-nowrap flex items-center pr-2 text-sm selectable-item"
:class="{
selected
}"
Expand Down
16 changes: 0 additions & 16 deletions packages/shared-utils/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,22 +593,6 @@ export function has (object, path, parent = false) {
return object != null && Object.prototype.hasOwnProperty.call(object, sections[0])
}

export function scrollIntoView (scrollParent, el, center = true) {
const parentTop = scrollParent.scrollTop
const parentHeight = scrollParent.offsetHeight
const elBounds = el.getBoundingClientRect()
const parentBounds = scrollParent.getBoundingClientRect()
const top = elBounds.top - parentBounds.top + scrollParent.scrollTop
const height = el.offsetHeight
if (center) {
scrollParent.scrollTop = top + (height - parentHeight) / 2
} else if (top < parentTop) {
scrollParent.scrollTop = top
} else if (top + height > parentTop + parentHeight) {
scrollParent.scrollTop = top - parentHeight + height
}
}

export function focusInput (el) {
el.focus()
el.setSelectionRange(0, el.value.length)
Expand Down

0 comments on commit 51c7e74

Please sign in to comment.