-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Adding MarqueeSelection component and example #74
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
Changes from 16 commits
24dd626
3921752
d5ec54c
58281d9
c4ced04
2e0a119
ae2bd96
1272674
bb4d1c0
089fd22
456aee3
3c3b43d
66ef16d
6729ebd
9d12f13
3c08105
4295470
0c7a8a4
fb61f66
7ade6e9
bd5777d
dca18b5
f329966
59ab874
4079b67
4a08c31
fa542ac
7f48aef
e85baa6
142872f
b891954
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export * from './components/MarqueeSelection/MarqueeSelection'; | ||
| export * from './components/MarqueeSelection/MarqueeSelection.Props'; | ||
| export * from './utilities/selection/index'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import * as React from 'react'; | ||
| import { ISelection } from '../../utilities/selection/interfaces'; | ||
| import { MarqueeSelection } from './MarqueeSelection'; | ||
|
|
||
| export interface IMarqueeSelectionProps extends React.Props<MarqueeSelection> { | ||
| /** | ||
| * The selection object to interact with when updating selection changes. | ||
| */ | ||
| selection: ISelection; | ||
|
|
||
| /** | ||
| * The base element tag name to render the marquee bounding area within. | ||
| * @default div | ||
| */ | ||
| rootTagName?: string; | ||
|
|
||
| /** | ||
| * Optional props to mix into the root element. | ||
| */ | ||
| rootProps?: React.HTMLProps<HTMLDivElement>; | ||
|
|
||
| /** | ||
| * Optional callback that is called, when the mouse down event occurs, in order to determine | ||
| * if we should start a marquee selection. If true is returned, we will cancel the mousedown | ||
| * event to prevent upstream mousedown handlers from executing. | ||
| */ | ||
| onShouldStartSelection?: (ev: React.MouseEvent) => boolean; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be widened or altered. @bind
private _onShouldStartSelection(area: Rectangle, event: React.MouseEvent): boolean {
if (!this._isDropping) {
return false;
}
if (area.width > 10 || area.height > 10) {
return true;
}
return false;
}
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure that passing along the rectangle helps at all. It would force the caller to figure out whats in the box, which pushes some of the logic in more than one place. However, it is possible we could try to identify if the pixel you clicked on is an item and pass that as a parameter. That could make it cleaner. |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| @import '../../common/common'; | ||
|
|
||
| .ms-MarqueeSelection { | ||
| position: relative; | ||
| cursor: default; | ||
| } | ||
|
|
||
| .ms-MarqueeSelection-dragMask { | ||
| position: absolute; | ||
| background: rgba(255, 0, 0, 0); | ||
| left: 0; | ||
| top: 0; | ||
| right: 0; | ||
| bottom: 0; | ||
| } | ||
|
|
||
| .ms-MarqueeSelection-box { | ||
| position: absolute; | ||
| box-sizing: border-box; | ||
| border: 1px solid $ms-color-themePrimary; | ||
| pointer-events: none; | ||
| } | ||
|
|
||
| .ms-MarqueeSelection-boxFill { | ||
| position: absolute; | ||
| box-sizing: border-box; | ||
| background-color: $ms-color-themePrimary; | ||
| opacity: .1; | ||
| left: 0; | ||
| top: 0; | ||
| right: 0; | ||
| bottom: 0; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would make a lot more sense just to define a
@binddecorator:The
@binddecorator would cleanly handle the binding once the instance was constructed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that suggestion. I'll remove it here and approach it that way separately.