Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also store pixel position in state.mousePosition #1211

Merged
merged 2 commits into from
Nov 15, 2016

Conversation

manisandro
Copy link
Contributor

Useful i.e. to display a hover tooltip in an "on-the-fly" identify mode.

@simboss simboss added the ready label Oct 26, 2016
Copy link
Contributor

@mbarto mbarto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests

@@ -268,7 +268,8 @@ let LeafletMap = React.createClass({
this.props.onMouseMove({
x: pos.lng,
y: pos.lat,
crs: "EPSG:4326"
crs: "EPSG:4326",
pixel: event.containerPoint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would copy coordinates also in this case, instead of storing Leaflet objects

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I also change other places in the leaflet/Map.jsx which use event.containerPoint (and even event.latlng), i.e. in the singleclick or contextmenu handlers?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be useful, but only if it doesn't take you too much time

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the smaller part, the bigger part is figuring out how to write a useful test about this ;)

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.009%) to 79.722% when pulling c517f9f on sourcepole:mousepos_pixel into baaa7d4 on geosolutions-it:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 79.731% when pulling 83d6ad3 on sourcepole:mousepos_pixel into baaa7d4 on geosolutions-it:master.

@manisandro
Copy link
Contributor Author

I haven't found a way to add a sensible test for this. I suppose a proper test would be simulating a mouse move event and checking that the i.e. mouseMove event handler gets called with object one expects. However I can't find a way to simulate a mousemove event, below does not work:

it('check that mouse position information is stored on mouse move', () => {
    const testHandlers = {
        onMouseMove: (mousePosition) => { return mousePosition; }
    };
    let spy = expect.spyOn(testHandlers, 'onMouseMove');

    const map = ReactDOM.render(
        <LeafletMap id="mymap" center={{y: 40.0, x: 10.0}} zoom={10} onMouseMove={testHandlers.onMouseMove} />,
        document.getElementById("container")
    );
    expect(map).toExist();

    ReactTestUtils.Simulate.mouseMove(document.getElementById("container"), {clientX: 0, clientY: 0, screenX: 0, screenY: 0});
    expect(spy.calls.length).toBe(1);
});

@coveralls
Copy link

Coverage Status

Coverage remained the same at 80.016% when pulling 21fe12f on sourcepole:mousepos_pixel into b5b3eb1 on geosolutions-it:master.

@mbarto mbarto merged commit 9cdec35 into geosolutions-it:master Nov 15, 2016
@manisandro manisandro deleted the mousepos_pixel branch November 16, 2016 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants