[Question] Avoid redrawing entire carousel but update specific views?
See original GitHub issueOverall context: I have a PagedListEpoxyController
which displays a carousel of filters at the top, and shows the paged list below it.
I attach a listener to my filter models, so that when one is clicked, I set a selectedFilterId
on the controller and request a model build. This does work, but the UX isn’t great. It appears when it redraws each item in the carousel, it changes the padding on the ones that are selected/deselected. Gif below.
I’ve been fighting this for a little bit and tinkered with a few ideas, but I’m not sure the best approach. Do you have any suggestions?
Here is some code if that helps:
override fun addModels(models: List<EpoxyModel<*>>) {
buildFilterCarousel()
super.addModels(models)
}
// Passed in through databinding, called when a filter is "clicked"
private val filterConsumer: Consumer<Filter?> = Consumer {
// Setting this field triggers a callback which pulls for the paged list, and when that happens we request a model build.
selectedFilterId = it?.filterId
}
private fun buildFilterCarousel() {
val filterModels: List<FilterEpoxyModel> = filters?.map { filter ->
// ... Get filter ID and selected status
return@map FilterEpoxyModel()
// I had to include "selected" as part of the model ID in order for it to actually update when I call `requestModelBuild`.
.id("Filter: $filterId, selected: $selected")
.viewModel(viewModel)
.filterConsumer(filterConsumer)
}.orEmpty()
CarouselModel_()
.numViewsToShowOnScreen(3.0f)
.hasFixedSize(true)
.paddingDp(16)
.id("Filter Carousel")
.models(filterModels)
.addTo(this)
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (14 by maintainers)
Top Results From Across the Web
Efficient Matplotlib Redrawing - python - Stack Overflow
My data is drawn in the background using pcolormesh() , so when I update the canvas using axis.figure.canvas.draw() both the scatter points and...
Read more >Snapping behaviour in Epoxy Carousel and its pitfalls
The details of the behaviour: There is a selected element — one item, ... items and in a Carousel and redraw the view...
Read more >Content Jumping (and How To Avoid It) | CSS-Tricks
I would argue that shifting the page layout after the initial render (without relevant user interaction) may be the single most unpleasant user ......
Read more >Turn 'Map Redraw' off in QGIS print layout - GIS Stack Exchange
Try deactivating the checkbox Live update at the bottom of the layer panel as well. enter image description here. Share.
Read more >Issues with Safari - Smart Slider Documentation - Help Scout
Text animations are blurry. Affected browser(s), Mac Safari. Affected slider type, All. Official bug report, View. Status ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve updated the wiki pages a bit for clarity 😃
the generated databinding class is much smarter about only rebinding the data that changed, your new manual version always rebinds everything
i would guess that your
viewModel(viewModel)
attribute you are passing does not properly implement equals and hashcode to represent that the selected state changed, so epoxy doesn’t think it needs to rebind itthe general advice is this - id should not change, any data that can change on the model must be represented by attributes that correctly implement equals and hashcode. Epoxy will rebind only the data that changed when models are rebuilt