Skip to content
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

State change callback #8

Open
patric-eberle opened this issue Apr 17, 2020 · 6 comments
Open

State change callback #8

patric-eberle opened this issue Apr 17, 2020 · 6 comments

Comments

@patric-eberle
Copy link

Is your feature request related to a problem? Please describe.
We use your plugin in Vue and need to update the content of the sticky element, when it becomes sticky. As far as I understand the documentation, there is currently no callback method to execute functionality, when the element becomes or stops to be sticky.

Describe the solution you'd like
There should be an option, to define a callback or bind to a custom event, to execute additional code, when the state of the sticky element changes (sticky/non-sticky).

Describe alternatives you've considered
Did not find a good one.

Additional context
In our case, we have a sidebar, that becomes sticky, once the header would cover it. In this case, some of the elements need to collapse by default in the sidebar, so it's size is reduced.

@github-actions
Copy link

Hey, thanks for filing an issue with Stickybits' first issue

@yowainwright
Copy link
Owner

@patric-eberle, thanks for your thoughtful issue.

I thought about an event system before but I realized that would/could become a mess with multiple Stickybit items. Especially for maintenance, haha.

I think a callback that happened on a Stickybit state update could be clean enough. The inheriting code could run its own checks within the callback and make updates as necessary.

Thoughts?

@patric-eberle
Copy link
Author

Yes I also think that a callback would be the better solution. In my opinion a relation to the instance may not be required but it should at least give the new state or have two events for becoming and leaving sticky mode. I don't think there is value in this. But with the callback we certainly could wire up the state change with the surrounding environment.

e.g.

stickybits("selector", {
  onChange(state) {}
});

@simplenotezy
Copy link

Ough, I need a callback handler before I can use this library, thought it was included out of the box tbh.

@yowainwright
Copy link
Owner

I'm going to get to this repo asap. 🙏

I'm sure y'all understand trying to get extra work done during this time of adversity.

@simplenotezy
Copy link

My workaround is to use IntersectionObserveer and watch for the sticky classes

Sent with GitHawk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants