You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Start by installing the Embla Carousel Angular **npm package** and add it to your dependencies.
14
15
15
-
<TabsgroupId="package-manager">
16
-
<TabsItemlabel="npm"value="npm">
16
+
<TabsgroupId={TABS_PACKAGE_MANAGER.GROUP_ID}>
17
+
<TabsItemtab={TABS_PACKAGE_MANAGER.TABS.NPM}>
17
18
18
19
```shell
19
20
npm install embla-carousel-angular --save
20
21
```
21
22
22
23
</TabsItem>
23
-
<TabsItemlabel="yarn"value="yarn">
24
+
<TabsItemtab={TABS_PACKAGE_MANAGER.TABS.YARN}>
24
25
25
26
```shell
26
27
yarn add embla-carousel-angular
@@ -33,9 +34,12 @@ Start by installing the Embla Carousel Angular **npm package** and add it to you
33
34
34
35
Embla Carousel provides the handy `EmblaCarouselDirective`**standalone** directive for seamless integration with Angular. A minimal setup requires an **overflow wrapper** and a **scroll container**. Start by adding the following structure to your carousel:
The element with the classname `embla` is needed to cover the scroll overflow. Its child element with the `container` classname is the scroll body that scrolls the slides. Continue by adding the following **CSS** to these elements:
@@ -84,22 +88,31 @@ The element with the classname `embla` is needed to cover the scroll overflow. I
84
88
85
89
The `emblaCarousel` directive takes the Embla Carousel [options](/api/options/) as part of its inputs. Additionally, you can access the [API](/api/) by using the `@ViewChild` decorator to access the carousel in `AfterViewInit` hook。
86
90
87
-
**ATTENTION**: Calling the following embla APIs directly will trigger too much ChangeDetection, which will lead to serious performance issues.
91
+
<Admonitiontype="warning">
92
+
**Warning**: Calling the following embla APIs directly will trigger too much
93
+
ChangeDetection, which will lead to serious performance issues.
94
+
95
+
<br />
88
96
89
97
-`emblaApi.on()`
90
98
-`emblaApi.scrollNext()`
91
99
-`emblaApi.scrollPrev()`
92
100
-`emblaApi.scrollTo()`
93
101
102
+
</Admonition>
103
+
94
104
Consider using the following methods which are wrapped with `ngZone.runOutsideAngular()`:
The `emblaCarousel` directive also provides a custom event: `emblaChange` that forwards embla events, also wrapped in `ngZone.runOutsideAngular`. You need to listen by passing the specified event names into `subscribeToEvents` input on demand.
0 commit comments