From fc8f008e2d911c32f1df4838e06ccc24635faa43 Mon Sep 17 00:00:00 2001 From: Yann Esposito Date: Wed, 2 Sep 2015 16:06:01 +0200 Subject: [PATCH] slight optimization --- src/apintro/core.cljs | 7 +++++- src/apintro/message.cljs | 12 ++++++---- src/apintro/vgapi.cljs | 50 +++++++++++++++++++++------------------- 3 files changed, 39 insertions(+), 30 deletions(-) diff --git a/src/apintro/core.cljs b/src/apintro/core.cljs index dbd1f6d..166b81d 100644 --- a/src/apintro/core.cljs +++ b/src/apintro/core.cljs @@ -51,7 +51,9 @@ {:font-size (rx (str (* 10 @ease1) "vh")) :padding-top (rx (str (* 10 @ease1) "vh")) :opacity (rx (str @ease2)) + :transform (rx (str "translateX(" (* 20 @ease3 (Math/sin (* 30 @ease3))) "px) rotate(" (* 5 (Math/sin (* 30 @ease3))) "deg)")) :-webkit-transform (rx (str "translateX(" (* 20 @ease3 (Math/sin (* 30 @ease3))) "px) rotate(" (* 5 (Math/sin (* 30 @ease3))) "deg)")) + :-moz-transform (rx (str "translateX(" (* 20 @ease3 (Math/sin (* 30 @ease3))) "px) rotate(" (* 5 (Math/sin (* 30 @ease3))) "deg)")) :text-align "center" :text-shadow (str "1px 3px 0 rgba(0,0,0,0.1)") :line-height "2em" @@ -88,7 +90,10 @@ (drop 1 (clojure.string/split (gets [:vgapi :project-id]) "-"))] [:div {:style {:opacity (rx (str @ease4)) - :-webkit-filter (rx (str "blur(" (* 15 (- 1 @ease4)) "px)"))} + :-webkit-filter (rx (str "blur(" (* 15 (- 1 @ease4)) "px)")) + :-moz-filter (rx (str "blur(" (* 15 (- 1 @ease4)) "px)")) + :filter (rx (str "blur(" (* 15 (- 1 @ease4)) "px)")) + } :node/on-attached (fn [node callback] (animation/start-easing! ease4 0.0 1.0 7000 animation/quad-in callback)) } diff --git a/src/apintro/message.cljs b/src/apintro/message.cljs index c4b4995..c528258 100644 --- a/src/apintro/message.cljs +++ b/src/apintro/message.cljs @@ -157,8 +157,10 @@ } :on-click #(open (tweet-url message)) } - [user-pic {:message message}] - ; [user-name message params] - [text message] - ; [actions-holder message params] - ])) + (when (> height 2) + [:div + [user-pic {:message message}] + [user-name message params] + [text message] + [actions-holder message params]] + )])) diff --git a/src/apintro/vgapi.cljs b/src/apintro/vgapi.cljs index dfee436..0779efc 100644 --- a/src/apintro/vgapi.cljs +++ b/src/apintro/vgapi.cljs @@ -20,8 +20,8 @@ :msg "Nothing done yet."}) (def time-protection 10000) -(def time-period 10000) -(def time-period-margin 90000) +(def time-period 4000) +(def time-period-margin 15000) ;; ------------------------------------------------------------------------------ ;; Tasks @@ -105,31 +105,33 @@ [:div {:style {:text-align "left" :line-height "2em" :position "relative" - :overflow "hidden" + :right (rx (str (* @e tw-width) "vh")) :height "50vh" :font-family "Verdana, sans-serif"}} - (for [tweet-sec (keys tweets-by-sec)] - [:div {:style {:position "absolute" - :bottom "0" - :right (rx - (str (- (* (- (/ (- (:pub_date_epoch_ms tweet-sec) (- time-period) from) - 1000) @e ) tw-width)) "vh")) - :width (str tw-width "vh") - } - } - (for [tweet (get tweets-by-sec tweet-sec)] - [message tweet vh-height ]) + (for [tweet-sec (sort-by :pub_date_epoch_ms (keys tweets-by-sec))] + (let [decalage (- + (/ (+ time-period + (- (:pub_date_epoch_ms tweet-sec) + from)) + 1000))] + [:div {:style {:position "absolute" + :bottom "0" + :right (str (* decalage tw-width) "vh") + :width (str tw-width "vh") + } + } + (for [tweet (get tweets-by-sec tweet-sec)] + [message tweet vh-height]) - [:div {:style {:font-size ".5em" - :text-align "center" - :border 0 - :padding 0 - :margin 0 - :line-height "1.5em" - :text-shadow "0 0 2px rgba(0,0,0,0.5)" - :width "100%"}} (clojure.string/replace (.toISOString (js/Date. (:pub_date_epoch_ms tweet-sec))) - #".*T(.*)\....Z" "$1")] - ])]))) + [:div {:style {:font-size ".5em" + :text-align "center" + :border 0 + :padding 0 + :margin 0 + :line-height "1.5em" + :text-shadow "0 0 2px rgba(0,0,0,0.5)" + :width "100%"}} (clojure.string/replace (.toISOString (js/Date. (:pub_date_epoch_ms tweet-sec))) + #".*T(.*)\....Z" "$1")]]))]))) (defn view-volume [state] [:div