Created
February 27, 2019 12:21
-
-
Save safareli/af035dcbbab8abfb519a70e77e654110 to your computer and use it in GitHub Desktop.
performs delay untill next animation frame using requestAnimationFrame
This file contains 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
-- | performs delay untill next animation frame. | |
untilNextAnimationFrame :: Aff Unit | |
untilNextAnimationFrame = do | |
var <- AVar.empty | |
w <- liftEffect $ window | |
Aff.bracket | |
(liftEffect $ requestAnimationFrame (launchAff_ $ AVar.put unit var) w) | |
(\requestAnimationFrameId -> liftEffect $ cancelAnimationFrame requestAnimationFrameId w) | |
(\_ -> AVar.take var) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment