mirror of
https://github.com/penpot/penpot.git
synced 2025-03-12 07:41:43 -05:00
🐛 Fixes problem with snaps
This commit is contained in:
parent
7ac78cb103
commit
a399363b08
3 changed files with 21 additions and 10 deletions
|
@ -9,16 +9,17 @@
|
|||
|
||||
(ns app.main.snap
|
||||
(:require
|
||||
[clojure.set :as set]
|
||||
[beicon.core :as rx]
|
||||
[app.common.uuid :refer [zero]]
|
||||
[app.common.math :as mth]
|
||||
[app.common.data :as d]
|
||||
[app.common.geom.point :as gpt]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.main.worker :as uw]
|
||||
[app.common.math :as mth]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.uuid :refer [zero]]
|
||||
[app.main.refs :as refs]
|
||||
[app.util.geom.snap-points :as sp]))
|
||||
[app.main.worker :as uw]
|
||||
[app.util.geom.snap-points :as sp]
|
||||
[beicon.core :as rx]
|
||||
[clojure.set :as set]))
|
||||
|
||||
(defonce ^:private snap-accuracy 5)
|
||||
(defonce ^:private snap-distance-accuracy 10)
|
||||
|
@ -186,6 +187,7 @@
|
|||
:frame-id (->> shapes first :frame-id)
|
||||
:include-frames? true
|
||||
:rect area-selrect})
|
||||
(rx/map #(cp/clean-loops objects %))
|
||||
(rx/map #(set/difference % (into #{} (map :id shapes))))
|
||||
(rx/map (fn [ids] (map #(get objects %) ids)))))
|
||||
|
||||
|
|
|
@ -101,8 +101,13 @@
|
|||
:rect rect
|
||||
:include-frames? true}))))
|
||||
|
||||
;; We use ref so we don't recreate the stream on a change
|
||||
transform-ref (mf/use-ref nil)
|
||||
|
||||
over-shapes-stream
|
||||
(->> move-stream
|
||||
;; When transforming shapes we stop querying the worker
|
||||
(rx/filter #(not (some? (mf/ref-val transform-ref))))
|
||||
(rx/switch-map query-point))
|
||||
|
||||
roots (mf/use-memo
|
||||
|
@ -111,9 +116,13 @@
|
|||
(let [roots-ids (cp/clean-loops objects selected)]
|
||||
(->> roots-ids (mapv #(get objects %))))))]
|
||||
|
||||
(mf/use-effect
|
||||
(mf/deps transform)
|
||||
#(mf/set-ref-val! transform-ref transform))
|
||||
|
||||
(hooks/use-stream
|
||||
over-shapes-stream
|
||||
(mf/deps page-id objects transform selected @ctrl?)
|
||||
(mf/deps page-id objects selected @ctrl?)
|
||||
(fn [ids]
|
||||
(let [remove-id? (into #{} (mapcat #(cp/get-parents % objects)) selected)
|
||||
remove-id? (if @ctrl?
|
||||
|
@ -122,9 +131,8 @@
|
|||
(filterv #(= :group (get-in objects [% :type])))))
|
||||
remove-id?)
|
||||
ids (->> ids (filterv (comp not remove-id?)))]
|
||||
(when (not transform)
|
||||
(reset! hover (get objects (first ids)))
|
||||
(reset! hover-ids ids)))))))
|
||||
(reset! hover-ids ids))))))
|
||||
|
||||
(defn setup-viewport-modifiers [modifiers selected objects render-ref]
|
||||
(let [roots (mf/use-memo
|
||||
|
|
|
@ -232,6 +232,7 @@
|
|||
:frame-id (:id frame)
|
||||
:include-frames? true
|
||||
:rect rect})
|
||||
(rx/map #(cp/clean-loops @refs/workspace-page-objects %))
|
||||
(rx/map #(set/difference % selected))
|
||||
(rx/map #(->> % (map (partial get @refs/workspace-page-objects)))))
|
||||
(rx/of nil))))]
|
||||
|
|
Loading…
Add table
Reference in a new issue