events.ts 559 B

1234567891011121314151617181920212223
  1. // Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. import type { StopEventOptions } from '@shared/types/events'
  3. const stopEvent = (event: Event, stopOptions: StopEventOptions = {}): void => {
  4. const {
  5. preventDefault = true,
  6. propagation = true,
  7. immediatePropagation = false,
  8. }: StopEventOptions = stopOptions
  9. if (preventDefault) {
  10. event.preventDefault()
  11. }
  12. if (propagation) {
  13. event.stopPropagation()
  14. }
  15. if (immediatePropagation) {
  16. event.stopImmediatePropagation()
  17. }
  18. }
  19. export default stopEvent