Last active
January 17, 2020 18:22
-
-
Save seamusv/9b12e7e0bbf8b16a4e90e1c6fa245cca to your computer and use it in GitHub Desktop.
ScalaJS facade for @n8tb1t/use-scroll-position
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ca.venasse.hooks | |
import org.scalajs.dom.html | |
import slinky.core.facade.ReactRef | |
import scala.scalajs.js | |
import scala.scalajs.js.JSConverters._ | |
import scala.scalajs.js.annotation.JSImport | |
import scala.scalajs.js.| | |
@JSImport("@n8tb1t/use-scroll-position", JSImport.Namespace) | |
@js.native | |
private[this] object UseScrollPositionRaw extends js.Object { | |
def useScrollPosition(effect: js.Function1[UseScrollPosition.ScrollProps, _], deps: js.Array[js.Any], element: ReactRef[html.Element | Null], useWindow: Boolean, wait: Int): Unit = js.native | |
} | |
object UseScrollPosition { | |
@js.native | |
sealed trait Position extends js.Object { | |
val x: Float | |
val y: Float | |
} | |
@js.native | |
sealed trait ScrollProps extends js.Object { | |
val prevPos: Position | |
val currPos: Position | |
} | |
@inline def useScrollPosition(effect: ScrollProps => Unit, deps: Iterable[Any] = Iterable.empty, element: ReactRef[html.Element | Null] = null, useWindow: Boolean = false, wait: Int = 0): Unit = | |
UseScrollPositionRaw.useScrollPosition(effect, deps.toJSArray.asInstanceOf[js.Array[js.Any]], element, useWindow, wait) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment