File tree 3 files changed +23
-3
lines changed
3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change 9
9
[renderer.attribute.range]
10
10
[renderer.attribute.stroke-linecap]
11
11
[renderer.attribute.stroke-linejoin]
12
- [renderer.attribute.style]))
12
+ [renderer.attribute.style]
13
+ [renderer.attribute.transform]))
Original file line number Diff line number Diff line change
1
+ (ns renderer.attribute.transform
2
+ " https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform"
3
+ (:require
4
+ [renderer.attribute.hierarchy :as hierarchy]
5
+ [renderer.element.events :as-alias element.e]))
6
+
7
+ (defmethod hierarchy /description :transform
8
+ []
9
+ " The transform attribute defines a list of transform definitions that are
10
+ applied to an element and the element's children." )
Original file line number Diff line number Diff line change 17
17
SVG elements."
18
18
:attrs [:transform ]})
19
19
20
+ (defn- translate
21
+ [transform [x y]]
22
+ (let [g (js/document.createElementNS " http://www.w3.org/2000/svg" " g" )
23
+ _ (.setAttributeNS g nil " transform" (or transform " " ))
24
+ m (.consolidate (.. g -transform -baseVal))
25
+ matrix (if m (.-matrix m) (js/DOMMatrixReadOnly. ))
26
+ matrix (.translate matrix x y)]
27
+ (.toString matrix)))
28
+
20
29
(defmethod tool /translate :g
21
- [el [_x _y] ]
22
- el ) ; TODO
30
+ [el offset ]
31
+ ( update-in el [ :attrs :transform ] translate offset))
23
32
24
33
(defmethod tool /render :g
25
34
[{:keys [attrs children bounds] :as element}]
You can’t perform that action at this time.
0 commit comments