Skip to content

Instantly share code, notes, and snippets.

@Leocardoso94
Created December 7, 2018 15:48
Show Gist options
  • Select an option

  • Save Leocardoso94/7ea466405d6f458fae4f240bbd3eaebe to your computer and use it in GitHub Desktop.

Select an option

Save Leocardoso94/7ea466405d6f458fae4f240bbd3eaebe to your computer and use it in GitHub Desktop.
(ns scroll-reveal
(:require
["scrollreveal" :as scroll-reveal]))
(defonce sr (scroll-reveal))
(defn reveal
[element options]
(.reveal sr element (clj->js options)))
;; inside a component
(defn component
[]
(let [!refs (atom {:foo nil})]
(r/create-class
{:component-did-mount
(fn []
(scroll-reveal/reveal (:foo @!refs) {:origin "left"
:distance "500px"
:duration 1000})
:reagent-render
(fn []
[:div.w-50
{:ref (fn [com]
(swap! !refs assoc :foo com))
:style {:visibility "hidden"}}
[:p "234"]]))})))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment