@@ -20,7 +20,7 @@ import {
2020 addUnit ,
2121 closest ,
2222 createNamespace ,
23- makeNumberProp ,
23+ isObject ,
2424 makeStringProp ,
2525 windowWidth ,
2626 windowHeight ,
@@ -38,11 +38,15 @@ import {
3838 FloatingBubbleAxis ,
3939 FloatingBubbleMagnetic ,
4040 FloatingBubbleOffset ,
41+ FloatingBubbleGap ,
4142 FloatingBubbleBoundary ,
4243} from './types' ;
4344
4445export const floatingBubbleProps = {
45- gap : makeNumberProp ( 24 ) ,
46+ gap : {
47+ type : [ Number , Object ] as unknown as PropType < FloatingBubbleGap > ,
48+ default : 24 ,
49+ } ,
4650 icon : String ,
4751 axis : makeStringProp < FloatingBubbleAxis > ( 'y' ) ,
4852 magnetic : String as PropType < FloatingBubbleMagnetic > ,
@@ -79,11 +83,17 @@ export default defineComponent({
7983 height : 0 ,
8084 } ) ;
8185
86+ const gapX = computed ( ( ) =>
87+ isObject ( props . gap ) ? props . gap . x : props . gap ,
88+ ) ;
89+ const gapY = computed ( ( ) =>
90+ isObject ( props . gap ) ? props . gap . y : props . gap ,
91+ ) ;
8292 const boundary = computed < FloatingBubbleBoundary > ( ( ) => ( {
83- top : props . gap ,
84- right : windowWidth . value - state . value . width - props . gap ,
85- bottom : windowHeight . value - state . value . height - props . gap ,
86- left : props . gap ,
93+ top : gapY . value ,
94+ right : windowWidth . value - state . value . width - gapX . value ,
95+ bottom : windowHeight . value - state . value . height - gapY . value ,
96+ left : gapX . value ,
8797 } ) ) ;
8898
8999 const dragging = ref ( false ) ;
@@ -110,8 +120,8 @@ export default defineComponent({
110120 const { width, height } = useRect ( rootRef . value ! ) ;
111121 const { offset } = props ;
112122 state . value = {
113- x : offset . x > - 1 ? offset . x : windowWidth . value - width - props . gap ,
114- y : offset . y > - 1 ? offset . y : windowHeight . value - height - props . gap ,
123+ x : offset . x > - 1 ? offset . x : windowWidth . value - width - gapX . value ,
124+ y : offset . y > - 1 ? offset . y : windowHeight . value - height - gapY . value ,
115125 width,
116126 height,
117127 } ;
@@ -203,7 +213,7 @@ export default defineComponent({
203213 } ) ;
204214
205215 watch (
206- [ windowWidth , windowHeight , ( ) => props . gap , ( ) => props . offset ] ,
216+ [ windowWidth , windowHeight , gapX , gapY , ( ) => props . offset ] ,
207217 updateState ,
208218 { deep : true } ,
209219 ) ;
0 commit comments