element-plus/packages/hooks/use-popper/use-popper-options.ts
jeremywu c28d7b3738
feat(hooks): redesign popper apis (#2529)
* feat(hooks): redesign popper apis

- Redesign use-popper APIs to make it more adaptable.

* - Reorganize the popper APIs
2021-07-15 14:08:13 +08:00

51 lines
839 B
TypeScript

import type { PropType } from 'vue'
import type { Options } from '@popperjs/core'
export const DEFAULT_FALLBACK_PLACEMENTS = []
export const defaultModifiers = [
{
name: 'offset',
options: {
offset: [0, 12],
},
},
{
name: 'preventOverflow',
options: {
padding: {
top: 2,
bottom: 2,
left: 5,
right: 5,
},
},
},
{
name: 'flip',
options: {
padding: 5,
fallbackPlacements: [],
},
},
{
name: 'computeStyles',
options: {
gpuAcceleration: true,
adaptive: true,
},
},
]
export const defaultPopperOptions = {
type: Object as PropType<Options>,
default: () => {
return {
fallbackPlacements: DEFAULT_FALLBACK_PLACEMENTS,
strategy: 'fixed',
modifiers: defaultModifiers,
}
},
}