mirror of
https://github.com/penpot/penpot.git
synced 2026-02-12 14:42:56 +00:00
🐛 Fix lazy load intersection on dragging at the beginning
This commit is contained in:
committed by
Alonso Torres
parent
c00d512193
commit
184487f568
@@ -300,7 +300,7 @@
|
|||||||
|
|
||||||
on-drop
|
on-drop
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps id index objects expanded? selected)
|
(mf/deps id objects expanded? selected)
|
||||||
(fn [side _data]
|
(fn [side _data]
|
||||||
(let [single? (= (count selected) 1)
|
(let [single? (= (count selected) 1)
|
||||||
same? (and single? (= (first selected) id))]
|
same? (and single? (= (first selected) id))]
|
||||||
@@ -321,14 +321,18 @@
|
|||||||
|
|
||||||
[parent-id _] (ctn/find-valid-parent-and-frame-ids parent-id objects (map #(get objects %) selected) false files)
|
[parent-id _] (ctn/find-valid-parent-and-frame-ids parent-id objects (map #(get objects %) selected) false files)
|
||||||
|
|
||||||
parent (get objects parent-id)
|
parent (get objects parent-id)
|
||||||
|
current-index (d/index-of (:shapes parent) id)
|
||||||
|
|
||||||
to-index (cond
|
to-index (cond
|
||||||
(= side :center) 0
|
(= side :center) 0
|
||||||
(and expanded? (= side :bot) (d/not-empty? (:shapes shape))) (count (:shapes parent))
|
(and expanded? (= side :bot) (d/not-empty? (:shapes shape))) (count (:shapes parent))
|
||||||
(= side :top) (inc index)
|
;; target not found in parent (while lazy loading)
|
||||||
:else index)]
|
(neg? current-index) nil
|
||||||
(st/emit! (dw/relocate-selected-shapes parent-id to-index)))))))
|
(= side :top) (inc current-index)
|
||||||
|
:else current-index)]
|
||||||
|
(when (some? to-index)
|
||||||
|
(st/emit! (dw/relocate-selected-shapes parent-id to-index))))))))
|
||||||
|
|
||||||
on-hold
|
on-hold
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
@@ -417,11 +421,7 @@
|
|||||||
current @children-count*
|
current @children-count*
|
||||||
new-count (min total (max current chunk-size min-count))]
|
new-count (min total (max current chunk-size min-count))]
|
||||||
(reset! children-count* new-count))
|
(reset! children-count* new-count))
|
||||||
(reset! children-count* 0)))
|
(reset! children-count* 0))))
|
||||||
(fn []
|
|
||||||
(when-let [obs ^js @observer-var]
|
|
||||||
(.disconnect obs)
|
|
||||||
(reset! observer-var nil))))
|
|
||||||
|
|
||||||
;; Re-observe sentinel whenever children-count changes (sentinel moves)
|
;; Re-observe sentinel whenever children-count changes (sentinel moves)
|
||||||
;; and (shapes item) to reconnect observer after shape changes
|
;; and (shapes item) to reconnect observer after shape changes
|
||||||
@@ -502,4 +502,4 @@
|
|||||||
:component-child? component-tree?}])))
|
:component-child? component-tree?}])))
|
||||||
(when (< children-count (count (:shapes item)))
|
(when (< children-count (count (:shapes item)))
|
||||||
[:div {:ref lazy-ref
|
[:div {:ref lazy-ref
|
||||||
:style {:min-height 1}}])])]))
|
:class (stl/css :lazy-load-sentinel)}])])]))
|
||||||
|
|||||||
@@ -298,3 +298,7 @@
|
|||||||
.filtered {
|
.filtered {
|
||||||
min-inline-size: $sz-12;
|
min-inline-size: $sz-12;
|
||||||
}
|
}
|
||||||
|
.lazy-load-sentinel {
|
||||||
|
min-height: 1px;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|||||||
@@ -521,8 +521,7 @@
|
|||||||
[:& filters-tree {:objects filtered-objects
|
[:& filters-tree {:objects filtered-objects
|
||||||
:key (dm/str (:id page))
|
:key (dm/str (:id page))
|
||||||
:parent-size size-parent}]
|
:parent-size size-parent}]
|
||||||
[:div {:ref lazy-load-ref
|
[:div {:ref lazy-load-ref}]]
|
||||||
:style {:min-height 16}}]]
|
|
||||||
[:div {:on-scroll on-scroll
|
[:div {:on-scroll on-scroll
|
||||||
:class (stl/css :tool-window-content)
|
:class (stl/css :tool-window-content)
|
||||||
:data-scroll-container true
|
:data-scroll-container true
|
||||||
|
|||||||
Reference in New Issue
Block a user