0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-04 13:29:14 -05:00

Add grab icon on scroll is performed on workspace.

This commit is contained in:
Andrey Antukh 2016-02-18 19:03:11 +02:00
parent 5ce3812e8b
commit 3827ecb5b7
3 changed files with 20 additions and 10 deletions

View file

@ -7,6 +7,10 @@
padding: 0 230px 0 230px; padding: 0 230px 0 230px;
position: relative; position: relative;
&.scrolling {
cursor: grab;
}
&.no-tool-bar-right { &.no-tool-bar-right {
padding-right: 0; padding-right: 0;
} }

View file

@ -61,9 +61,11 @@
left-sidebar? (not (empty? (keep flags [:layers :sitemap]))) left-sidebar? (not (empty? (keep flags [:layers :sitemap])))
right-sidebar? (not (empty? (keep flags [:icons :drawtools right-sidebar? (not (empty? (keep flags [:icons :drawtools
:element-options]))) :element-options])))
local (:rum/local own)
classes (classnames classes (classnames
:no-tool-bar-right (not right-sidebar?) :no-tool-bar-right (not right-sidebar?)
:no-tool-bar-left (not left-sidebar?))] :no-tool-bar-left (not left-sidebar?)
:scrolling (:scrolling @local false))]
(html (html
[:div [:div
(header) (header)
@ -80,20 +82,17 @@
(horizontal-rule) (horizontal-rule)
(vertical-rule) (vertical-rule)
(coordinates) #_(coordinates)
;; Canvas ;; Canvas
[:section.workspace-canvas {:class classes [:section.workspace-canvas {:ref "workspace-canvas"}
:ref "workspace-canvas"}
(viewport)]] (viewport)]]
(colorpalette) (colorpalette)
;; Aside ;; Aside
(when left-sidebar? (when left-sidebar?
(left-sidebar)) (left-sidebar))
(when right-sidebar? (when right-sidebar?
(right-sidebar)) (right-sidebar))
]]))) ]])))
@ -110,12 +109,18 @@
(let [stoper (->> wb/interactions-b (let [stoper (->> wb/interactions-b
(rx/filter #(not= % :scroll/viewport)) (rx/filter #(not= % :scroll/viewport))
(rx/take 1)) (rx/take 1))
local (:rum/local own)
initial @wb/mouse-viewport-a] initial @wb/mouse-viewport-a]
(swap! local assoc :scrolling true)
(as-> wb/mouse-viewport-s $ (as-> wb/mouse-viewport-s $
(rx/take-until stoper $) (rx/take-until stoper $)
(rx/subscribe $ #(handle-scroll % initial))))) (rx/subscribe $ #(on-scroll % initial) nil on-scroll-end))))
(handle-scroll [pt initial] (on-scroll-end []
(let [local (:rum/local own)]
(swap! local assoc :scrolling false)))
(on-scroll [pt initial]
(let [{:keys [x y]} (gpt/subtract pt initial) (let [{:keys [x y]} (gpt/subtract pt initial)
el (mx/get-ref-dom own "workspace-canvas") el (mx/get-ref-dom own "workspace-canvas")
cx (.-scrollLeft el) cx (.-scrollLeft el)
@ -152,4 +157,5 @@
:will-unmount workspace-will-unmount :will-unmount workspace-will-unmount
:did-mount workspace-did-mount :did-mount workspace-did-mount
:name "workspace" :name "workspace"
:mixins [mx/static rum/reactive wshortcuts/mixin]})) :mixins [mx/static rum/reactive wshortcuts/mixin
(mx/local)]}))

View file

@ -123,7 +123,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def ^:const viewport-width 4000) (def ^:const viewport-width 4000)
(def ^:const viewport-height 2000) (def ^:const viewport-height 4000)
(def ^:const canvas-start-x 600) (def ^:const canvas-start-x 600)
(def ^:const canvas-start-y 600) (def ^:const canvas-start-y 600)