mirror of
https://github.com/penpot/penpot.git
synced 2025-08-06 11:18:33 +02:00
🐛 Fix problem with z positioning of elements
This commit is contained in:
parent
6a4d505033
commit
cbe8587db3
2 changed files with 17 additions and 26 deletions
|
@ -31,6 +31,7 @@
|
||||||
- Fix problems with touch devices and Wacom tablets [#2216](https://github.com/penpot/penpot/issues/2216)
|
- Fix problems with touch devices and Wacom tablets [#2216](https://github.com/penpot/penpot/issues/2216)
|
||||||
- Fix problem with board titles misplaced [Taiga #4738](https://tree.taiga.io/project/penpot/issue/4738)
|
- Fix problem with board titles misplaced [Taiga #4738](https://tree.taiga.io/project/penpot/issue/4738)
|
||||||
- Fix problem with alt getting stuck when alt+tab [Taiga #5013](https://tree.taiga.io/project/penpot/issue/5013)
|
- Fix problem with alt getting stuck when alt+tab [Taiga #5013](https://tree.taiga.io/project/penpot/issue/5013)
|
||||||
|
- Fix problem with z positioning of elements [Taiga #5014](https://tree.taiga.io/project/penpot/issue/5014)
|
||||||
|
|
||||||
### :heart: Community contributions by (Thank you!)
|
### :heart: Community contributions by (Thank you!)
|
||||||
- To @ondrejkonec: for contributing to the code with:
|
- To @ondrejkonec: for contributing to the code with:
|
||||||
|
|
|
@ -148,17 +148,17 @@
|
||||||
[base idx-a idx-b]))
|
[base idx-a idx-b]))
|
||||||
|
|
||||||
(defn is-shape-over-shape?
|
(defn is-shape-over-shape?
|
||||||
[objects base-shape-id over-shape-id]
|
[objects base-shape-id over-shape-id bottom-frames?]
|
||||||
|
|
||||||
(let [[base index-a index-b] (get-base objects base-shape-id over-shape-id)]
|
(let [[base index-a index-b] (get-base objects base-shape-id over-shape-id)]
|
||||||
(cond
|
(cond
|
||||||
;; The base the base shape, so the other item is bellow
|
;; The base the base shape, so the other item is bellow (if not bottom-frames)
|
||||||
(= base base-shape-id)
|
(= base base-shape-id)
|
||||||
false
|
(and bottom-frames? (cph/frame-shape? objects base))
|
||||||
|
|
||||||
;; The base is the testing over, so it's over
|
;; The base is the testing over, so it's over (if not bottom-frames)
|
||||||
(= base over-shape-id)
|
(= base over-shape-id)
|
||||||
true
|
(or (not bottom-frames?) (not (cph/frame-shape? objects base)))
|
||||||
|
|
||||||
;; Check which index is lower
|
;; Check which index is lower
|
||||||
:else
|
:else
|
||||||
|
@ -177,29 +177,19 @@
|
||||||
([objects ids]
|
([objects ids]
|
||||||
(sort-z-index objects ids nil))
|
(sort-z-index objects ids nil))
|
||||||
|
|
||||||
([objects ids {:keys [bottom-frames?] :as options}]
|
([objects ids {:keys [bottom-frames?] :as options
|
||||||
(letfn [(comp [id-a id-b]
|
:or {bottom-frames? false}}]
|
||||||
(let [frame-a? (= :frame (dm/get-in objects [id-a :type]))
|
(letfn [
|
||||||
frame-b? (= :frame (dm/get-in objects [id-b :type]))]
|
(comp [id-a id-b]
|
||||||
(cond
|
(cond
|
||||||
(= id-a id-b)
|
(= id-a id-b)
|
||||||
0
|
0
|
||||||
|
|
||||||
(and (not frame-a?) frame-b?)
|
(is-shape-over-shape? objects id-a id-b bottom-frames?)
|
||||||
(if bottom-frames? -1 1)
|
1
|
||||||
|
|
||||||
(and frame-a? (not frame-b?))
|
:else
|
||||||
(if bottom-frames? 1 -1)
|
-1))]
|
||||||
|
|
||||||
;; When comparing frames we invert the order if the flag `bottom-frames?` is on
|
|
||||||
(and frame-a? frame-b? bottom-frames?)
|
|
||||||
(if (is-shape-over-shape? objects id-b id-a) 1 -1)
|
|
||||||
|
|
||||||
(is-shape-over-shape? objects id-b id-a)
|
|
||||||
-1
|
|
||||||
|
|
||||||
:else
|
|
||||||
1)))]
|
|
||||||
(sort comp ids))))
|
(sort comp ids))))
|
||||||
|
|
||||||
(defn frame-id-by-position
|
(defn frame-id-by-position
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue