Skip to content

Commit 4f09f69

Browse files
committed
Parametro adicional con el id de un div padre que este usando css zoom para poder ajustar la posicion del popover
1 parent 596f342 commit 4f09f69

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
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.44"
1+
(defproject org.clojars.intception/om-widgets "0.3.45"
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: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,27 @@
174174
(if (< o 0)
175175
(max o (- m))
176176
(min o m)))
177+
apply-zoom-factor (fn [rect zoomed-container]
178+
(if-let [zn (.getElementById js/document zoomed-container)]
179+
(let [zoom (.-zoom (.getComputedStyle js/window zn ""))]
180+
(merge rect {:top (* (:top rect) zoom)
181+
:left (* (:left rect) zoom)
182+
:bottom (* (:bottom rect) zoom)
183+
:right (* (:right rect) zoom)
184+
:width (* (:width rect) zoom)
185+
:height (* (:height rect) zoom)}))
186+
rect))
177187
wz (window-size)
178-
trect (if coordinates
179-
{:top (:y coordinates)
180-
:bottom (+ (:y coordinates) 1)
181-
:left (:x coordinates)
182-
:right (+ (:x coordinates) 1)
183-
:width 1
184-
:height 1}
185-
(first (client-rects target)))
188+
trect (-> (if coordinates
189+
{:top (:y coordinates)
190+
:bottom (+ (:y coordinates) 1)
191+
:left (:x coordinates)
192+
:right (+ (:x coordinates) 1)
193+
:width 1
194+
:height 1}
195+
(first (client-rects target)))
196+
(cond-> (:zoomed-container opts)
197+
(apply-zoom-factor (:zoomed-container opts))))
186198
target-pos (merge trect
187199
{:top (+ (:top trect) (:scroll-y wz))
188200
:bottom (+ (:bottom trect) (:scroll-y wz))
@@ -251,6 +263,7 @@
251263

252264
om/IRenderState
253265
(render-state [this {:keys [label side has-arrow content-fn mouse-down] :as state}]
266+
254267
(html
255268
[:div {:class (str "om-widgets-popover " (name side) " " (:popover-class opts))}
256269
(when (:mouse-down opts)
@@ -278,6 +291,7 @@
278291
:has-arrow (:has-arrow opts)
279292
:mouse-down #(om/set-state! owner :visible false)
280293
:popover-class (:popover-class opts)
294+
:zoomed-container (:zoomed-container opts)
281295
:close-fn #(go
282296
(<! (timeout 10))
283297
(om/set-state! owner :visible false))}})))
@@ -312,6 +326,7 @@
312326
:opts {:align (:align opts)
313327
:has-arrow (:has-arrow opts)
314328
:mouse-down #(om/set-state! owner :visible false)
329+
:zoomed-container (:zoomed-container opts)
315330
:popover-class (:popover-class opts)
316331
:close-fn #(go
317332
(<! (timeout 10))
@@ -336,6 +351,7 @@
336351
has-arrow
337352
popover-class
338353
launcher-class-name
354+
zoomed-container
339355
channel
340356
align
341357
visible
@@ -358,6 +374,8 @@
358374
:coordinates coordinates}
359375
:opts {:for for
360376
:has-arrow has-arrow
377+
:zoomed-container zoomed-container
378+
361379
:popover-class popover-class
362380
:launcher-class-name launcher-class-name
363381
:align align}})
@@ -373,5 +391,6 @@
373391
:coordinates coordinates}
374392
:opts {:align align
375393
:popover-class popover-class
394+
:zoomed-container zoomed-container
376395
:launcher-class-name launcher-class-name
377396
:has-arrow has-arrow}})))

0 commit comments

Comments
 (0)