Skip to content

Commit 642c719

Browse files
committed
Remove mapChildProps option
The caller can transform the props themselves via the function that receives them.
1 parent 0dfcab4 commit 642c719

10 files changed

+2
-191
lines changed

README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ The function provided will receive the following object:
6868
}
6969
}
7070
```
71-
This structure may be customized by implementing `mapChildProps` API feature.
72-
7371
The information in `detectedEnvironment` is acquired from interaction with this component and will be unset until the first interaction.
7472

7573
## Props API
@@ -88,12 +86,6 @@ All props are optional.
8886

8987
**isEnabled** : Boolean - Enable or disable cursor position monitoring without remounting. Defaults to true.
9088

91-
**mapChildProps** : Function - Model child component props to your custom shape.
92-
Function receives one parameter with the signature
93-
`{ isActive: Boolean, isPositionOutside: Boolean, position: { x: Number, y: Number } }`.
94-
It should return an object that is compatible with the props interface of your child components.
95-
See [example demo](https://ethanselzer.github.io/react-cursor-position/#/map-child-props).
96-
9789
**onActivationChanged** : Function - Called when the component is active.
9890
Function receives one parameter with the signature `{ isActive: Boolean }`.
9991

example/public/map-child-props.html

Lines changed: 0 additions & 44 deletions
This file was deleted.

example/src/components/MapProps.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

example/src/pages/Home.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class App extends Component {
4646
<NavItem href="#/activate-by-touch">Activate by Touch</NavItem>
4747
<NavItem href="#/class-name">Class Name</NavItem>
4848
<NavItem href="#/hover-delay">Hover Delay</NavItem>
49-
<NavItem href="#/map-child-props">Map Child Props</NavItem>
5049
<NavItem href="#/detected-environment-changed">On Environment Changed</NavItem>
5150
<NavItem href="#/on-position-changed">On Position Changed</NavItem>
5251
<NavItem href="#/on-activation-changed">On Activation Changed</NavItem>

example/src/pages/MapProps.js

Lines changed: 0 additions & 73 deletions
This file was deleted.

example/src/router.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import ClassName from './pages/ClassName';
1111
import PositionChanged from './pages/PositionChanged';
1212
import Home from './pages/Home';
1313
import ImageMagnify from './pages/ImageMagnify';
14-
import MapProps from './pages/MapProps';
1514
import Style from './pages/Style';
1615
import Support from './pages/Support';
1716
import DetectedEnvironmentChanged from './pages/DetectedEnvironmentChanged';
@@ -28,7 +27,6 @@ const Routes = (props) => (
2827
<Route path="/activate-by-touch" component={ActivatedByTouch} />
2928
<Route path="/activate-by-tap" component={ActivateByTap} />
3029
<Route path="/activate-by-press" component={ActivateByPress} />
31-
<Route path="/map-child-props" component={MapProps} />
3230
<Route path="/on-position-changed" component={PositionChanged} />
3331
<Route path="/on-activation-changed" component={ActivationChanged} />
3432
<Route path="/style" component={Style} />

src/ReactCursorPosition.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ interface CursorPositionOptionsProps {
3131
className?: string;
3232
hoverDelayInMs?: number;
3333
isEnabled?: boolean;
34-
mapChildProps?: (CursorPositionGeneratedProps) => object;
3534
onActivationChanged?: ({isActive: boolean}) => void;
3635
onDetectedEnvironmentChanged?: (DetectedEnvironment) => void;
3736
onPositionChanged?: (CursorPositionGeneratedProps) => void;

src/ReactCursorPosition.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ export default class extends React.Component {
7777
hoverDelayInMs: PropTypes.number,
7878
hoverOffDelayInMs: PropTypes.number,
7979
isEnabled: PropTypes.bool,
80-
mapChildProps: PropTypes.func,
8180
onActivationChanged: PropTypes.func,
8281
onDetectedEnvironmentChanged: PropTypes.func,
8382
onPositionChanged: PropTypes.func,
@@ -95,7 +94,6 @@ export default class extends React.Component {
9594
hoverDelayInMs: 0,
9695
hoverOffDelayInMs: 0,
9796
isEnabled: true,
98-
mapChildProps: props => props,
9997
onActivationChanged: noop,
10098
onDetectedEnvironmentChanged: noop,
10199
onPositionChanged: noop,
@@ -453,10 +451,10 @@ export default class extends React.Component {
453451
}
454452

455453
render() {
456-
const { children, className, mapChildProps, style } = this.props;
454+
const { children, className, style } = this.props;
457455
const props = objectAssign(
458456
{},
459-
mapChildProps(this.state),
457+
this.state,
460458
this.getPassThroughProps()
461459
);
462460

test/ReactCursorPosition.spec.js

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -624,42 +624,6 @@ describe('ReactCursorPosition', () => {
624624
expect(tree.css('width')).toBe('100px');
625625
});
626626

627-
it('supports mapChildProps', () => {
628-
function mapChildProps({ elementDimensions, isActive, isPositionOutside, position }) {
629-
return {
630-
elementDimensions,
631-
isOperative: isActive,
632-
isAlfresco: isPositionOutside,
633-
point: position
634-
};
635-
}
636-
const tree = getMountedComponentTree({
637-
mapChildProps,
638-
activationInteractionMouse: INTERACTIONS.CLICK,
639-
activationInteractionTouch: INTERACTIONS.TOUCH
640-
});
641-
const instance = tree.instance();
642-
643-
instance.componentDidMount();
644-
instance.onTouchStart(touchEvent);
645-
instance.onTouchMove(touchEvent);
646-
tree.update();
647-
648-
const childComponent = tree.find(GenericSpanComponent);
649-
expect(childComponent.props()).toEqual({
650-
elementDimensions: {
651-
width: 4,
652-
height: 4
653-
},
654-
isOperative: true,
655-
isAlfresco: false,
656-
point: {
657-
x: 1,
658-
y: 2
659-
}
660-
});
661-
});
662-
663627
it('supports onPositionChanged callback', () => {
664628
const spy = jest.fn();
665629
const tree = getMountedComponentTree({

test/__snapshots__/ReactCursorPosition.spec.js.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Object {
77
"hoverDelayInMs": 0,
88
"hoverOffDelayInMs": 0,
99
"isEnabled": true,
10-
"mapChildProps": [Function],
1110
"onActivationChanged": [Function],
1211
"onDetectedEnvironmentChanged": [Function],
1312
"onPositionChanged": [Function],

0 commit comments

Comments
 (0)