mirror of
https://github.com/penpot/penpot.git
synced 2025-02-13 10:38:13 -05:00
Make coords indicator on workspace header aware of zoom.
This commit is contained in:
parent
574d78871a
commit
55dfbd73e5
3 changed files with 16 additions and 12 deletions
|
@ -156,7 +156,7 @@
|
|||
height: 30px;
|
||||
margin: 0 $small;
|
||||
position: relative;
|
||||
width: 50px;
|
||||
width: 60px;
|
||||
|
||||
&.zoom-input {
|
||||
width: 85px;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
[uxbox.ui.navigation :as nav]
|
||||
[uxbox.ui.mixins :as mx]
|
||||
[uxbox.ui.lightbox :as lightbox]
|
||||
[uxbox.util.geom.point :as gpt]
|
||||
[uxbox.util.math :as mth]))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
@ -29,11 +30,16 @@
|
|||
|
||||
(defn- coordenates-render
|
||||
[own]
|
||||
(when-let [{:keys [x y]} (rum/react wb/mouse-canvas-a)]
|
||||
(let [zoom (rum/react wb/zoom-l)
|
||||
coords (some-> (rum/react wb/mouse-canvas-a)
|
||||
(gpt/divide zoom)
|
||||
(gpt/round 1))]
|
||||
(html
|
||||
[:ul.options-view
|
||||
[:li.coordinates {:alt "x"} "X: " x]
|
||||
[:li.coordinates {:alt "y"} "Y: " y]
|
||||
[:li.coordinates {:alt "x"}
|
||||
(str "X: " (:x coords "-"))]
|
||||
[:li.coordinates {:alt "y"}
|
||||
(str "Y: " (:y coords "-"))]
|
||||
[:li.zoom-input
|
||||
[:span.add-zoom "+"]
|
||||
[:span "100%"]
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com>
|
||||
|
||||
(ns uxbox.util.geom.point
|
||||
(:refer-clojure :exclude [divide])
|
||||
(:require [uxbox.util.math :as mth]))
|
||||
|
||||
(defrecord Point [x y])
|
||||
|
@ -152,11 +153,8 @@
|
|||
(if (>= y 0) 1 4)
|
||||
(if (>= y 0) 2 3)))
|
||||
|
||||
(defn transform-point
|
||||
[pt mx]
|
||||
(Point. (+ (* (:x pt) (:a mx))
|
||||
(* (:y pt) (:c mx))
|
||||
(:tx mx))
|
||||
(+ (* (:x pt) (:b mx))
|
||||
(* (:y pt) (:d mx))
|
||||
(:ty mx))))
|
||||
(defn round
|
||||
"Change the precision of the point coordinates."
|
||||
[{:keys [x y]} decimanls]
|
||||
(Point. (mth/precision x decimanls)
|
||||
(mth/precision y decimanls)))
|
||||
|
|
Loading…
Add table
Reference in a new issue