|
156 | 156 | (did-mount [this]
|
157 | 157 | (let [node (om.core/get-node owner)
|
158 | 158 | align (or (:align opts) 0.5)
|
| 159 | + coordinates (om/get-state owner :coordinates) |
159 | 160 | parent (dommy/remove! node)
|
160 | 161 | target (if (:for opts)
|
161 | 162 | (or (sel1 (keyword (str "#" (:for opts)))) parent)
|
|
173 | 174 | (max o (- m))
|
174 | 175 | (min o m)))
|
175 | 176 | wz (window-size)
|
176 |
| - trect (first (client-rects target)) |
| 177 | + trect (if coordinates |
| 178 | + {:top (:y coordinates) |
| 179 | + :bottom (+ (:y coordinates) 1) |
| 180 | + :left (:x coordinates) |
| 181 | + :right (+ (:x coordinates) 1) |
| 182 | + :width 1 |
| 183 | + :height 1} |
| 184 | + (first (client-rects target))) |
177 | 185 | target-pos (merge trect
|
178 | 186 | {:top (+ (:top trect) (:scroll-y wz))
|
179 | 187 | :bottom (+ (:bottom trect) (:scroll-y wz))
|
|
255 | 263 | [_ owner opts]
|
256 | 264 | (reify
|
257 | 265 | om/IRenderState
|
258 |
| - (render-state [this {:keys [visible-content-fn popup-content-fn visible prefered-side channel] :as state}] |
| 266 | + (render-state [this {:keys [visible-content-fn popup-content-fn visible prefered-side channel coordinates] :as state}] |
259 | 267 | (html
|
260 | 268 | [:div {:class (:launcher-class-name opts)}
|
261 | 269 | (when visible
|
262 | 270 | (dom/div #js {:style #js {:position "absolute" :display "inline"}}
|
263 | 271 | (om/build popover-container nil {:init-state {:channel channel}
|
264 | 272 | :state {:content-fn popup-content-fn
|
265 |
| - :prefered-side prefered-side} |
| 273 | + :prefered-side prefered-side |
| 274 | + :coordinates coordinates} |
266 | 275 | :opts {:for (:for opts)
|
267 | 276 | :align (:align opts)
|
268 | 277 | :has-arrow (:has-arrow opts)
|
|
284 | 293 | {:visible false})
|
285 | 294 |
|
286 | 295 | om/IRenderState
|
287 |
| - (render-state [this {:keys [label id disabled class-name visible body prefered-side channel]}] |
| 296 | + (render-state [this {:keys [label id disabled class-name visible body prefered-side channel coordinates]}] |
288 | 297 | (html
|
289 | 298 | [:div {:class (:launcher-class-name opts)}
|
290 | 299 | [:a {:class class-name
|
|
297 | 306 | (when visible
|
298 | 307 | (om/build popover-container nil {:state {:content-fn body
|
299 | 308 | :prefered-side prefered-side
|
| 309 | + :coordinates coordinates |
300 | 310 | :channel channel}
|
301 | 311 | :opts {:align (:align opts)
|
302 | 312 | :has-arrow (:has-arrow opts)
|
|
327 | 337 | launcher-class-name
|
328 | 338 | channel
|
329 | 339 | align
|
330 |
| - visible] |
| 340 | + visible |
| 341 | + coordinates] |
331 | 342 | :or {class-name "om-widgets-popover-button"
|
332 | 343 | prefered-side :bottom
|
333 | 344 | popover-class ""
|
|
342 | 353 | :state {:visible-content-fn front-face
|
343 | 354 | :popup-content-fn popup-body
|
344 | 355 | :prefered-side prefered-side
|
345 |
| - :channel channel} |
| 356 | + :channel channel |
| 357 | + :coordinates coordinates} |
346 | 358 | :opts {:for for
|
347 | 359 | :has-arrow has-arrow
|
348 | 360 | :popover-class popover-class
|
|
356 | 368 | :class-name class-name
|
357 | 369 | :prefered-side prefered-side
|
358 | 370 | :body popup-body
|
359 |
| - :channel channel} |
| 371 | + :channel channel |
| 372 | + :coordinates coordinates} |
360 | 373 | :opts {:align align
|
361 | 374 | :popover-class popover-class
|
362 | 375 | :launcher-class-name launcher-class-name
|
|
0 commit comments