Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. const CustomEvent = (event, params) => {
  2. const evt = document.createEvent('CustomEvent');
  3.  
  4. params = params || {
  5. bubbles: false,
  6. cancelable: false
  7. };
  8.  
  9. evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
  10. return evt;
  11. };
  12.  
  13. if (typeof window.CustomEvent !== 'function') {
  14. CustomEvent.prototype = window.Event.prototype;
  15. window.CustomEvent = CustomEvent;
  16. }
  17.  
  18. window.triggerDTMEvent = eventName => {
  19. document.body.dispatchEvent(new window.CustomEvent(eventName));
  20. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement