@@ -40,11 +40,11 @@ virtualListWithSelection :: forall t m k v. (DomBuilder t m, PostBuild t m, Mona
4040 -> (Int -> k) -- ^ Index to Key function, used to determine position of Map elements
4141 -> m (Dynamic t (Int, Int), Event t k) -- ^ A tuple containing: a 'Dynamic' of the index (based on the current scroll position) and number of items currently being rendered, and an 'Event' of the selected key
4242virtualListWithSelection heightPx rowPx maxIndex i0 setI listTag listAttrs rowTag rowAttrs itemBuilder items indexToKey = do
43− totalHeightStyle <- mapDyn (toHeightStyle . (*) rowPx) maxIndex
44− containerStyle <- mapDyn toContainer heightPx
45− viewportStyle <- mapDyn toViewport heightPx
43+ let totalHeightStyle = fmap (toHeightStyle . (*) rowPx) maxIndex
44+ containerStyle = fmap toContainer heightPx
45+ viewportStyle = fmap toViewport heightPx
4646 rec (container, sel) <- elDynAttr "div" containerStyle $ elDynAttr' "div" viewportStyle $ do
47− currentTop <- mapDyn (listWrapperStyle . fst) window
47+ let currentTop = fmap (listWrapperStyle . fst) window
4848 (_, lis) <- elDynAttr "div" totalHeightStyle $ tagWrapper listTag listAttrs currentTop $ selectViewListWithKey_ selected itemsInWindow $ \k v s -> do
4949 (li,_) <- tagWrapper rowTag rowAttrs (constDyn $ toHeightStyle rowPx) $ itemBuilder k v s
5050 return $ fmap (const k) (domEvent Click li)
@@ -59,7 +59,7 @@ virtualListWithSelection heightPx rowPx maxIndex i0 setI listTag listAttrs rowTa
5959 postBuild <- getPostBuild
6060 performEvent_ $ ffor (leftmost [setI, i0 <$ postBuild]) $ \i -> do
6161 liftIO $ setScrollTop (_element_raw container) (i * rowPx)
62− indexAndLength <- mapDyn snd window
62+ let indexAndLength = fmap snd window
6363 return (indexAndLength, sel)
6464 where
6565 toStyleAttr m = "style" =: Map.foldWithKey (\k v s -> k <> ":" <> v <> ";" <> s) "" m
@@ -91,9 +91,9 @@ virtualList :: forall t m k v a. (DomBuilder t m, PostBuild t m, MonadHold t m,
9191 -> (k -> v -> Event t v -> m a) -- ^ The row child element builder.
9292 -> m (Dynamic t (Int, Int), Dynamic t (Map k a)) -- ^ A tuple containing: a 'Dynamic' of the index (based on the current scroll position) and number of items currently being rendered, and the 'Dynamic' list result
9393virtualList heightPx rowPx maxIndex i0 setI keyToIndex items0 itemsUpdate itemBuilder = do
94− virtualH <- mapDyn (mkVirtualHeight . (*) rowPx) maxIndex
95− containerStyle <- mapDyn mkContainer heightPx
96− viewportStyle <- mapDyn mkViewport heightPx
94+ let virtualH = fmap (mkVirtualHeight . (*) rowPx) maxIndex
95+ containerStyle = fmap mkContainer heightPx
96+ viewportStyle = fmap mkViewport heightPx
9797 pb <- getPostBuild
9898 rec (viewport, result) <- elDynAttr "div" containerStyle $ elDynAttr' "div" viewportStyle $ elDynAttr "div" virtualH $
9999 listWithKeyShallowDiff items0 itemsUpdate $ \k v e -> elAttr "div" (mkRow k) $ itemBuilder k v e