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

Feature request: defaultBrushArea="move" #1435

Merged
merged 3 commits into from
Nov 8, 2019

Conversation

Hypnosphi
Copy link
Contributor

I find it quite convenient to move the selected area without changing the zoom by just clicking at the desired location, like with scrollbars

Kapture 2019-11-06 at 16 52 56

const parentSVG = restProps.parentSVG || Selection.getParentSVG(evt);
const pannedBox = this.panBox(
{
...restProps,
Copy link
Contributor

@boygirl boygirl Nov 7, 2019

Choose a reason for hiding this comment

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

You can avoid a second call to this.getDomainBox, and avoid needing to destructure / remove props from restProps like so:

const pannedBox = this.panBox(
        {
          ...targetProps,
          ...brushBox,
          brushDomain: cachedDomain,
          startX: (brushBox.x1 + brushBox.x2) / 2,
          startY: (brushBox.y1 + brushBox.y2) / 2
        },
        Selection.getSVGEventCoordinates(evt, parentSVG)
      );

@@ -20,7 +20,7 @@ export const brushContainerMixin = (base) =>
y: PropTypes.array
}),
brushStyle: PropTypes.object,
defaultBrushArea: PropTypes.oneOf(["all", "disable", "none"]),
defaultBrushArea: PropTypes.oneOf(["all", "disable", "none", "move"]),
Copy link
Contributor

Choose a reason for hiding this comment

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

This addition is making me want to rename this prop 😅
I'm going to avoid the breaking change for now so I can get this feature in without a major version bump. For the future, I think this should be something more like brushClearing: PropTypes.oneOf(["selectAll", "disable", "selectNone", "move"]) Open to suggestions on what would be clearest. What do you think?

Copy link
Contributor Author

@Hypnosphi Hypnosphi Nov 7, 2019

Choose a reason for hiding this comment

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

Yeah, I had basically the same thought. Maybe something like outsideClickBehavior

@boygirl
Copy link
Contributor

boygirl commented Nov 7, 2019

@Hypnosphi thanks for this feature! I will merge this after the slight changes to getDefaultBrushArea I mentioned above.

@boygirl
Copy link
Contributor

boygirl commented Nov 8, 2019

Thanks! I'm going to get this merged and released as a patch today. I'll add changing that prop name to my todo list for the next major verison bump.

@boygirl boygirl merged commit 3f92f8e into FormidableLabs:master Nov 8, 2019
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.

2 participants