diff --git a/src/renderer/document/events.cljs b/src/renderer/document/events.cljs index ea46ad82..be883ffe 100644 --- a/src/renderer/document/events.cljs +++ b/src/renderer/document/events.cljs @@ -1,7 +1,7 @@ (ns renderer.document.events (:require [clojure.edn :as edn] - [de-dupe.core :as dd] + #_[de-dupe.core :as dd] [re-frame.core :as rf] [re-frame.interceptor :refer [->interceptor get-effect get-coeffect assoc-coeffect assoc-effect]] [renderer.document.db :as db] @@ -14,8 +14,7 @@ (let [db-store-key :re-frame-path/db-store] (->interceptor :id :active-document-path - :before (fn - [context] + :before (fn [context] (let [original-db (get-coeffect context :db)] (-> context (update db-store-key conj original-db) diff --git a/src/renderer/events.cljs b/src/renderer/events.cljs index 36301f54..f6073d3d 100644 --- a/src/renderer/events.cljs +++ b/src/renderer/events.cljs @@ -1,6 +1,5 @@ (ns renderer.events (:require - [clojure.core.matrix :as mat] [malli.core :as ma] [platform] [re-frame.core :as rf] @@ -8,7 +7,8 @@ [renderer.frame.handlers :as frame-h] [renderer.handlers :as h] [renderer.tools.base :as tools] - [renderer.utils.local-storage :as local-storage])) + [renderer.utils.local-storage :as local-storage] + [renderer.utils.pointer :as pointer])) (defn check-and-throw "Throws an exception if `db` doesn't match the Spec" @@ -104,13 +104,6 @@ (fn [db [_]] (update db :snap? not))) -(defn significant-drag? - [pointer-pos pointer-offset] - (let [threshold 1] - (when (and (vector? pointer-pos) (vector? pointer-offset)) - (> (apply max (map abs (mat/sub pointer-pos pointer-offset))) - threshold)))) - (rf/reg-event-db :pointer-event (fn [{:keys [pointer-offset tool content-rect drag?] :as db} @@ -121,7 +114,7 @@ (if (= buttons :right) db (-> (if pointer-offset - (if (significant-drag? pointer-pos pointer-offset) + (if (pointer/significant-drag? pointer-pos pointer-offset) (cond-> db (not= tool :pan) (frame-h/pan-out-of-canvas content-rect diff --git a/src/renderer/utils/pointer.cljs b/src/renderer/utils/pointer.cljs index 990922ba..003fe1ef 100644 --- a/src/renderer/utils/pointer.cljs +++ b/src/renderer/utils/pointer.cljs @@ -1,5 +1,6 @@ (ns renderer.utils.pointer (:require + [clojure.core.matrix :as mat] [re-frame.core :as rf])) (defn ctrl? @@ -14,6 +15,13 @@ [e] (some #(contains? (:modifiers e) %) #{:ctrl :shift})) +(defn significant-drag? + [pointer-pos pointer-offset] + (let [threshold 1] + (when (and (vector? pointer-pos) (vector? pointer-offset)) + (> (apply max (map abs (mat/sub pointer-pos pointer-offset))) + threshold)))) + (def button "https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button" [:left