experimental disjointed popups

This commit is contained in:
Henry Jameson 2022-05-20 00:56:23 +03:00
parent c83657a072
commit fd831a27f4
4 changed files with 26 additions and 14 deletions

View file

@ -54,6 +54,7 @@
<PostStatusModal /> <PostStatusModal />
<SettingsModal /> <SettingsModal />
<div id="modal" /> <div id="modal" />
<div id="popovers" />
<GlobalNoticeList /> <GlobalNoticeList />
</div> </div>
</template> </template>

View file

@ -43,6 +43,7 @@ const Popover = {
methods: { methods: {
containerBoundingClientRect () { containerBoundingClientRect () {
const container = this.boundToSelector ? this.$el.closest(this.boundToSelector) : this.$el.offsetParent const container = this.boundToSelector ? this.$el.closest(this.boundToSelector) : this.$el.offsetParent
console.log(container)
return container.getBoundingClientRect() return container.getBoundingClientRect()
}, },
updateStyles () { updateStyles () {
@ -125,10 +126,17 @@ const Popover = {
// Note, separate translateX and translateY avoids blurry text on chromium, // Note, separate translateX and translateY avoids blurry text on chromium,
// single translate or translate3d resulted in blurry text. // single translate or translate3d resulted in blurry text.
console.log(translateX + screenBox.x + screenBox.width)
console.log(Math.round(parentBounds.width))
this.styles = { this.styles = {
opacity: 1, opacity: 1,
transform: `translateX(${Math.round(translateX)}px) translateY(${Math.round(translateY)}px)` // transform: `translateX(${Math.round(translateX)}px) translateY(${Math.round(translateY)}px)`
left: `${Math.round(translateX + screenBox.x + screenBox.width / 2)}px`,
top: `${Math.round(translateY + screenBox.y + screenBox.height / 2)}px`,
maxWidth: `${Math.round(parentBounds.width)}px`,
position: 'fixed'
} }
console.log(this.styles)
}, },
showPopover () { showPopover () {
const wasHidden = this.hidden const wasHidden = this.hidden

View file

@ -11,19 +11,21 @@
> >
<slot name="trigger" /> <slot name="trigger" />
</button> </button>
<div <teleport to="#popovers">
v-if="!hidden" <div
ref="content" v-if="!hidden"
:style="styles" ref="content"
class="popover" :style="styles"
:class="popoverClass || 'popover-default'" class="popover"
> :class="popoverClass || 'popover-default'"
<slot >
name="content" <slot
class="popover-inner" name="content"
:close="hidePopover" class="popover-inner"
/> :close="hidePopover"
</div> />
</div>
</teleport>
</div> </div>
</template> </template>

View file

@ -6,6 +6,7 @@
:offset="{ y: 5 }" :offset="{ y: 5 }"
:bound-to="{ x: 'container' }" :bound-to="{ x: 'container' }"
remove-padding remove-padding
popover-class="ReactButton popover-default"
@show="focusInput" @show="focusInput"
> >
<template v-slot:content="{close}"> <template v-slot:content="{close}">