When using loadAnimation, you can pass a rendererSettings object to fine-tune the renderer behavior. This is particularly useful when using the canvas renderer.
Common rendererSettings keys:
context: The canvas context (e.g., '2d'). Required if providing an existing canvas.preserveAspectRatio: Supports same options as the SVG preserveAspectRatio property (e.g., 'xMinYMin slice').title: Adds an SVG <title> element for accessibility.description: Adds an SVG <desc> element for accessibility.clearCanvas: Boolean.progressiveLoad: (SVG only) If true, loads DOM elements when needed to speed up initialization.hideOnTransparent: (SVG only) If true, hides elements when opacity reaches 0.className: CSS class to add to the renderer.id: Unique ID for the renderer.
lottie.loadAnimation({
container: element,
renderer: 'svg',
loop: true,
autoplay: true,
animationData: animationData,
rendererSettings: {
context: canvasContext,
preserveAspectRatio: 'xMinYMin slice',
title: 'Accessible Title',
description: 'Accessible description.',
clearCanvas: false,
progressiveLoad: false,
hideOnTransparent: true,
className: 'some-css-class-name',
id: 'some-id',
}
});