mirror of
https://github.com/penpot/penpot.git
synced 2025-02-25 16:25:56 -05:00
commit
7c3d71e572
14 changed files with 95 additions and 13 deletions
|
@ -7,6 +7,7 @@
|
||||||
### :sparkles: New features
|
### :sparkles: New features
|
||||||
|
|
||||||
- Enhance corner radius behavior [Taiga #2190](https://tree.taiga.io/project/penpot/issue/2190).
|
- Enhance corner radius behavior [Taiga #2190](https://tree.taiga.io/project/penpot/issue/2190).
|
||||||
|
- Allow preserve scroll position in interactions [Taiga task #1998](https://tree.taiga.io/project/penpot/task/1998).
|
||||||
|
|
||||||
### :bug: Bugs fixed
|
### :bug: Bugs fixed
|
||||||
|
|
||||||
|
|
|
@ -392,7 +392,8 @@
|
||||||
|
|
||||||
(defmethod read-action-opts :navigate
|
(defmethod read-action-opts :navigate
|
||||||
[interaction-src]
|
[interaction-src]
|
||||||
(select-keys interaction-src [:destination]))
|
(select-keys interaction-src [:destination
|
||||||
|
:preserve-scroll]))
|
||||||
|
|
||||||
(defmethod read-action-opts :open-overlay
|
(defmethod read-action-opts :open-overlay
|
||||||
[interaction-src]
|
[interaction-src]
|
||||||
|
@ -430,7 +431,8 @@
|
||||||
(let [{:keys [event-type action-type]} (read-classifier interaction-src)
|
(let [{:keys [event-type action-type]} (read-classifier interaction-src)
|
||||||
{:keys [delay]} (read-event-opts interaction-src)
|
{:keys [delay]} (read-event-opts interaction-src)
|
||||||
{:keys [destination overlay-pos-type overlay-position url
|
{:keys [destination overlay-pos-type overlay-position url
|
||||||
close-click-outside background-overlay]} (read-action-opts interaction-src)
|
close-click-outside background-overlay preserve-scroll]}
|
||||||
|
(read-action-opts interaction-src)
|
||||||
|
|
||||||
interactions (-> (lookup-shape file from-id)
|
interactions (-> (lookup-shape file from-id)
|
||||||
:interactions
|
:interactions
|
||||||
|
@ -443,7 +445,8 @@
|
||||||
:overlay-position overlay-position
|
:overlay-position overlay-position
|
||||||
:url url
|
:url url
|
||||||
:close-click-outside close-click-outside
|
:close-click-outside close-click-outside
|
||||||
:background-overlay background-overlay})))]
|
:background-overlay background-overlay
|
||||||
|
:preserve-scroll preserve-scroll})))]
|
||||||
(commit-change
|
(commit-change
|
||||||
file
|
file
|
||||||
{:type :mod-obj
|
{:type :mod-obj
|
||||||
|
|
|
@ -64,11 +64,13 @@
|
||||||
(s/def ::url ::us/string)
|
(s/def ::url ::us/string)
|
||||||
(s/def ::close-click-outside ::us/boolean)
|
(s/def ::close-click-outside ::us/boolean)
|
||||||
(s/def ::background-overlay ::us/boolean)
|
(s/def ::background-overlay ::us/boolean)
|
||||||
|
(s/def ::preserve-scroll ::us/boolean)
|
||||||
|
|
||||||
(defmulti action-opts-spec :action-type)
|
(defmulti action-opts-spec :action-type)
|
||||||
|
|
||||||
(defmethod action-opts-spec :navigate [_]
|
(defmethod action-opts-spec :navigate [_]
|
||||||
(s/keys :req-un [::destination]))
|
(s/keys :req-un [::destination]
|
||||||
|
:opt-un [::preserve-scroll]))
|
||||||
|
|
||||||
(defmethod action-opts-spec :open-overlay [_]
|
(defmethod action-opts-spec :open-overlay [_]
|
||||||
(s/keys :req-un [::destination
|
(s/keys :req-un [::destination
|
||||||
|
@ -151,7 +153,8 @@
|
||||||
:navigate
|
:navigate
|
||||||
(assoc interaction
|
(assoc interaction
|
||||||
:action-type action-type
|
:action-type action-type
|
||||||
:destination (get interaction :destination))
|
:destination (get interaction :destination)
|
||||||
|
:preserve-scroll false)
|
||||||
|
|
||||||
(:open-overlay :toggle-overlay)
|
(:open-overlay :toggle-overlay)
|
||||||
(let [overlay-pos-type (get interaction :overlay-pos-type :center)
|
(let [overlay-pos-type (get interaction :overlay-pos-type :center)
|
||||||
|
@ -196,6 +199,10 @@
|
||||||
(and (has-destination interaction)
|
(and (has-destination interaction)
|
||||||
(some? (:destination interaction))))
|
(some? (:destination interaction))))
|
||||||
|
|
||||||
|
(defn has-preserve-scroll
|
||||||
|
[interaction]
|
||||||
|
(= (:action-type interaction) :navigate))
|
||||||
|
|
||||||
(defn set-destination
|
(defn set-destination
|
||||||
[interaction destination]
|
[interaction destination]
|
||||||
(us/verify ::interaction interaction)
|
(us/verify ::interaction interaction)
|
||||||
|
@ -210,6 +217,13 @@
|
||||||
(assoc :overlay-pos-type :center
|
(assoc :overlay-pos-type :center
|
||||||
:overlay-position (gpt/point 0 0))))
|
:overlay-position (gpt/point 0 0))))
|
||||||
|
|
||||||
|
(defn set-preserve-scroll
|
||||||
|
[interaction preserve-scroll]
|
||||||
|
(us/verify ::interaction interaction)
|
||||||
|
(us/verify ::us/boolean preserve-scroll)
|
||||||
|
(assert (has-preserve-scroll interaction))
|
||||||
|
(assoc interaction :preserve-scroll preserve-scroll))
|
||||||
|
|
||||||
(defn has-url
|
(defn has-url
|
||||||
[interaction]
|
[interaction]
|
||||||
(= (:action-type interaction) :open-url))
|
(= (:action-type interaction) :open-url))
|
||||||
|
|
|
@ -46,7 +46,7 @@ $width-settings-bar: 16rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.handoff-layout {
|
.handoff-layout {
|
||||||
.viewer-preview {
|
.viewer-section {
|
||||||
flex-wrap: nowrap;
|
flex-wrap: nowrap;
|
||||||
}
|
}
|
||||||
.settings-bar {
|
.settings-bar {
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
.viewer-preview {
|
.viewer-section {
|
||||||
height: calc(100vh - 40px);
|
height: calc(100vh - 48px);
|
||||||
|
|
||||||
grid-row: 1 / span 2;
|
grid-row: 1 / span 2;
|
||||||
grid-column: 1 / span 1;
|
grid-column: 1 / span 1;
|
||||||
|
|
|
@ -302,6 +302,21 @@
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:viewer-local :interactions-show?] false))))
|
(assoc-in state [:viewer-local :interactions-show?] false))))
|
||||||
|
|
||||||
|
(defn set-nav-scroll
|
||||||
|
[scroll]
|
||||||
|
(ptk/reify ::set-nav-scroll
|
||||||
|
ptk/UpdateEvent
|
||||||
|
(update [_ state]
|
||||||
|
(assoc-in state [:viewer-local :nav-scroll] scroll))))
|
||||||
|
|
||||||
|
(defn reset-nav-scroll
|
||||||
|
[]
|
||||||
|
(ptk/reify ::reset-nav-scroll
|
||||||
|
ptk/UpdateEvent
|
||||||
|
(update [_ state]
|
||||||
|
(d/dissoc-in state [:viewer-local :nav-scroll]))))
|
||||||
|
|
||||||
|
|
||||||
;; --- Navigation inside page
|
;; --- Navigation inside page
|
||||||
|
|
||||||
(defn go-to-frame-by-index
|
(defn go-to-frame-by-index
|
||||||
|
|
|
@ -242,7 +242,8 @@
|
||||||
:penpot:overlay-position-y ((d/nilf get-in) interaction [:overlay-position :y])
|
:penpot:overlay-position-y ((d/nilf get-in) interaction [:overlay-position :y])
|
||||||
:penpot:url (:url interaction)
|
:penpot:url (:url interaction)
|
||||||
:penpot:close-click-outside ((d/nilf str) (:close-click-outside interaction))
|
:penpot:close-click-outside ((d/nilf str) (:close-click-outside interaction))
|
||||||
:penpot:background-overlay ((d/nilf str) (:background-overlay interaction))}])]))
|
:penpot:background-overlay ((d/nilf str) (:background-overlay interaction))
|
||||||
|
:penpot:preserve-scroll ((d/nilf str) (:preserve-scroll interaction))}])]))
|
||||||
|
|
||||||
(mf/defc export-data
|
(mf/defc export-data
|
||||||
[{:keys [shape]}]
|
[{:keys [shape]}]
|
||||||
|
|
|
@ -43,6 +43,8 @@
|
||||||
|
|
||||||
local (mf/deref refs/viewer-local)
|
local (mf/deref refs/viewer-local)
|
||||||
|
|
||||||
|
nav-scroll (:nav-scroll local)
|
||||||
|
|
||||||
page-id (or page-id (-> file :data :pages first))
|
page-id (or page-id (-> file :data :pages first))
|
||||||
|
|
||||||
page (mf/use-memo
|
page (mf/use-memo
|
||||||
|
@ -91,6 +93,14 @@
|
||||||
(fn []
|
(fn []
|
||||||
(events/unlistenByKey key1)))))
|
(events/unlistenByKey key1)))))
|
||||||
|
|
||||||
|
(mf/use-layout-effect
|
||||||
|
(mf/deps nav-scroll)
|
||||||
|
(fn []
|
||||||
|
(when (number? nav-scroll)
|
||||||
|
(let [viewer-section (dom/get-element "viewer-section")]
|
||||||
|
(st/emit! (dv/reset-nav-scroll))
|
||||||
|
(dom/set-scroll-pos! viewer-section nav-scroll)))))
|
||||||
|
|
||||||
[:div {:class (dom/classnames
|
[:div {:class (dom/classnames
|
||||||
:force-visible (:show-thumbnails local)
|
:force-visible (:show-thumbnails local)
|
||||||
:viewer-layout (not= section :handoff)
|
:viewer-layout (not= section :handoff)
|
||||||
|
@ -110,7 +120,7 @@
|
||||||
:show? (:show-thumbnails local false)
|
:show? (:show-thumbnails local false)
|
||||||
:page page
|
:page page
|
||||||
:index index}]
|
:index index}]
|
||||||
[:section.viewer-preview
|
[:section.viewer-section {:id "viewer-section"}
|
||||||
(cond
|
(cond
|
||||||
(empty? frames)
|
(empty? frames)
|
||||||
[:section.empty-state
|
[:section.empty-state
|
||||||
|
|
|
@ -44,7 +44,12 @@
|
||||||
(case (:action-type interaction)
|
(case (:action-type interaction)
|
||||||
:navigate
|
:navigate
|
||||||
(when-let [frame-id (:destination interaction)]
|
(when-let [frame-id (:destination interaction)]
|
||||||
(st/emit! (dv/go-to-frame frame-id)))
|
(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))))
|
||||||
|
|
||||||
:open-overlay
|
:open-overlay
|
||||||
(let [dest-frame-id (:destination interaction)
|
(let [dest-frame-id (:destination interaction)
|
||||||
|
|
|
@ -169,6 +169,7 @@
|
||||||
overlay-pos-type (:overlay-pos-type interaction)
|
overlay-pos-type (:overlay-pos-type interaction)
|
||||||
close-click-outside? (:close-click-outside interaction false)
|
close-click-outside? (:close-click-outside interaction false)
|
||||||
background-overlay? (:background-overlay interaction false)
|
background-overlay? (:background-overlay interaction false)
|
||||||
|
preserve-scroll? (:preserve-scroll interaction false)
|
||||||
|
|
||||||
extended-open? (mf/use-state false)
|
extended-open? (mf/use-state false)
|
||||||
|
|
||||||
|
@ -197,6 +198,11 @@
|
||||||
value (when (not= value "") (uuid/uuid value))]
|
value (when (not= value "") (uuid/uuid value))]
|
||||||
(update-interaction index #(cti/set-destination % value))))
|
(update-interaction index #(cti/set-destination % value))))
|
||||||
|
|
||||||
|
change-preserve-scroll
|
||||||
|
(fn [event]
|
||||||
|
(let [value (-> event dom/get-target dom/checked?)]
|
||||||
|
(update-interaction index #(cti/set-preserve-scroll % value))))
|
||||||
|
|
||||||
change-url
|
change-url
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(let [target (dom/get-target event)
|
(let [target (dom/get-target event)
|
||||||
|
@ -295,6 +301,17 @@
|
||||||
(not= (:id frame) (:frame-id shape))) ; nor a shape to its container frame
|
(not= (:id frame) (:frame-id shape))) ; nor a shape to its container frame
|
||||||
[:option {:value (str (:id frame))} (:name frame)]))]])
|
[:option {:value (str (:id frame))} (:name frame)]))]])
|
||||||
|
|
||||||
|
; Preserve scroll
|
||||||
|
(when (cti/has-preserve-scroll interaction)
|
||||||
|
[:div.interactions-element
|
||||||
|
[:div.input-checkbox
|
||||||
|
[:input {:type "checkbox"
|
||||||
|
:id (str "preserve-" index)
|
||||||
|
:checked preserve-scroll?
|
||||||
|
:on-change change-preserve-scroll}]
|
||||||
|
[:label {:for (str "preserve-" index)}
|
||||||
|
(tr "workspace.options.interaction-preserve-scroll")]]])
|
||||||
|
|
||||||
; URL
|
; URL
|
||||||
(when (cti/has-url interaction)
|
(when (cti/has-url interaction)
|
||||||
[:div.interactions-element
|
[:div.interactions-element
|
||||||
|
|
|
@ -340,6 +340,14 @@
|
||||||
(defn remove-attribute [^js node ^string attr]
|
(defn remove-attribute [^js node ^string attr]
|
||||||
(.removeAttribute node attr))
|
(.removeAttribute node attr))
|
||||||
|
|
||||||
|
(defn get-scroll-pos
|
||||||
|
[element]
|
||||||
|
(.-scrollTop ^js element))
|
||||||
|
|
||||||
|
(defn set-scroll-pos!
|
||||||
|
[element scroll]
|
||||||
|
(obj/set! ^js element "scrollTop" scroll))
|
||||||
|
|
||||||
(defn scroll-into-view!
|
(defn scroll-into-view!
|
||||||
([element]
|
([element]
|
||||||
(.scrollIntoView ^js element false))
|
(.scrollIntoView ^js element false))
|
||||||
|
|
|
@ -763,7 +763,8 @@
|
||||||
(assoc :delay (get-meta node :delay d/parse-double))
|
(assoc :delay (get-meta node :delay d/parse-double))
|
||||||
|
|
||||||
(cti/has-destination interaction)
|
(cti/has-destination interaction)
|
||||||
(assoc :destination (get-meta node :destination uuid/uuid))
|
(assoc :destination (get-meta node :destination uuid/uuid)
|
||||||
|
:preserve-scroll (get-meta node :preserve-scroll str->bool))
|
||||||
|
|
||||||
(cti/has-url interaction)
|
(cti/has-url interaction)
|
||||||
(assoc :url (get-meta node :url str))
|
(assoc :url (get-meta node :url str))
|
||||||
|
|
|
@ -2469,6 +2469,10 @@ msgstr "Top right"
|
||||||
msgid "workspace.options.interaction-position"
|
msgid "workspace.options.interaction-position"
|
||||||
msgstr "Position"
|
msgstr "Position"
|
||||||
|
|
||||||
|
#: src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs
|
||||||
|
msgid "workspace.options.interaction-preserve-scroll"
|
||||||
|
msgstr "Preserve scroll position"
|
||||||
|
|
||||||
#: src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs
|
#: src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs
|
||||||
msgid "workspace.options.interaction-prev-screen"
|
msgid "workspace.options.interaction-prev-screen"
|
||||||
msgstr "Previous screen"
|
msgstr "Previous screen"
|
||||||
|
@ -3200,4 +3204,3 @@ msgstr "Update"
|
||||||
|
|
||||||
msgid "workspace.viewport.click-to-close-path"
|
msgid "workspace.viewport.click-to-close-path"
|
||||||
msgstr "Click to close the path"
|
msgstr "Click to close the path"
|
||||||
|
|
||||||
|
|
|
@ -2464,6 +2464,10 @@ msgstr "Arriba derecha"
|
||||||
msgid "workspace.options.interaction-position"
|
msgid "workspace.options.interaction-position"
|
||||||
msgstr "Posición"
|
msgstr "Posición"
|
||||||
|
|
||||||
|
#: src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs
|
||||||
|
msgid "workspace.options.interaction-preserve-scroll"
|
||||||
|
msgstr "Conservar posición de desplazamiento"
|
||||||
|
|
||||||
#: src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs
|
#: src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs
|
||||||
msgid "workspace.options.interaction-prev-screen"
|
msgid "workspace.options.interaction-prev-screen"
|
||||||
msgstr "Pantalla anterior"
|
msgstr "Pantalla anterior"
|
||||||
|
|
Loading…
Add table
Reference in a new issue