Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. import { getElement } from "@stencil/core";
  2.  
  3. /**
  4. * Call this function as soon as the click outside of annotated method's host is done.
  5. * @example
  6. ```
  7. @ClickOutside()
  8. callback() {
  9. // this will run when click outside of element (host component) is done.
  10. }
  11. ```
  12. */
  13. export function ClickOutside() {
  14. return (proto: ComponentInstance, methodName: string) => {
  15. const { componentDidLoad } = proto;
  16. proto.componentDidLoad = function() {
  17. const host = getElement(this);
  18. const method = this[methodName];
  19. registerClickOutside(this, host, method);
  20. return componentDidLoad && componentDidLoad.call(this);
  21. };
  22. };
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement