mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-09-30 08:38:22 +00:00
Replace js code with proper elm using elm-scroll package
This commit is contained in:
@@ -13,6 +13,7 @@ module Page.Home.Data exposing
|
||||
import Api
|
||||
import Api.Model.ItemLightList exposing (ItemLightList)
|
||||
import Api.Model.ItemSearch
|
||||
import Browser.Dom as Dom
|
||||
import Comp.FixedDropdown
|
||||
import Comp.ItemCardList
|
||||
import Comp.SearchMenu
|
||||
@@ -95,6 +96,7 @@ type Msg
|
||||
| SearchTypeMsg (Comp.FixedDropdown.Msg SearchType)
|
||||
| KeyUpMsg (Maybe KeyCode)
|
||||
| SetContentOnly String
|
||||
| ScrollResult (Result Dom.Error ())
|
||||
|
||||
|
||||
type SearchType
|
||||
|
@@ -8,7 +8,8 @@ import Data.Flags exposing (Flags)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Page exposing (Page(..))
|
||||
import Page.Home.Data exposing (..)
|
||||
import Ports
|
||||
import Scroll
|
||||
import Task
|
||||
import Throttle
|
||||
import Time
|
||||
import Util.Html exposing (KeyCode(..))
|
||||
@@ -221,6 +222,9 @@ update mId key flags settings msg model =
|
||||
KeyUpMsg _ ->
|
||||
withSub ( model, Cmd.none )
|
||||
|
||||
ScrollResult res ->
|
||||
withSub ( model, Cmd.none )
|
||||
|
||||
|
||||
|
||||
--- Helpers
|
||||
@@ -228,9 +232,13 @@ update mId key flags settings msg model =
|
||||
|
||||
scrollToCard : Maybe String -> Model -> ( Model, Cmd Msg, Sub Msg )
|
||||
scrollToCard mId model =
|
||||
let
|
||||
scroll id =
|
||||
Scroll.scroll id 0.5 0.5 0.5 0.5
|
||||
in
|
||||
case mId of
|
||||
Just id ->
|
||||
( model, Ports.scrollToElem ( id, 0 ), Sub.none )
|
||||
( model, Task.attempt ScrollResult (scroll id), Sub.none )
|
||||
|
||||
Nothing ->
|
||||
( model, Cmd.none, Sub.none )
|
||||
|
Reference in New Issue
Block a user