Merge pull request #3089 from penpot/alotor-bugfixing-13

Alotor bugfixing 13
This commit is contained in:
Alejandro
2023-03-31 08:49:46 +02:00
committed by GitHub
5 changed files with 84 additions and 68 deletions

View File

@@ -73,6 +73,8 @@
- Fix last update project timer update after creating new file [Taiga #5096](https://tree.taiga.io/project/penpot/issue/5096)
- Fix dashboard scrolling using 'Page Up' and 'Page Down' [Taiga #5081](https://tree.taiga.io/project/penpot/issue/5081)
- Fix view mode header buttons overlapping in small resolutions [Taiga #5058](https://tree.taiga.io/project/penpot/issue/5058)
- Fix precision for wrap in flex [Taiga #5072](https://tree.taiga.io/project/penpot/issue/5072)
- Fix relative position overlay positioning [Taiga #5092](https://tree.taiga.io/project/penpot/issue/5092)
### :heart: Community contributions by (Thank you!)
- To @ondrejkonec: for contributing to the code with:

View File

@@ -104,8 +104,10 @@
(if (and (some? line-data)
(or (not wrap?)
(and row? (<= next-line-min-width layout-width))
(and col? (<= next-line-min-height layout-height))))
(and row? (or (< next-line-min-width layout-width)
(mth/close? next-line-min-width layout-width 0.5)))
(and col? (or (< next-line-min-height layout-height)
(mth/close? next-line-min-height layout-height 0.5)))))
(recur {:line-min-width (if row? (+ line-min-width next-min-width) (max line-min-width next-min-width))
:line-max-width (if row? (+ line-max-width next-max-width) (max line-max-width next-max-width))

View File

@@ -185,8 +185,10 @@
(defn close?
"Equality for float numbers. Check if the difference is within a range"
[num1 num2]
(<= (abs (- num1 num2)) float-equal-precision))
([num1 num2]
(close? num1 num2 float-equal-precision))
([num1 num2 precision]
(<= (abs (- num1 num2)) precision)))
(defn lerp
"Calculates a the linear interpolation between two values and a given percent"

View File

@@ -664,7 +664,8 @@
(pcb/update-shapes ordered-indexes ctl/remove-layout-item-data))
;; Remove the hide in viewer flag
(pcb/update-shapes ordered-indexes #(cond-> % (cph/frame-shape? %) (assoc :hide-in-viewer true)))
(cond-> (and (not= uuid/zero parent-id) (cph/frame-shape? objects parent-id))
(pcb/update-shapes ordered-indexes #(cond-> % (cph/frame-shape? %) (assoc :hide-in-viewer true))))
;; Move the shapes
(pcb/change-parent parent-id

View File

@@ -7,6 +7,7 @@
(ns app.main.ui.viewer.shapes
"The main container for a frame in viewer mode"
(:require
[app.common.geom.point :as gpt]
[app.common.geom.shapes :as gsh]
[app.common.pages.helpers :as cph]
[app.common.types.shape.interactions :as ctsi]
@@ -46,80 +47,88 @@
(defn- activate-interaction
[interaction shape base-frame frame-offset objects overlays]
(case (:action-type interaction)
:navigate
(when-let [frame-id (:destination interaction)]
(let [viewer-section (dom/get-element "viewer-section")
scroll (if (:preserve-scroll interaction)
(dom/get-scroll-pos viewer-section)
0)]
(st/emit! (dv/set-nav-scroll scroll)
(dv/go-to-frame frame-id (:animation interaction)))))
:open-overlay
(let [dest-frame-id (:destination interaction)
viewer-objects (deref (refs/get-viewer-objects))
dest-frame (get viewer-objects dest-frame-id)
relative-to-id (if (= :manual (:overlay-pos-type interaction))
(:id shape) ;; manual interactions are allways from "self"
(:position-relative-to interaction))
relative-to-shape (or (get objects relative-to-id) base-frame)
close-click-outside (:close-click-outside interaction)
background-overlay (:background-overlay interaction)
overlays-ids (set (map :id overlays))
relative-to-base-frame (find-relative-to-base-frame relative-to-shape objects overlays-ids base-frame)
position (ctsi/calc-overlay-position interaction
viewer-objects
relative-to-shape
relative-to-base-frame
dest-frame
frame-offset)]
(when dest-frame-id
(st/emit! (dv/open-overlay dest-frame-id
position
close-click-outside
background-overlay
(:animation interaction)))))
(let [;; When the interactive item is inside a nested frame we need to add to the offset the position
;; of the parent-frame otherwise the position won't match
shape-frame (cph/get-frame objects shape)
:toggle-overlay
(let [frame-id (:destination interaction)
dest-frame (get objects frame-id)
relative-to-id (if (= :manual (:overlay-pos-type interaction))
(:id shape) ;; manual interactions are allways from "self"
(:position-relative-to interaction))
relative-to-shape (or (get objects relative-to-id) base-frame)
overlays-ids (set (map :id overlays))
relative-to-base-frame (find-relative-to-base-frame relative-to-shape objects overlays-ids base-frame)
position (ctsi/calc-overlay-position interaction
objects
relative-to-shape
relative-to-base-frame
dest-frame
frame-offset)
frame-offset (if (or (cph/root-frame? shape-frame) (cph/root? shape-frame))
frame-offset
(gpt/add frame-offset (gpt/point shape-frame)))]
(case (:action-type interaction)
:navigate
(when-let [frame-id (:destination interaction)]
(let [viewer-section (dom/get-element "viewer-section")
scroll (if (:preserve-scroll interaction)
(dom/get-scroll-pos viewer-section)
0)]
(st/emit! (dv/set-nav-scroll scroll)
(dv/go-to-frame frame-id (:animation interaction)))))
close-click-outside (:close-click-outside interaction)
background-overlay (:background-overlay interaction)]
(when frame-id
(st/emit! (dv/toggle-overlay frame-id
:open-overlay
(let [dest-frame-id (:destination interaction)
viewer-objects (deref (refs/get-viewer-objects))
dest-frame (get viewer-objects dest-frame-id)
relative-to-id (if (= :manual (:overlay-pos-type interaction))
(:id shape) ;; manual interactions are allways from "self"
(:position-relative-to interaction))
relative-to-shape (or (get objects relative-to-id) base-frame)
close-click-outside (:close-click-outside interaction)
background-overlay (:background-overlay interaction)
overlays-ids (set (map :id overlays))
relative-to-base-frame (find-relative-to-base-frame relative-to-shape objects overlays-ids base-frame)
position (ctsi/calc-overlay-position interaction
viewer-objects
relative-to-shape
relative-to-base-frame
dest-frame
frame-offset)]
(when dest-frame-id
(st/emit! (dv/open-overlay dest-frame-id
position
close-click-outside
background-overlay
(:animation interaction)))))
:close-overlay
(let [frame-id (or (:destination interaction)
(if (= (:type shape) :frame)
(:id shape)
(:frame-id shape)))]
(st/emit! (dv/close-overlay frame-id (:animation interaction))))
:toggle-overlay
(let [frame-id (:destination interaction)
dest-frame (get objects frame-id)
relative-to-id (if (= :manual (:overlay-pos-type interaction))
(:id shape) ;; manual interactions are allways from "self"
(:position-relative-to interaction))
relative-to-shape (or (get objects relative-to-id) base-frame)
overlays-ids (set (map :id overlays))
relative-to-base-frame (find-relative-to-base-frame relative-to-shape objects overlays-ids base-frame)
position (ctsi/calc-overlay-position interaction
objects
relative-to-shape
relative-to-base-frame
dest-frame
frame-offset)
:prev-screen
(st/emit! (rt/nav-back-local))
close-click-outside (:close-click-outside interaction)
background-overlay (:background-overlay interaction)]
(when frame-id
(st/emit! (dv/toggle-overlay frame-id
position
close-click-outside
background-overlay
(:animation interaction)))))
:open-url
(st/emit! (dom/open-new-window (:url interaction)))
:close-overlay
(let [frame-id (or (:destination interaction)
(if (= (:type shape) :frame)
(:id shape)
(:frame-id shape)))]
(st/emit! (dv/close-overlay frame-id (:animation interaction))))
nil))
:prev-screen
(st/emit! (rt/nav-back-local))
:open-url
(st/emit! (dom/open-new-window (:url interaction)))
nil)))
;; Perform the opposite action of an interaction, if possible
(defn- deactivate-interaction