question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feat: custom ion-slides mutation observer

See original GitHub issue

Feature Request

Ionic version:

[x] 5.2.3

Describe the Feature Request

We’re rendering dynamic content (graphs, D3) inside a caroussel (ion-slides) which repeatedly render streamed data (once a second). This, it seems, causes ion-slides’ Mutation Observer to fire constantly and update each ion-slide. I observed that in the elements tree, each ion-slide’s attributes are updated once per second. The consequence of this behaviour is, while slowly dragging the slides, that sometimes they can jump or flicker erratically. This is really unpleasant from a UX perspective.

To find the source of that issue I had to clone and build Ionic Core manually and link it to our app. I found that the default values of Mutation Observer don’t work for us.

mut.observe(this.el, {
        childList: true,
        subtree: true
});

I mitigated the issue by changing the options object to restore the defaults.

mut.observe(this.el, { attributes: true });

Et voila, flickering/jumping disappear. A side benefit is the noticably smoother dragging performance.

Describe Preferred Solution

There are two options:

  1. Extend the ion-slides API to allow passing MutationObserverInit options from outside, e.g.
@Prop() mutationsOptions: MutationObserverInit = {
        childList: true,
        subtree: true
};
  1. Prop to tell whether have shallow observations or deep observations.
@Prop() observeChildrenDeep = false;

…

mut.observe(this.el, this.observeChildrenDeep ?  {
        childList: true,
        subtree: true
}): { attributes: true }

Feel free to find better names 😄.

Additional Context

Currently, I cannot get this to work w/o forking/linking Ionic Core because I don’t have access to the internal Mutation Observer setup.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
pixelbucket-devcommented, Jul 14, 2020

@liamdebeasi I will have to have a look how I can create a simple and abstract version of our complex solution. Won’t be easy. I will keep you posted.

0reactions
ionitron-bot[bot]commented, Feb 19, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Guide to custom React Hooks with MutationObserver
Using custom React Hooks makes it easy for developers to share projects. Learn how to use custom Hooks in React with MutationObserver.
Read more >
Mutation Observer | Can I use... Support tables for ... - CanIUse
Method for observing and reacting to changes to the DOM. Replaces MutationEvents, which is deprecated. Usage % of. all users, all tracked, tracked...
Read more >
MutationObserver - Web APIs | MDN
The MutationObserver interface provides the ability to watch for changes ... Mutation Observer & customize resize event listener & demo.
Read more >
Swiper js size - Natures Organics Shop
Swiper js size ... This guide will cover migration from the deprecated ion-slides component to the framework-specific solutions that Swiper.js provides as well...
Read more >
ED119619.pdf - ERIC
T1364.832 Ft! AT. Food preparation, Food purchasing, Food storage, Food substit- utions, ernits, Nutrition education, Vegetables.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found