-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/pass through drag callbacks (#161)
* renamed onDragStart and onDragEnd These names were misleading. They are not related in any way to React’s event types. * allow event propagation Not sure why we are stopping event propagation in the slider tray. We should allow events to bubble up to maximize configurability for Pure React Carousel consumers. Commenting out for now, will remove completely if no bugs arise from this change. * Created Example 11 Created a new example carousel to demonstrait how to pass events to the Slider tray element. * fix incorrect value for preserveAspectRatio * removing commented-out code * added “missing” prop types * forgot to update tests with fakeOnDragMove, End * rename onDragStart to fakeOnDragStart
- Loading branch information
1 parent
d4ca2da
commit fe25e75
Showing
6 changed files
with
241 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
import React from 'react'; | ||
import { | ||
ButtonBack, | ||
ButtonFirst, | ||
ButtonLast, | ||
ButtonNext, | ||
CarouselProvider, | ||
DotGroup, | ||
Image, | ||
Slide, | ||
Slider, | ||
} from '../../..'; | ||
|
||
import s from '../../style.scss'; | ||
|
||
function eventLogger(ev) { | ||
// eslint-disable-next-line no-console | ||
console.log(ev.type, ev.target); | ||
} | ||
|
||
export default () => ( | ||
<CarouselProvider | ||
visibleSlides={2} | ||
totalSlides={6} | ||
naturalSlideWidth={400} | ||
naturalSlideHeight={500} | ||
> | ||
<h2 className={s.headline}>Carousel with custom event handlers.</h2> | ||
<p> | ||
Simple carousel with custom event handlers attachet to the | ||
{' '} | ||
<code><Slider /></code> | ||
{' '} | ||
component's | ||
{' '} | ||
<code>trayProps</code> | ||
{' '} | ||
property. Open your browser devloper tools and look at | ||
the console log, then manipulate the carousel. | ||
</p> | ||
<Slider | ||
className={s.slider} | ||
trayProps={{ | ||
// clipboard events? Sure why not. | ||
onCopy: eventLogger, | ||
onCut: eventLogger, | ||
onPaste: eventLogger, | ||
|
||
// composition events | ||
onCompositionEnd: eventLogger, | ||
onCompositionStart: eventLogger, | ||
onCompositionUpdate: eventLogger, | ||
|
||
// keyboard events | ||
onKeyDown: eventLogger, | ||
onKeyPress: eventLogger, | ||
onKeyUp: eventLogger, | ||
|
||
// focus events, | ||
onFocus: eventLogger, | ||
onBlur: eventLogger, | ||
|
||
// form events, | ||
onChange: eventLogger, | ||
onInput: eventLogger, | ||
onInvalid: eventLogger, | ||
onSubmit: eventLogger, | ||
|
||
// mouse events | ||
onClick: eventLogger, | ||
onContextMenu: eventLogger, | ||
onDoubleClick: eventLogger, | ||
onDrag: eventLogger, | ||
onDragEnd: eventLogger, | ||
onDragEnter: eventLogger, | ||
onDragExit: eventLogger, | ||
onDragLeave: eventLogger, | ||
onDragOver: eventLogger, | ||
onDragStart: eventLogger, | ||
onDrop: eventLogger, | ||
onMouseDown: eventLogger, | ||
onMouseEnter: eventLogger, | ||
onMouseLeave: eventLogger, | ||
// onMouseMove: eventLogger, | ||
onMouseOut: eventLogger, | ||
onMouseOver: eventLogger, | ||
onMouseUp: eventLogger, | ||
|
||
// touch events | ||
onTouchCancel: eventLogger, | ||
onTouchEnd: eventLogger, | ||
// onTouchMove: eventLogger, | ||
onTouchStart: eventLogger, | ||
|
||
// pointer events | ||
onPointerDown: eventLogger, | ||
// onPointerMove: eventLogger, | ||
onPointerUp: eventLogger, | ||
onPointerCancel: eventLogger, | ||
onGotPointerCapture: eventLogger, | ||
onLostPointerCapture: eventLogger, | ||
onPointerEnter: eventLogger, | ||
onPointerLeave: eventLogger, | ||
onPointerOver: eventLogger, | ||
onPointerOut: eventLogger, | ||
|
||
draggable: true, | ||
}} | ||
> | ||
<Slide tag="a" index={0}> | ||
<Image src="./media/img01.jpeg" /> | ||
</Slide> | ||
<Slide tag="a" index={1}> | ||
<Image src="./media/img02.jpeg" /> | ||
</Slide> | ||
<Slide tag="a" index={2}> | ||
<Image src="./media/img03.jpeg" /> | ||
</Slide> | ||
<Slide tag="a" index={3}> | ||
<Image src="./media/img04.jpeg" /> | ||
</Slide> | ||
<Slide tag="a" index={4}> | ||
<Image src="./media/img05.jpeg" /> | ||
</Slide> | ||
<Slide tag="a" index={5}> | ||
<Image src="./media/img06.jpeg" /> | ||
</Slide> | ||
</Slider> | ||
<ButtonFirst>First</ButtonFirst> | ||
<ButtonBack>Back</ButtonBack> | ||
<ButtonNext>Next</ButtonNext> | ||
<ButtonLast>Last</ButtonLast> | ||
<DotGroup dotNumbers /> | ||
</CarouselProvider> | ||
); |
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,3 @@ | ||
import Example11 from './Example11'; | ||
|
||
export default Example11; |
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.