mirror of
https://github.com/penpot/penpot.git
synced 2025-07-16 19:35:14 +02:00
🐛 Fix origin-frame calculation
This commit is contained in:
parent
7618fcade0
commit
f736ec813e
2 changed files with 20 additions and 16 deletions
|
@ -235,7 +235,6 @@
|
||||||
viewer-section-ref (mf/use-ref nil)
|
viewer-section-ref (mf/use-ref nil)
|
||||||
|
|
||||||
current-animations (mf/deref current-animations-ref)
|
current-animations (mf/deref current-animations-ref)
|
||||||
first-animation (first (vals current-animations))
|
|
||||||
|
|
||||||
page-id (or page-id (-> file :data :pages first))
|
page-id (or page-id (-> file :data :pages first))
|
||||||
|
|
||||||
|
@ -259,8 +258,13 @@
|
||||||
scroll (mf/use-state nil)
|
scroll (mf/use-state nil)
|
||||||
|
|
||||||
orig-frame
|
orig-frame
|
||||||
(when (:orig-frame-id first-animation)
|
(mf/with-memo [current-animations]
|
||||||
(d/seek #(= (:id %) (:orig-frame-id first-animation)) frames))
|
;; We assume there can only be one animation with origin (this is used only in
|
||||||
|
;; navigation animations, and we cannot navigate to two different destinations
|
||||||
|
;; at the same time).
|
||||||
|
(let [animation-with-origin (d/seek :orig-frame-id (vals current-animations))]
|
||||||
|
(when animation-with-origin
|
||||||
|
(d/seek #(= (:id %) (:orig-frame-id animation-with-origin)) frames))))
|
||||||
|
|
||||||
size
|
size
|
||||||
(mf/with-memo [frame zoom]
|
(mf/with-memo [frame zoom]
|
||||||
|
@ -385,21 +389,21 @@
|
||||||
(wapi/exit-fullscreen))))))
|
(wapi/exit-fullscreen))))))
|
||||||
|
|
||||||
(mf/use-layout-effect
|
(mf/use-layout-effect
|
||||||
(mf/deps index)
|
(mf/deps index current-animations)
|
||||||
(fn []
|
(fn []
|
||||||
;; Navigate animation needs to be started after navigation
|
;; Navigate animation needs to be started after navigation
|
||||||
;; is complete, and we have the next page index.
|
;; is complete, and we have the next page index.
|
||||||
(when (and first-animation
|
(let [nav-animation (d/seek #(= (:kind %) :go-to-frame) (vals current-animations))]
|
||||||
(= (:kind first-animation) :go-to-frame))
|
(when nav-animation
|
||||||
(let [orig-viewport (mf/ref-val orig-viewport-ref)
|
(let [orig-viewport (mf/ref-val orig-viewport-ref)
|
||||||
current-viewport (mf/ref-val current-viewport-ref)]
|
current-viewport (mf/ref-val current-viewport-ref)]
|
||||||
(interactions/animate-go-to-frame
|
(interactions/animate-go-to-frame
|
||||||
(:animation first-animation)
|
(:animation nav-animation)
|
||||||
current-viewport
|
current-viewport
|
||||||
orig-viewport
|
orig-viewport
|
||||||
size
|
size
|
||||||
orig-size
|
orig-size
|
||||||
wrapper-size)))))
|
wrapper-size))))))
|
||||||
|
|
||||||
(mf/use-layout-effect
|
(mf/use-layout-effect
|
||||||
(mf/deps current-animations)
|
(mf/deps current-animations)
|
||||||
|
|
|
@ -69,7 +69,7 @@
|
||||||
|
|
||||||
:toggle-overlay
|
:toggle-overlay
|
||||||
(let [frame-id (:destination interaction)
|
(let [frame-id (:destination interaction)
|
||||||
dest-frame (get objects frame-id)
|
dest-frame (get objects frame-id)
|
||||||
position (ctsi/calc-overlay-position interaction
|
position (ctsi/calc-overlay-position interaction
|
||||||
base-frame
|
base-frame
|
||||||
dest-frame
|
dest-frame
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue