SHOW:
|
|
- or go back to the newest paste.
| 1 | (let [start-xy-chan (om/get-state owner :start-xy-chan) | |
| 2 | - | change-xy-chan (om/get-state owner :change-xy-chan) |
| 2 | + | change-xy-chan (om/get-state owner :change-xy-chan) |
| 3 | - | end-xy-chan (om/get-state owner :end-xy-chan)] |
| 3 | + | end-xy-chan (om/get-state owner :end-xy-chan)] |
| 4 | (go | |
| 5 | (loop [] | |
| 6 | (let [[x0 y0] (<! start-xy-chan)] | |
| 7 | (loop [] | |
| 8 | (let [[[x1 y1] ch] (alts! [change-xy-chan end-xy-chan]) | |
| 9 | dx (- x0 x1) | |
| 10 | dy (- y0 y1)] | |
| 11 | (om/transact! app | |
| 12 | (fn [{:keys [currentUser] :as all}]
| |
| 13 | (update-in all [:users currentUser :position] | |
| 14 | - | (let [scale (get-in all [:users currentUser :zoom])] |
| 14 | + | (let [zoom (get-in all [:users currentUser :zoom])] |
| 15 | (fn [[x y]] | |
| 16 | - | [(+ x (/ dx scale)) (+ y (/ dy scale))])))))) |
| 16 | + | [(+ x (/ dx zoom)) (+ y (/ dy zoom))])))))) |
| 17 | (if (= ch change-xy-chan) | |
| 18 | (recur)))) | |
| 19 | (recur)))) |