New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to update arbitrary properties #714

Closed
Fresheyeball opened this Issue Sep 18, 2016 · 6 comments

Comments

Projects
None yet
4 participants
@Fresheyeball

Fresheyeball commented Sep 18, 2016

Consider a scenario where we wish to update the scrollTop property on a Node. At the moment, I have to do this with ports and hack around querying because there is no post render hook. Its not ideal given that the data being sent is simple view logic, and views cannot issues Cmd. As it stands Attribute works well for properties exposed as attributes in the Html api, but it could as well update any arbitrary property.

Proposition for this use-case

import Html.Attributes as Attr

container at = div [ Attr.class "container", Attr.scrollTop "300px" ] [ text "wowzers" ]

Since the raw attribute function takes 2 strings, it could be possible to update any arbitrary property via 'stringly typed match'.

@process-bot

This comment has been minimized.

Show comment
Hide comment
@process-bot

process-bot Sep 18, 2016

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

process-bot commented Sep 18, 2016

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

@lukewestby

This comment has been minimized.

Show comment
Hide comment
@lukewestby

lukewestby Sep 18, 2016

Member

Html.Attributes.property will do this if you want

Html.Attributes.property "scrollTop" (Json.Encode.int 300)

You would just need to be careful with things like scrollTop on the first render since nothing will be in the DOM and setting scrollTop doesn't have any effect until the element is actually inserted.

Member

lukewestby commented Sep 18, 2016

Html.Attributes.property will do this if you want

Html.Attributes.property "scrollTop" (Json.Encode.int 300)

You would just need to be careful with things like scrollTop on the first render since nothing will be in the DOM and setting scrollTop doesn't have any effect until the element is actually inserted.

@Fresheyeball

This comment has been minimized.

Show comment
Hide comment
@Fresheyeball

Fresheyeball Sep 18, 2016

Damn, how the heck did I miss that.

Fresheyeball commented Sep 18, 2016

Damn, how the heck did I miss that.

@lukewestby

This comment has been minimized.

Show comment
Hide comment
@lukewestby

lukewestby Sep 18, 2016

Member

I forget about it all the time too, it doesn't come up super often since the built-in attribute stuff covers most use cases 😃

Member

lukewestby commented Sep 18, 2016

I forget about it all the time too, it doesn't come up super often since the built-in attribute stuff covers most use cases 😃

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Sep 19, 2016

Member

Should be done with this instead though.

Member

evancz commented Sep 19, 2016

Should be done with this instead though.

@Fresheyeball

This comment has been minimized.

Show comment
Hide comment
@Fresheyeball

Fresheyeball Sep 19, 2016

Dom querying really?
On Mon, Sep 19, 2016 at 5:52 PM Evan Czaplicki notifications@github.com
wrote:

Should be done with this
http://package.elm-lang.org/packages/elm-lang/dom/1.1.0/Dom-Scroll#toY
instead though.


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/elm-lang/core/issues/714#issuecomment-248162819, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAlL_7cUL4pBMTcI8Sr9oqAg7WqHKvKaks5qryAvgaJpZM4J_xd5
.

Fresheyeball commented Sep 19, 2016

Dom querying really?
On Mon, Sep 19, 2016 at 5:52 PM Evan Czaplicki notifications@github.com
wrote:

Should be done with this
http://package.elm-lang.org/packages/elm-lang/dom/1.1.0/Dom-Scroll#toY
instead though.


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/elm-lang/core/issues/714#issuecomment-248162819, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAlL_7cUL4pBMTcI8Sr9oqAg7WqHKvKaks5qryAvgaJpZM4J_xd5
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment