This commit is contained in:
Yann Esposito (Yogsototh) 2015-08-31 19:18:58 +02:00
parent f81cfd763c
commit 55c21f3f49
2 changed files with 24 additions and 22 deletions

View file

@ -71,17 +71,23 @@
content content
[anchor i next-id next-text]]) [anchor i next-id next-text]])
(defn infinite-easing [e n]
(animation/start-easing! e n (+ n 1) 1000 animation/linear #(infinite-easing e (+ n 1))))
(defn ease-view [] (defn ease-view []
[:div (let [inf-ease (animation/easer 0.0)]
[page 0 "title" orange "#subtitle" "To Sub Title »" [:div {:node/on-attached (fn [a b] (infinite-easing inf-ease 0)) }
[:div [page 0 "title" orange "#subtitle" "To Sub Title »"
[animated-title (gets [:title])] [:div
[:div.project {:style {:font-family "Monaco,monospace" :opacity 0.5}} [animated-title (gets [:title])]
(gets [:vgapi :project-id])] [:div.project {:style {:font-family "Monaco,monospace" :opacity 0.5}}
(rx [vgapi/view (gets [:vgapi])]) (gets [:vgapi :project-id])]
]] (rx [vgapi/view (gets [:vgapi]) (rx @inf-ease)])
[page 1 "subtitle" green "#title" "« Back to Title" ]]
[animated-title (gets [:subtitle])]]]) [page 1 "subtitle" green "#title" "« Back to Title"
[animated-title (gets [:subtitle])]]]
)
)
(dom/mount! (.getElementById js/document "root") (ease-view)) (dom/mount! (.getElementById js/document "root") (ease-view))

View file

@ -30,7 +30,7 @@
(smart-si (smart-si
(fn [] (fn []
(go (let [now (.getTime (new js/Date)) (go (let [now (.getTime (new js/Date))
from (.toISOString (new js/Date (- now (+ (* 2 interval) (* 40 1000))))) from (.toISOString (new js/Date (- now (+ interval (* 40 1000)))))
to (.toISOString (new js/Date (- now (* 40 1000)))) to (.toISOString (new js/Date (- now (* 40 1000))))
response (<! (http/get (str "http://dev.api.vigiglo.be/api" route) response (<! (http/get (str "http://dev.api.vigiglo.be/api" route)
{:query-params (into {:project_id (gets [prefix :project-id]) {:query-params (into {:project_id (gets [prefix :project-id])
@ -88,10 +88,9 @@
;; ------------------------------------------------------------------------------ ;; ------------------------------------------------------------------------------
;; View ;; View
;; ------------------------------------------------------------------------------ ;; ------------------------------------------------------------------------------
(defn view-tweets [state] (defn view-tweets [state e]
(when (:messages state) (when (:messages state)
(let [ease (animation/easer 1.0) (let [tweets (:messages state)
tweets (:messages state)
max-sec (reduce max 0 (map :pub_date_epoch_ms tweets)) max-sec (reduce max 0 (map :pub_date_epoch_ms tweets))
tweets-by-sec (clojure.set/index (set tweets) [:pub_date_epoch_ms]) tweets-by-sec (clojure.set/index (set tweets) [:pub_date_epoch_ms])
max-nb (reduce #(max %1 (count %2)) 0 (vals tweets-by-sec)) max-nb (reduce #(max %1 (count %2)) 0 (vals tweets-by-sec))
@ -104,15 +103,13 @@
:overflow "hidden" :overflow "hidden"
:height "50vh" :height "50vh"
:border "solid 1px red" :border "solid 1px red"
:font-family "Futura, sans-serif"} :font-family "Futura, sans-serif"}}
:node/on-attached (fn [node callback] (rx e)
(animation/start-easing! ease 1.0 0.0 20000 animation/linear callback))
}
(for [tweet-sec (keys tweets-by-sec)] (for [tweet-sec (keys tweets-by-sec)]
(let [nb (/ (- max-sec (:pub_date_epoch_ms tweet-sec)) 1000)] (let [nb (/ (- max-sec (:pub_date_epoch_ms tweet-sec)) 1000)]
[:div {:style {:position "absolute" [:div {:style {:position "absolute"
:bottom "0" :bottom "0"
:left (rx (str (* (- (* 10 @ease) nb) tw-width) "vh")) :left (rx (str (* (- e nb) tw-width) "vh"))
:width (str tw-width "vh") :width (str tw-width "vh")
} }
} }
@ -127,7 +124,6 @@
[:div [:div
(str "volume: " (:volume state))]) (str "volume: " (:volume state))])
(defn view [state] (defn view [state e]
[:div [:div
[view-volume state] [view-tweets state e]])
[view-tweets state]])