34 |
this.nodeClick(e)}>
35 | {(this.props.siteNavItem.svg && (
36 |
37 |
42 | {this.props.navIsOpened && (
43 |
44 |
45 | {this.props.siteNavItem.title}
46 |
47 | {(this.props.siteNavItem.subNavItems &&
48 | !this.state.isOpened && (
49 |
56 | )) ||
57 | (this.props.siteNavItem.subNavItems &&
58 | this.state.isOpened && (
59 |
66 | ))}
67 |
68 | )}
69 |
70 | )) ||
71 | (!this.props.siteNavItem.svg && (
72 |
73 |
74 |
75 | {this.props.siteNavItem.title}
76 |
77 |
78 |
79 | ))}
80 |
81 | {(this.props.siteNavItem.subNavItems &&
82 | !this.props.navIsOpened && (
83 |
84 | {this.props.siteNavItem.subNavItems.map(this.renderSubNavItems)}
85 |
86 | )) ||
87 | (this.props.siteNavItem.subNavItems &&
88 | this.props.navIsOpened &&
89 | this.state.isOpened && (
90 |
91 | {this.props.siteNavItem.subNavItems.map(this.renderSubNavItems)}
92 |
93 | ))}
94 |
95 | );
96 | }
97 |
98 | private check(): void {
99 | const node: Element = ReactDOM.findDOMNode(this.refs.children) as Element;
100 | if (!node) {
101 | return;
102 | }
103 |
104 | const rect: ClientRect = node.getBoundingClientRect();
105 | const space: number = window.innerHeight - (rect.top + rect.height);
106 | if (space < 0) {
107 | // it's off screen
108 | const heightStyle: string =
109 | "height: " + String(node.clientHeight + space) + "px;";
110 | const overflowStyle: string = "overflow-y: auto; -webkit-overflow-scrolling: touch;";
111 | node.setAttribute("style", heightStyle + overflowStyle);
112 | } else {
113 | node.setAttribute("style", "height: auto;");
114 | }
115 | }
116 |
117 | private nodeClick(e: React.MouseEvent