mirror of
https://github.com/typeable/elm-ui.git
synced 2024-11-23 01:50:11 +03:00
compare numbers by rounding || flooring
This commit is contained in:
parent
43f03783bb
commit
79df3d1eff
@ -1040,6 +1040,10 @@ onLeft element =
|
||||
}
|
||||
|
||||
|
||||
compare x vs y =
|
||||
vs (round x) (round y) || vs (floor x) (floor y)
|
||||
|
||||
|
||||
{-| -}
|
||||
inFront : Testable.Element msg -> Testable.Attr msg
|
||||
inFront element =
|
||||
@ -1048,79 +1052,51 @@ inFront element =
|
||||
, element = element
|
||||
, label = "inFront"
|
||||
, test =
|
||||
\found _ ->
|
||||
let
|
||||
horizontalCheck =
|
||||
if found.self.bbox.width > found.parent.bbox.width then
|
||||
[ (found.self.bbox.right <= found.parent.bbox.right)
|
||||
|| (found.self.bbox.left >= found.parent.bbox.left)
|
||||
]
|
||||
|
||||
else
|
||||
[ found.self.bbox.right <= found.parent.bbox.right
|
||||
, found.self.bbox.left >= found.parent.bbox.left
|
||||
]
|
||||
|
||||
verticalCheck =
|
||||
if found.self.bbox.width > found.parent.bbox.width then
|
||||
[ (found.self.bbox.top >= found.parent.bbox.top)
|
||||
|| (found.self.bbox.bottom <= found.parent.bbox.bottom)
|
||||
]
|
||||
|
||||
else
|
||||
[ found.self.bbox.top >= found.parent.bbox.top
|
||||
, found.self.bbox.bottom <= found.parent.bbox.bottom
|
||||
]
|
||||
in
|
||||
Expect.true "within the confines of the parent"
|
||||
(List.all ((==) True)
|
||||
(List.concat
|
||||
[ horizontalCheck
|
||||
, verticalCheck
|
||||
]
|
||||
)
|
||||
)
|
||||
withinHelper
|
||||
}
|
||||
|
||||
|
||||
withinHelper found _ =
|
||||
let
|
||||
horizontalCheck =
|
||||
if found.self.bbox.width > found.parent.bbox.width then
|
||||
[ compare found.self.bbox.right (<=) found.parent.bbox.right
|
||||
|| compare found.self.bbox.left (>=) found.parent.bbox.left
|
||||
]
|
||||
|
||||
else
|
||||
[ compare found.self.bbox.right (<=) found.parent.bbox.right
|
||||
, compare found.self.bbox.left (>=) found.parent.bbox.left
|
||||
]
|
||||
|
||||
verticalCheck =
|
||||
if found.self.bbox.width > found.parent.bbox.width then
|
||||
[ compare found.self.bbox.top (>=) found.parent.bbox.top
|
||||
|| compare found.self.bbox.bottom (<=) found.parent.bbox.bottom
|
||||
]
|
||||
|
||||
else
|
||||
[ compare found.self.bbox.top (>=) found.parent.bbox.top
|
||||
, compare found.self.bbox.bottom (<=) found.parent.bbox.bottom
|
||||
]
|
||||
in
|
||||
Expect.true "within the confines of the parent"
|
||||
(List.all ((==) True)
|
||||
(List.concat
|
||||
[ horizontalCheck
|
||||
, verticalCheck
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
{-| -}
|
||||
behindContent : Testable.Element msg -> Testable.Attr msg
|
||||
behindContent element =
|
||||
Testable.Nearby
|
||||
{ location = Testable.Behind
|
||||
, element = element
|
||||
, label = "behind"
|
||||
, label = "behindContent"
|
||||
, test =
|
||||
\found _ ->
|
||||
let
|
||||
horizontalCheck =
|
||||
if found.self.bbox.width > found.parent.bbox.width then
|
||||
[ (found.self.bbox.right <= found.parent.bbox.right)
|
||||
|| (found.self.bbox.left >= found.parent.bbox.left)
|
||||
]
|
||||
|
||||
else
|
||||
[ found.self.bbox.right <= found.parent.bbox.right
|
||||
, found.self.bbox.left >= found.parent.bbox.left
|
||||
]
|
||||
|
||||
verticalCheck =
|
||||
if found.self.bbox.width > found.parent.bbox.width then
|
||||
[ (found.self.bbox.top >= found.parent.bbox.top)
|
||||
|| (found.self.bbox.bottom <= found.parent.bbox.bottom)
|
||||
]
|
||||
|
||||
else
|
||||
[ found.self.bbox.top >= found.parent.bbox.top
|
||||
, found.self.bbox.bottom <= found.parent.bbox.bottom
|
||||
]
|
||||
in
|
||||
Expect.true "within the confines of the parent"
|
||||
(List.all ((==) True)
|
||||
(List.concat
|
||||
[ horizontalCheck
|
||||
, verticalCheck
|
||||
]
|
||||
)
|
||||
)
|
||||
withinHelper
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user