{-|
Copyright   : Written by David Himmelstrup
License     : Unlicense
Maintainer  : lemmih@gmail.com
Stability   : experimental
Portability : POSIX
-}
module Reanimate.Builtin.Slide where

import           Reanimate.Constants  (screenHeight, screenWidth)
import           Reanimate.Effect     (constE, translateE)
import           Reanimate.Svg        (translate)
import           Reanimate.Transition (Transition, effectT)

-- | <<docs/gifs/doc_slideLeftT.gif>>
slideLeftT :: Transition
slideLeftT :: Transition
slideLeftT = Effect -> Effect -> Transition
effectT Effect
slideLeft (Effect -> Effect -> Effect
forall t t b c a.
(t -> t -> b -> c) -> (t -> t -> a -> b) -> t -> t -> a -> c
andE Effect
slideLeft Effect
moveRight)
  where
    slideLeft :: Effect
slideLeft = Double -> Double -> Effect
translateE (-Double
forall a. Fractional a => a
screenWidth) Double
0
    moveRight :: Effect
moveRight = (Tree -> Tree) -> Effect
constE (Effect
translate Double
forall a. Fractional a => a
screenWidth Double
0)
    andE :: (t -> t -> b -> c) -> (t -> t -> a -> b) -> t -> t -> a -> c
andE t -> t -> b -> c
a t -> t -> a -> b
b t
d t
t = t -> t -> b -> c
a t
d t
t (b -> c) -> (a -> b) -> a -> c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. t -> t -> a -> b
b t
d t
t

-- | <<docs/gifs/doc_slideDownT.gif>>
slideDownT :: Transition
slideDownT :: Transition
slideDownT = Effect -> Effect -> Transition
effectT Effect
slideDown (Effect -> Effect -> Effect
forall t t b c a.
(t -> t -> b -> c) -> (t -> t -> a -> b) -> t -> t -> a -> c
andE Effect
slideDown Effect
moveUp)
  where
    slideDown :: Effect
slideDown = Double -> Double -> Effect
translateE Double
0 (-Double
forall a. Fractional a => a
screenHeight)
    moveUp :: Effect
moveUp = (Tree -> Tree) -> Effect
constE (Effect
translate Double
0 Double
forall a. Fractional a => a
screenHeight)
    andE :: (t -> t -> b -> c) -> (t -> t -> a -> b) -> t -> t -> a -> c
andE t -> t -> b -> c
a t -> t -> a -> b
b t
d t
t = t -> t -> b -> c
a t
d t
t (b -> c) -> (a -> b) -> a -> c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. t -> t -> a -> b
b t
d t
t

-- | <<docs/gifs/doc_slideUpT.gif>>
slideUpT :: Transition
slideUpT :: Transition
slideUpT = Effect -> Effect -> Transition
effectT Effect
slideUp (Effect -> Effect -> Effect
forall t t b c a.
(t -> t -> b -> c) -> (t -> t -> a -> b) -> t -> t -> a -> c
andE Effect
slideUp Effect
moveDown)
  where
    slideUp :: Effect
slideUp = Double -> Double -> Effect
translateE Double
0 Double
forall a. Fractional a => a
screenHeight
    moveDown :: Effect
moveDown = (Tree -> Tree) -> Effect
constE (Effect
translate Double
0 (-Double
forall a. Fractional a => a
screenHeight))
    andE :: (t -> t -> b -> c) -> (t -> t -> a -> b) -> t -> t -> a -> c
andE t -> t -> b -> c
a t -> t -> a -> b
b t
d t
t = t -> t -> b -> c
a t
d t
t (b -> c) -> (a -> b) -> a -> c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. t -> t -> a -> b
b t
d t
t