airbnb / lottie-web

Render After Effects animations natively on Web, Android and iOS, and React Native. http://airbnb.io/lottie/
MIT License
29.85k stars 2.85k forks source link

Hidden style elements are skipped, making it difficult to get to their properties #2997

Closed geomaster closed 1 year ago

geomaster commented 1 year ago

Hidden styles, e.g. ty: 'fl' and hd: true, are skipped when the element is created. This is fine, but trying to reach them afterwards via element.itemsData[0].it[i] in order to change their properties (such as color) dynamically means that the indices no longer correspond one-to-one with the original Lottie. So, one has to adjust the index to account for the styles that were skipped.

The skipping happens because of https://github.com/airbnb/lottie-web/blob/master/player/js/elements/svgElements/SVGShapeElement.js#L214.

I imagine this would affect lottie-api as well, although I haven't checked.

Would it be possible to keep them there, especially as styles have a closed property which is AFAICT already used to skip their rendering?

geomaster commented 1 year ago

Ah, I misunderstood something. This is not actually happening - the line of code I referenced does not affect the it array.

Closing.