-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: migrate the carousel to transforms (#963)
* feat: get custom scroll for mouse and update * refactor: remove drag speed * refactor: add back drag speed * feat: one scroll model * fix: clean up a bit * fix: dumb timeouts * without animateScroll$ * does transform walking * feat: correct drag direction * initial snapping * correct snapping * works with next and prev * add will change transform * custom animations except for initial load * user defined transitions work * fix: resize * mobile sorta works * smoother on mobile * fix: simplify scroller impl * narrowed down problem * mobile working * handle x, y, or z * working in an agnostic way * cleanup markup and props * get initial slide position * refactor: add comment on qvisible * feat: no flicker getting initial slide * teeny flicker but with animations * feat: no more flicker * feat: handle initial slide pos for any orientation * feat: respect transform boundaries * fix: carousel start index * fix: progress * fix: make sure there are no duplicate handler calls * fix: respect boundaries * refactor: make carousel scroller easier to understand * fix: remove the viewport from the equation * fix: smoother swiping experience * feat: sensitivity * feat: initial move impl * fix: only calculate pos when it's not the start * feat: renders correct bullets based on slides per view * feat: proper bullet navigation * feat: bullets are smart enough to know if something is in range * feat: prev and next buttons both work with move * fix: state tests * feat: initial vertical * fix: offset for vertical version * feat: vertical with transform * fix: touch start moves according to touchY in vertical * refactor: better naming * refactor: code more easy to understand * refactored names * refactor: use props map instead * fix: initial slide position vertically * fix: don't render marker points with non-scroller carousels * feat: start docs * fix: text align * docs: add example animation * feat: upgrade carousel to beta * fix: the merge issues
- Loading branch information
1 parent
f59e183
commit f1ea4f3
Showing
24 changed files
with
1,146 additions
and
635 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
apps/website/src/routes/docs/headless/carousel/examples/animate.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { component$, useStyles$ } from '@builder.io/qwik'; | ||
import { Carousel } from '@qwik-ui/headless'; | ||
|
||
export default component$(() => { | ||
useStyles$(styles); | ||
|
||
const colors = ['red', 'green', 'blue', 'yellow', 'purple', 'orange', 'pink']; | ||
|
||
return ( | ||
<Carousel.Root class="carousel-root" gap={30}> | ||
<div class="carousel-buttons"> | ||
<Carousel.Previous>Prev</Carousel.Previous> | ||
<Carousel.Next>Next</Carousel.Next> | ||
</div> | ||
<Carousel.Scroller class="carousel-scroller carousel-animation"> | ||
{colors.map((color) => ( | ||
<Carousel.Slide key={color} class="carousel-slide"> | ||
{color} | ||
</Carousel.Slide> | ||
))} | ||
</Carousel.Scroller> | ||
</Carousel.Root> | ||
); | ||
}); | ||
// internal | ||
import styles from './carousel.css?inline'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
apps/website/src/routes/docs/headless/carousel/examples/move.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { component$, useStyles$ } from '@builder.io/qwik'; | ||
import { Carousel } from '@qwik-ui/headless'; | ||
|
||
export default component$(() => { | ||
useStyles$(styles); | ||
|
||
const colors = ['red', 'green', 'blue', 'yellow', 'purple', 'orange', 'pink']; | ||
|
||
useStyles$(` | ||
.carousel-circle { | ||
width: 20px; | ||
height: 20px; | ||
margin: 0 5px; | ||
border-radius: 50%; | ||
background-color: lightgray; | ||
} | ||
.carousel-circle[data-active] { | ||
background-color: lightblue; | ||
} | ||
`); | ||
|
||
return ( | ||
<> | ||
<Carousel.Root class="carousel-root" gap={30} move={2} slidesPerView={2}> | ||
<div class="carousel-buttons"> | ||
<Carousel.Previous>Prev</Carousel.Previous> | ||
<Carousel.Next>Next</Carousel.Next> | ||
</div> | ||
<Carousel.Scroller class="carousel-scroller"> | ||
{colors.map((color) => ( | ||
<Carousel.Slide key={color} class="carousel-slide"> | ||
{color} | ||
</Carousel.Slide> | ||
))} | ||
</Carousel.Scroller> | ||
|
||
<Carousel.Pagination | ||
style={{ display: 'flex', justifyContent: 'center', marginTop: '0.5rem' }} | ||
> | ||
{colors.map((_, index) => { | ||
return ( | ||
<Carousel.Bullet key={index} class="carousel-circle"></Carousel.Bullet> | ||
); | ||
})} | ||
</Carousel.Pagination> | ||
</Carousel.Root> | ||
</> | ||
); | ||
}); | ||
// internal | ||
import styles from './carousel.css?inline'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
apps/website/src/routes/docs/headless/carousel/examples/sensitivity.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { component$, useStyles$ } from '@builder.io/qwik'; | ||
import { Carousel } from '@qwik-ui/headless'; | ||
|
||
export default component$(() => { | ||
useStyles$(styles); | ||
|
||
const colors = ['red', 'green', 'blue', 'yellow', 'purple', 'orange', 'pink']; | ||
|
||
return ( | ||
<Carousel.Root | ||
class="carousel-root" | ||
gap={30} | ||
sensitivity={{ | ||
mouse: 2.5, | ||
touch: 2.25, | ||
}} | ||
> | ||
<div class="carousel-buttons"> | ||
<Carousel.Previous>Prev</Carousel.Previous> | ||
<Carousel.Next>Next</Carousel.Next> | ||
</div> | ||
<Carousel.Scroller class="carousel-scroller"> | ||
{colors.map((color) => ( | ||
<Carousel.Slide key={color} class="carousel-slide"> | ||
{color} | ||
</Carousel.Slide> | ||
))} | ||
</Carousel.Scroller> | ||
</Carousel.Root> | ||
); | ||
}); | ||
// internal | ||
import styles from './carousel.css?inline'; |
30 changes: 30 additions & 0 deletions
30
apps/website/src/routes/docs/headless/carousel/examples/start.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { component$, useStyles$ } from '@builder.io/qwik'; | ||
import { Carousel } from '@qwik-ui/headless'; | ||
|
||
export default component$(() => { | ||
useStyles$(styles); | ||
|
||
const colors = ['red', 'green', 'blue', 'yellow', 'purple', 'orange', 'pink']; | ||
|
||
return ( | ||
<Carousel.Root class="carousel-root" gap={30}> | ||
<div class="carousel-buttons"> | ||
<Carousel.Previous>Prev</Carousel.Previous> | ||
<Carousel.Next>Next</Carousel.Next> | ||
</div> | ||
<Carousel.Scroller class="carousel-scroller"> | ||
{colors.map((color) => ( | ||
<Carousel.Slide | ||
style={{ flexBasis: '300px' }} | ||
key={color} | ||
class="carousel-slide" | ||
> | ||
{color} | ||
</Carousel.Slide> | ||
))} | ||
</Carousel.Scroller> | ||
</Carousel.Root> | ||
); | ||
}); | ||
// internal | ||
import styles from './carousel.css?inline'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.