Skip to content

Commit 167b03c

Browse files
committed
Popover supports specific coordinates for positioning. Bumped version to 0.3.29
1 parent b1eec3b commit 167b03c

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

‎project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject org.clojars.intception/om-widgets "0.3.28"
1+
(defproject org.clojars.intception/om-widgets "0.3.29"
22
:description "Widgets for OM/React"
33
:url "https://github.com/orgs/intception/"
44
:license {:name "Eclipse Public License"

‎src/om_widgets/popover.cljs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
(did-mount [this]
157157
(let [node (om.core/get-node owner)
158158
align (or (:align opts) 0.5)
159+
coordinates (om/get-state owner :coordinates)
159160
parent (dommy/remove! node)
160161
target (if (:for opts)
161162
(or (sel1 (keyword (str "#" (:for opts)))) parent)
@@ -173,7 +174,14 @@
173174
(max o (- m))
174175
(min o m)))
175176
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)))
177185
target-pos (merge trect
178186
{:top (+ (:top trect) (:scroll-y wz))
179187
:bottom (+ (:bottom trect) (:scroll-y wz))
@@ -255,14 +263,15 @@
255263
[_ owner opts]
256264
(reify
257265
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}]
259267
(html
260268
[:div {:class (:launcher-class-name opts)}
261269
(when visible
262270
(dom/div #js {:style #js {:position "absolute" :display "inline"}}
263271
(om/build popover-container nil {:init-state {:channel channel}
264272
:state {:content-fn popup-content-fn
265-
:prefered-side prefered-side}
273+
:prefered-side prefered-side
274+
:coordinates coordinates}
266275
:opts {:for (:for opts)
267276
:align (:align opts)
268277
:has-arrow (:has-arrow opts)
@@ -284,7 +293,7 @@
284293
{:visible false})
285294

286295
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]}]
288297
(html
289298
[:div {:class (:launcher-class-name opts)}
290299
[:a {:class class-name
@@ -297,6 +306,7 @@
297306
(when visible
298307
(om/build popover-container nil {:state {:content-fn body
299308
:prefered-side prefered-side
309+
:coordinates coordinates
300310
:channel channel}
301311
:opts {:align (:align opts)
302312
:has-arrow (:has-arrow opts)
@@ -327,7 +337,8 @@
327337
launcher-class-name
328338
channel
329339
align
330-
visible]
340+
visible
341+
coordinates]
331342
:or {class-name "om-widgets-popover-button"
332343
prefered-side :bottom
333344
popover-class ""
@@ -342,7 +353,8 @@
342353
:state {:visible-content-fn front-face
343354
:popup-content-fn popup-body
344355
:prefered-side prefered-side
345-
:channel channel}
356+
:channel channel
357+
:coordinates coordinates}
346358
:opts {:for for
347359
:has-arrow has-arrow
348360
:popover-class popover-class
@@ -356,7 +368,8 @@
356368
:class-name class-name
357369
:prefered-side prefered-side
358370
:body popup-body
359-
:channel channel}
371+
:channel channel
372+
:coordinates coordinates}
360373
:opts {:align align
361374
:popover-class popover-class
362375
:launcher-class-name launcher-class-name

0 commit comments

Comments
 (0)