mirror of
https://github.com/penpot/penpot.git
synced 2025-05-28 22:36:10 +02:00
🎉 Add preserve scroll option
This commit is contained in:
parent
3d59d31b0a
commit
f913816d87
14 changed files with 94 additions and 12 deletions
|
@ -392,7 +392,8 @@
|
|||
|
||||
(defmethod read-action-opts :navigate
|
||||
[interaction-src]
|
||||
(select-keys interaction-src [:destination]))
|
||||
(select-keys interaction-src [:destination
|
||||
:preserve-scroll]))
|
||||
|
||||
(defmethod read-action-opts :open-overlay
|
||||
[interaction-src]
|
||||
|
@ -430,7 +431,8 @@
|
|||
(let [{:keys [event-type action-type]} (read-classifier interaction-src)
|
||||
{:keys [delay]} (read-event-opts interaction-src)
|
||||
{: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
|
||||
|
@ -443,7 +445,8 @@
|
|||
:overlay-position overlay-position
|
||||
:url url
|
||||
:close-click-outside close-click-outside
|
||||
:background-overlay background-overlay})))]
|
||||
:background-overlay background-overlay
|
||||
:preserve-scroll preserve-scroll})))]
|
||||
(commit-change
|
||||
file
|
||||
{:type :mod-obj
|
||||
|
|
|
@ -64,11 +64,13 @@
|
|||
(s/def ::url ::us/string)
|
||||
(s/def ::close-click-outside ::us/boolean)
|
||||
(s/def ::background-overlay ::us/boolean)
|
||||
(s/def ::preserve-scroll ::us/boolean)
|
||||
|
||||
(defmulti action-opts-spec :action-type)
|
||||
|
||||
(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 [_]
|
||||
(s/keys :req-un [::destination
|
||||
|
@ -151,7 +153,8 @@
|
|||
:navigate
|
||||
(assoc interaction
|
||||
:action-type action-type
|
||||
:destination (get interaction :destination))
|
||||
:destination (get interaction :destination)
|
||||
:preserve-scroll false)
|
||||
|
||||
(:open-overlay :toggle-overlay)
|
||||
(let [overlay-pos-type (get interaction :overlay-pos-type :center)
|
||||
|
@ -196,6 +199,10 @@
|
|||
(and (has-destination interaction)
|
||||
(some? (:destination interaction))))
|
||||
|
||||
(defn has-preserve-scroll
|
||||
[interaction]
|
||||
(= (:action-type interaction) :navigate))
|
||||
|
||||
(defn set-destination
|
||||
[interaction destination]
|
||||
(us/verify ::interaction interaction)
|
||||
|
@ -210,6 +217,13 @@
|
|||
(assoc :overlay-pos-type :center
|
||||
: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
|
||||
[interaction]
|
||||
(= (:action-type interaction) :open-url))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue