Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { getElement } from "@stencil/core";
- /**
- * Call this function as soon as the click outside of annotated method's host is done.
- * @example
- ```
- @ClickOutside()
- callback() {
- // this will run when click outside of element (host component) is done.
- }
- ```
- */
- export function ClickOutside() {
- return (proto: ComponentInstance, methodName: string) => {
- const { componentDidLoad } = proto;
- proto.componentDidLoad = function() {
- const host = getElement(this);
- const method = this[methodName];
- registerClickOutside(this, host, method);
- return componentDidLoad && componentDidLoad.call(this);
- };
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement