mirror of
https://github.com/penpot/penpot.git
synced 2025-03-15 01:01:30 -05:00
🐛 Fixes problems with preview
This commit is contained in:
parent
738a791a27
commit
721879aaa8
4 changed files with 15 additions and 13 deletions
|
@ -117,7 +117,6 @@
|
||||||
(s/keys :req-un [::id
|
(s/keys :req-un [::id
|
||||||
::name
|
::name
|
||||||
::file-id
|
::file-id
|
||||||
::version
|
|
||||||
::revn
|
::revn
|
||||||
::created-at
|
::created-at
|
||||||
::modified-at
|
::modified-at
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
[uxbox.util.geom.snap-points :as sp]))
|
[uxbox.util.geom.snap-points :as sp]))
|
||||||
|
|
||||||
(def ^:private snap-accuracy 5)
|
(def ^:private snap-accuracy 5)
|
||||||
(def ^:private snap-distance-accuracy 10)
|
(def ^:private snap-distance-accuracy 5)
|
||||||
|
|
||||||
(defn- remove-from-snap-points [remove-id?]
|
(defn- remove-from-snap-points [remove-id?]
|
||||||
(fn [query-result]
|
(fn [query-result]
|
||||||
|
@ -162,7 +162,7 @@
|
||||||
(-> % gsh/selection-rect (gsh/move movev))))
|
(-> % gsh/selection-rect (gsh/move movev))))
|
||||||
(rx/merge-map
|
(rx/merge-map
|
||||||
(fn [[frame selrect]]
|
(fn [[frame selrect]]
|
||||||
(let [areas (->> (gsh/selrect->areas (or (:selrect frame) @refs/vbox) selrect)
|
(let [areas (->> (gsh/selrect->areas (or (:selrect frame) (gsh/rect->rect-shape @refs/vbox)) selrect)
|
||||||
(d/mapm #(select-shapes-area page-id shapes objects %2)))
|
(d/mapm #(select-shapes-area page-id shapes objects %2)))
|
||||||
snap-x (search-snap-distance selrect :x (:left areas) (:right areas))
|
snap-x (search-snap-distance selrect :x (:left areas) (:right areas))
|
||||||
snap-y (search-snap-distance selrect :y (:top areas) (:bottom areas))]
|
snap-y (search-snap-distance selrect :y (:top areas) (:bottom areas))]
|
||||||
|
|
|
@ -43,8 +43,8 @@
|
||||||
(mf/fnc generic-wrapper
|
(mf/fnc generic-wrapper
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [{:keys [x y width height]
|
(let [shape (unchecked-get props "shape")
|
||||||
:as shape} (->> (unchecked-get props "shape") :selrect)
|
{:keys [x y width height]} (:selrect shape)
|
||||||
|
|
||||||
childs (unchecked-get props "childs")
|
childs (unchecked-get props "childs")
|
||||||
frame (unchecked-get props "frame")
|
frame (unchecked-get props "frame")
|
||||||
|
@ -114,7 +114,8 @@
|
||||||
childs (mapv #(get objects %) (:shapes shape))
|
childs (mapv #(get objects %) (:shapes shape))
|
||||||
shape (geom/transform-shape shape)
|
shape (geom/transform-shape shape)
|
||||||
props (obj/merge! #js {} props
|
props (obj/merge! #js {} props
|
||||||
#js {:childs childs
|
#js {:shape shape
|
||||||
|
:childs childs
|
||||||
:show-interactions? show-interactions?})]
|
:show-interactions? show-interactions?})]
|
||||||
[:> frame-wrapper props]))))
|
[:> frame-wrapper props]))))
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
half-point))
|
half-point))
|
||||||
|
|
||||||
(def pill-text-width-letter 6)
|
(def pill-text-width-letter 6)
|
||||||
(def pill-text-width-margin 12)
|
(def pill-text-width-margin 6)
|
||||||
(def pill-text-font-size 12)
|
(def pill-text-font-size 12)
|
||||||
(def pill-text-height 20)
|
(def pill-text-height 20)
|
||||||
(def pill-text-border-radius 4)
|
(def pill-text-border-radius 4)
|
||||||
|
@ -52,10 +52,11 @@
|
||||||
to-c (max (get sr1 (if (= :x coord) :x1 :y1))
|
to-c (max (get sr1 (if (= :x coord) :x1 :y1))
|
||||||
(get sr2 (if (= :x coord) :x1 :y1)))
|
(get sr2 (if (= :x coord) :x1 :y1)))
|
||||||
|
|
||||||
distance (mth/round (- to-c from-c))
|
distance (- to-c from-c)
|
||||||
|
distance-str (-> distance (mth/precision 2) str)
|
||||||
half-point (half-point coord sr1 sr2)
|
half-point (half-point coord sr1 sr2)
|
||||||
width (-> distance
|
width (-> distance-str
|
||||||
mth/log10 ;; number of digits
|
count
|
||||||
(* (/ pill-text-width-letter zoom))
|
(* (/ pill-text-width-letter zoom))
|
||||||
(+ (/ pill-text-width-margin zoom)))]
|
(+ (/ pill-text-width-margin zoom)))]
|
||||||
|
|
||||||
|
@ -79,7 +80,7 @@
|
||||||
:font-size (/ pill-text-font-size zoom)
|
:font-size (/ pill-text-font-size zoom)
|
||||||
:fill "white"
|
:fill "white"
|
||||||
:text-anchor "middle"}
|
:text-anchor "middle"}
|
||||||
(mth/round distance)]])
|
(mth/precision distance 2)]])
|
||||||
|
|
||||||
(let [p1 [(+ from-c (/ segment-gap zoom)) (+ half-point (/ segment-gap-side zoom))]
|
(let [p1 [(+ from-c (/ segment-gap zoom)) (+ half-point (/ segment-gap-side zoom))]
|
||||||
p2 [(+ from-c (/ segment-gap zoom)) (- half-point (/ segment-gap-side zoom))]
|
p2 [(+ from-c (/ segment-gap zoom)) (- half-point (/ segment-gap-side zoom))]
|
||||||
|
@ -123,7 +124,8 @@
|
||||||
(fn [[selrect selected frame]]
|
(fn [[selrect selected frame]]
|
||||||
(let [lt-side (if (= coord :x) :left :top)
|
(let [lt-side (if (= coord :x) :left :top)
|
||||||
gt-side (if (= coord :x) :right :bottom)
|
gt-side (if (= coord :x) :right :bottom)
|
||||||
areas (gsh/selrect->areas (or (:selrect frame) @refs/vbox) selrect)
|
areas (gsh/selrect->areas (or (:selrect frame)
|
||||||
|
(gsh/rect->rect-shape @refs/vbox)) selrect)
|
||||||
query-side (fn [side]
|
query-side (fn [side]
|
||||||
(->> (uw/ask! {:cmd :selection/query
|
(->> (uw/ask! {:cmd :selection/query
|
||||||
:page-id page-id
|
:page-id page-id
|
||||||
|
@ -141,7 +143,7 @@
|
||||||
(gsh/distance-selrect sr selrect)
|
(gsh/distance-selrect sr selrect)
|
||||||
(gsh/distance-selrect selrect sr))
|
(gsh/distance-selrect selrect sr))
|
||||||
coord
|
coord
|
||||||
mth/round)))
|
(mth/precision 2))))
|
||||||
|
|
||||||
get-shapes-match
|
get-shapes-match
|
||||||
(fn [pred? shapes]
|
(fn [pred? shapes]
|
||||||
|
|
Loading…
Add table
Reference in a new issue