-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add useDraggable composable #4486
base: develop
Are you sure you want to change the base?
Conversation
👷 Deploy request for vuestic-docs pending review.Visit the deploys page to approve it
|
✅ Deploy Preview for vuestic-storybook ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
0d48bd9
to
270b5a0
Compare
@@ -38,6 +38,8 @@ const modalOptions: Record<keyof ModalOptions, string> = { | |||
overlay: "boolean", | |||
overlayOpacity: "number | string", | |||
zIndex: "number | string", | |||
draggable: "boolean", | |||
draggablePosition: "{ x?: number | string, y?: number | string }", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be better to set type like number | '${number}%'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move remainders in separate issue and merge this.
What I recall:
- Composable docs are missing.
- Touch events are not working.
- There is a bug with compiled docs attachEvent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move remainders in separate issue and merge this.
What I recall:
- Composable docs are missing.
- Touch events are not working.
- There is a bug with compiled docs attachEvent
- Interaction tests + check rotate font
@@ -422,12 +422,44 @@ watch(isTopLevelModal, newIsTopLevelModal => { | |||
} | |||
}, { immediate: true }) | |||
|
|||
const initialPosition = toRef(props, 'draggablePosition') | |||
|
|||
const containerRef = ref<HTMLElement | null>(null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const containerRef = ref<HTMLElement | null>(null) | |
const containerRef = useSelectorTemplateRef(toRef(props,'attachElement')) |
const { positionStyle, startDrag } = useDraggable({ | ||
draggableRef: modalDialog, | ||
containerRef, | ||
isDraggable: props.draggable, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isDraggable: props.draggable, | |
isDraggable: toRef(props, 'draggable'), |
stopDrag() | ||
}) | ||
|
||
watch(position, () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PositionStyle can be computed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VaModal vs VaDialog
Modal position is broken. Draggable must be applied to the dialog window, instead of overlay element.
The purpose of a modal window is to block the application until it is closed. Therefore, there is no reason for modal window to be draggable actually. Instead, we need a dialog window that wouldn't block the application and can be dragged over the page.
I'd not use a draggable prop in VaModal, but instead have it in the VaDialog component, which seems more reasonable. In such case, draggable dialog is more of a popup.
// TODO: add tests | ||
type PositionType = number | `${number}%` | ||
type initialPositionType = { x?: PositionType; y?: PositionType } | ||
export const DraggableAndAttachElement: StoryFn = () => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const DraggableAndAttachElement: StoryFn = () => ({ | |
export const DraggableAndAttachElement = defineStory({ |
- tests
useDraggable apiWould be also nice to have no-return api for useDraggable and expose it to end user. const dialogRef = ref()
const draggableArea = computed(() => dialogRef.value.querySelector('.va-dialog-header'))
useDraggable(dialogRef, {
draggableChild: draggableArea
}) <VaDialog ref="dialogRef" /> This way, useDraggable must apply position style to dialogRef. This can be considered as step 2 and is not required right now. |
Description
useDraggable
composableVaModal
useDraggable
Docs
forVaModal
VaModal
component with provide draggable logicTypes of changes