@@ -40,11 +40,11 @@ virtualListWithSelection :: forall t m k v. (DomBuilder t m, PostBuild t m, Mona
40 -> (Int -> k) -- ^ Index to Key function, used to determine position of Map elements
40 -> (Int -> k) -- ^ Index to Key function, used to determine position of Map elements
41 -> 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
41 -> 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
42virtualListWithSelection heightPx rowPx maxIndex i0 setI listTag listAttrs rowTag rowAttrs itemBuilder items indexToKey = do
42virtualListWithSelection heightPx rowPx maxIndex i0 setI listTag listAttrs rowTag rowAttrs itemBuilder items indexToKey = do
43− totalHeightStyle <- mapDyn (toHeightStyle . (*) rowPx) maxIndex
43+ let totalHeightStyle = fmap (toHeightStyle . (*) rowPx) maxIndex
44− containerStyle <- mapDyn toContainer heightPx
44+ containerStyle = fmap toContainer heightPx
45− viewportStyle <- mapDyn toViewport heightPx
45+ viewportStyle = fmap toViewport heightPx
46 rec (container, sel) <- elDynAttr "div" containerStyle $ elDynAttr' "div" viewportStyle $ do
46 rec (container, sel) <- elDynAttr "div" containerStyle $ elDynAttr' "div" viewportStyle $ do
47− currentTop <- mapDyn (listWrapperStyle . fst) window
47+ let currentTop = fmap (listWrapperStyle . fst) window
48 (_, lis) <- elDynAttr "div" totalHeightStyle $ tagWrapper listTag listAttrs currentTop $ selectViewListWithKey_ selected itemsInWindow $ \k v s -> do
48 (_, lis) <- elDynAttr "div" totalHeightStyle $ tagWrapper listTag listAttrs currentTop $ selectViewListWithKey_ selected itemsInWindow $ \k v s -> do
49 (li,_) <- tagWrapper rowTag rowAttrs (constDyn $ toHeightStyle rowPx) $ itemBuilder k v s
49 (li,_) <- tagWrapper rowTag rowAttrs (constDyn $ toHeightStyle rowPx) $ itemBuilder k v s
50 return $ fmap (const k) (domEvent Click li)
50 return $ fmap (const k) (domEvent Click li)
@@ -59,7 +59,7 @@ virtualListWithSelection heightPx rowPx maxIndex i0 setI listTag listAttrs rowTa
59 postBuild <- getPostBuild
59 postBuild <- getPostBuild
60 performEvent_ $ ffor (leftmost [setI, i0 <$ postBuild]) $ \i -> do
60 performEvent_ $ ffor (leftmost [setI, i0 <$ postBuild]) $ \i -> do
61 liftIO $ setScrollTop (_element_raw container) (i * rowPx)
61 liftIO $ setScrollTop (_element_raw container) (i * rowPx)
62− indexAndLength <- mapDyn snd window
62+ let indexAndLength = fmap snd window
63 return (indexAndLength, sel)
63 return (indexAndLength, sel)
65 toStyleAttr m = "style" =: Map.foldWithKey (\k v s -> k <> ":" <> v <> ";" <> s) "" m
65 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,
91 -> (k -> v -> Event t v -> m a) -- ^ The row child element builder.
91 -> (k -> v -> Event t v -> m a) -- ^ The row child element builder.
92 -> 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
92 -> 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
93virtualList heightPx rowPx maxIndex i0 setI keyToIndex items0 itemsUpdate itemBuilder = do
93virtualList heightPx rowPx maxIndex i0 setI keyToIndex items0 itemsUpdate itemBuilder = do
94− virtualH <- mapDyn (mkVirtualHeight . (*) rowPx) maxIndex
94+ let virtualH = fmap (mkVirtualHeight . (*) rowPx) maxIndex
95− containerStyle <- mapDyn mkContainer heightPx
95+ containerStyle = fmap mkContainer heightPx
96− viewportStyle <- mapDyn mkViewport heightPx
96+ viewportStyle = fmap mkViewport heightPx
97 pb <- getPostBuild
97 pb <- getPostBuild
98 rec (viewport, result) <- elDynAttr "div" containerStyle $ elDynAttr' "div" viewportStyle $ elDynAttr "div" virtualH $
98 rec (viewport, result) <- elDynAttr "div" containerStyle $ elDynAttr' "div" viewportStyle $ elDynAttr "div" virtualH $
99 listWithKeyShallowDiff items0 itemsUpdate $ \k v e -> elAttr "div" (mkRow k) $ itemBuilder k v e
99 listWithKeyShallowDiff items0 itemsUpdate $ \k v e -> elAttr "div" (mkRow k) $ itemBuilder k v e