         displacement (subtract-vec pos camera-pos)
         r (scaled-distance-from-camera state pos)
         projected-r (project-displacement r)]
-    (add-vec view-center (scalar-multiply displacement
-                                        (/ projected-r r)))))
+      (add-vec view-center
+            (vec-clamp-to-bounds (scalar-multiply displacement (/ projected-r r)) view-center))))
 
 (defn project-radius [t]
-    (+ min-radius (* (- max-radius min-radius)
-                     (min 1 (/ 1 (.pow js/Math 2 (* 2 (- t 0.25))))))))
+  (+ min-radius (* (- max-radius min-radius)
+                   (min 1 (/ 1 (.pow js/Math 2 (* 2 (- t 0.25))))))))
 
 (defn view-radius [state pos]
   (let [r (scaled-distance-from-camera state pos)]

    (/ (vec-distance (:camera-pos state) pos) corner-distance)))

(defn elliptic-distance-from-camera [state pos]
  (let [{:keys [view-size camera-pos]} state
        rx (/ (:x view-size) 2)
        ry (/ (:y view-size) 2)

  (scalar-multiply v (/ l (vec-length v))))

(def vec-distance (comp vec-length subtract-vec))

(defn vec-clamp-to-bounds [v bounds]
  (let [ratios (merge-with (comp js/Math.abs /) bounds v)
        max-ratio (min 1 (:x ratios) (:y ratios))]
    (scalar-multiply v max-ratio)))

;; D3 magic

