You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
855 B

2 months ago
  1. // @flow
  2. import type { ModifierArguments, Modifier } from '../types';
  3. import computeOffsets from '../utils/computeOffsets';
  4. function popperOffsets({ state, name }: ModifierArguments<{||}>) {
  5. // Offsets are the actual position the popper needs to have to be
  6. // properly positioned near its reference element
  7. // This is the most basic placement, and will be adjusted by
  8. // the modifiers in the next step
  9. state.modifiersData[name] = computeOffsets({
  10. reference: state.rects.reference,
  11. element: state.rects.popper,
  12. strategy: 'absolute',
  13. placement: state.placement,
  14. });
  15. }
  16. // eslint-disable-next-line import/no-unused-modules
  17. export type PopperOffsetsModifier = Modifier<'popperOffsets', {||}>;
  18. export default ({
  19. name: 'popperOffsets',
  20. enabled: true,
  21. phase: 'read',
  22. fn: popperOffsets,
  23. data: {},
  24. }: PopperOffsetsModifier);