Change drag component to instantiate on enter the viewport

This commit is contained in:
alonso.torres 2024-01-30 14:55:55 +01:00
parent f75da999dc
commit 497b581576
9 changed files with 121 additions and 67 deletions

View file

@ -62,6 +62,13 @@
(.setData dt data-type data))
e)))
(defn invisible-image
[]
(let [img (js/Image.)
imd "data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="]
(set! (.-src img) imd)
img))
(defn set-drag-image!
([e image]
(set-drag-image! e image 0 0))
@ -108,11 +115,13 @@
([e]
(get-data e "penpot/data"))
([e data-type]
(let [dt (.-dataTransfer e)]
(if (or (str/starts-with? data-type "penpot")
(= data-type "application/json"))
(t/decode-str (.getData dt data-type))
(.getData dt data-type)))))
(let [dt (.-dataTransfer e)
data (.getData dt data-type)]
(cond-> data
(and (some? data) (not= data "")
(or (str/starts-with? data-type "penpot")
(= data-type "application/json")))
(t/decode-str)))))
(defn get-files
[e]

View file

@ -8,7 +8,7 @@
(:require
[beicon.v2.core :as rx]))
(defn- throttle-fn
(defn throttle-fn
[delay f]
(let [state
#js {:lastExecTime 0