0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 23:49:45 -05:00

Fix canvas selrect selection.

This commit is contained in:
Andrey Antukh 2016-02-16 20:04:42 +02:00
parent a55d3655cf
commit 674136bcab
6 changed files with 23 additions and 17 deletions

View file

@ -120,8 +120,8 @@
;; that horrible hack.
(let [el1 (mx/get-ref-dom own "viewport-container")
el2 (mx/get-ref-dom own "workspace-canvas")]
(set! (.-scrollLeft el1) wb/document-start-scroll-x)
(set! (.-scrollLeft el2) wb/document-start-scroll-x)
(set! (.-scrollLeft el1) wb/canvas-start-scroll-x)
(set! (.-scrollLeft el2) wb/canvas-start-scroll-x)
own))
(defn- workspace-transfer-state

View file

@ -125,7 +125,7 @@
(def ^:const viewport-width 4069)
(def ^:const viewport-height 2048)
(def ^:const document-start-x 600)
(def ^:const document-start-y 30)
(def ^:const canvas-start-x 600)
(def ^:const canvas-start-y 30)
(def ^:const document-start-scroll-x 550)
(def ^:const canvas-start-scroll-x 550)

View file

@ -157,8 +157,8 @@
shapes-selected (filter (comp workspace-selected :id) shapes)
shapes-notselected (filter (comp not workspace-selected :id) shapes)]
(html
[:svg.page-canvas {:x wb/document-start-x
:y wb/document-start-y
[:svg.page-canvas {:x wb/canvas-start-x
:y wb/canvas-start-y
:ref (str "canvas" id)
:width width
:height height}

View file

@ -62,9 +62,15 @@
(letfn [(on-value [pos]
(swap! selrect-pos assoc :current pos))
(translate-selrect [selrect]
(assoc selrect
:x (- (:x selrect) wb/canvas-start-x)
:y (- (:y selrect) wb/canvas-start-y)))
(on-complete []
(let [selrect (selrect->rect @selrect-pos)]
(rs/emit! (dw/select-shapes selrect))
(let [selrect (selrect->rect @selrect-pos)
selrect' (translate-selrect selrect)]
(rs/emit! (dw/select-shapes selrect'))
(reset! selrect-pos nil)))
(init []

View file

@ -58,21 +58,21 @@
flags (rum/react wb/flags-l)
page (rum/react wb/page-l)
enabled? (contains? flags :grid)
vertical-ticks (range (- 0 wb/document-start-y)
(- (:width page) wb/document-start-y)
vertical-ticks (range (- 0 wb/canvas-start-y)
(- (:width page) wb/canvas-start-y)
step-size)
horizontal-ticks (range (- 0 wb/document-start-x)
(- (:height page) wb/document-start-x)
horizontal-ticks (range (- 0 wb/canvas-start-x)
(- (:height page) wb/canvas-start-x)
step-size)]
(html
[:g.grid
{:style {:display (if enabled? "block" "none")}}
(for [tick vertical-ticks]
(let [position (+ tick wb/document-start-x)
(let [position (+ tick wb/canvas-start-x)
line (vertical-line page position tick)]
(rum/with-key line (str "tick-" tick))))
(for [tick horizontal-ticks]
(let [position (+ tick wb/document-start-y)
(let [position (+ tick wb/canvas-start-y)
line (horizontal-line page position tick)]
(rum/with-key line (str "tick-" tick))))]))))

View file

@ -11,8 +11,8 @@
(def ^:static zoom 1)
(def ^:static step-padding 20)
(def ^:static step-size 10)
(def ^:static start-width wb/document-start-x)
(def ^:static start-height wb/document-start-y)
(def ^:static start-width wb/canvas-start-x)
(def ^:static start-height wb/canvas-start-y)
(def ^:static big-ticks-mod (/ 100 zoom))
(def ^:static mid-ticks-mod (/ 50 zoom))
(def ^:static scroll-left 0)