Skip to content
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
2ae8032
Fix sticky top behavior. Make inner div of ScrollablePane scrollable…
edwlmsft Apr 5, 2018
2534902
Fix sticky footer behavior
edwlmsft Apr 6, 2018
351b509
Remove unused state placeholderHeight. clean up onScrollEvent to onl…
edwlmsft Apr 6, 2018
d7befce
Add stickyPosition prop back
edwlmsft Apr 6, 2018
2e6f1eb
Remove stickyBelowContainer from handle.
edwlmsft Apr 6, 2018
4cc5960
Revert details list example. Fix distanceFromTop calculation
edwlmsft Apr 6, 2018
30b8c79
Fix unmounting sticky. Fix ScrollablePane not setting correct height…
edwlmsft Apr 6, 2018
de0424b
Update subscribers when DOM changes in scrollablePane. Add back Deta…
edwlmsft Apr 6, 2018
0fe99c9
Clean up inline sticky styles
edwlmsft Apr 6, 2018
92d4db5
Remove "testing testing" from default example
edwlmsft Apr 6, 2018
de3070c
Set stickyClassName on nonStickyContent if Sticky component is sticky…
edwlmsft Apr 6, 2018
b72e391
Remove unused _stickyBelow/_stickyAbove from ScrollablePane. Clean u…
edwlmsft Apr 6, 2018
e4ab481
black to $ms-color-black. Set overflow-x to auto and overflow-y to h…
edwlmsft Apr 6, 2018
7fe6b8c
Remove unused ref _stickyBelowContainerRef
edwlmsft Apr 7, 2018
7992359
Add getter for contentContainer
edwlmsft Apr 7, 2018
0397c02
Fix initial scroll position prop not working properly. Only set sta…
edwlmsft Apr 8, 2018
0082fb4
Simplify sortSticky function. Clean up _addtoStickyContainer function…
edwlmsft Apr 9, 2018
a143c76
Add back in detailslist example
edwlmsft Apr 9, 2018
ca65251
Fix linting
edwlmsft Apr 9, 2018
b4a7820
Remove redundant check for canStickyTop/Bottom in updateStickyRefHeig…
edwlmsft Apr 9, 2018
697abf8
nit: cleaner code in _addToStickyContainer
edwlmsft Apr 10, 2018
9e012ff
Fix lint
edwlmsft Apr 11, 2018
5d894de
Add aria-hidden to render for Sticky. Add comment in notifySubscribers.
edwlmsft Apr 13, 2018
0ff1aec
move sortSticky to component mount only. Add setDistanceFromTop func…
edwlmsft Apr 16, 2018
57faff0
Return undefined instead of null in _getBackground
edwlmsft Apr 17, 2018
8741d7c
merge master
edwlmsft Apr 17, 2018
7d86387
Fix merge conflict
edwlmsft Apr 17, 2018
0b6badb
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
edwlmsft Apr 19, 2018
3799d87
Remove unused StickyPosition
edwlmsft Apr 19, 2018
a7aeb07
Only updateStickyRefHeights in Sticky if state changes. Change from …
edwlmsft Apr 22, 2018
aac9e53
Add mutationObserver to check for Sticky component state changes
edwlmsft Apr 22, 2018
0080b46
Change scrollablePane didUpdate to notify when stickyTop/Bottom heigh…
edwlmsft Apr 23, 2018
0313824
Update scrollablePane styles to use position absolute. Update defaul…
edwlmsft Apr 23, 2018
28709a7
Fix default example to not have duplicate colors
edwlmsft Apr 23, 2018
78a298f
Update details list example
edwlmsft Apr 23, 2018
59f2ab7
Update ScrollablePane Do's. Update example css
edwlmsft Apr 23, 2018
0ef10da
Update sticky donts
edwlmsft Apr 23, 2018
c55aad9
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
edwlmsft Apr 23, 2018
b8aab4c
Fix lint
edwlmsft Apr 23, 2018
489d246
more lint
edwlmsft Apr 23, 2018
ac905dc
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
edwlmsft Apr 23, 2018
474bf81
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
edwlmsft May 2, 2018
1fa5a01
Set refs as private properties of Sticky. Remove background #fff fro…
edwlmsft May 2, 2018
e04d2a7
Fix order of public/private in Sticky
edwlmsft May 2, 2018
00a8b44
Set width on stickyabove/below instead of Sticky component itself.
edwlmsft May 2, 2018
b49fa90
Get rid of maxheight styles. Add throttle to scroll event. Change no…
edwlmsft May 3, 2018
c5b0ef3
Update Do's
edwlmsft May 3, 2018
f37feb8
Add change file
edwlmsft May 4, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {

const GlobalClassNames = {
root: 'ms-ScrollablePane',
contentContainer: 'ms-ScrollablePane--contentContainer'
};

export const getStyles = (
Expand All @@ -24,19 +25,39 @@ export const getStyles = (
position: 'absolute',
pointerEvents: 'auto',
width: '100%',
zIndex: ZIndexes.ScrollablePane,
overflowY: 'hidden',
overflowX: 'auto'
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we get rid of the maxHeightStyles altogether now?

const maxHeightStyles: IStyle = {
height: 'inherit',
maxHeight: 'inherit',
zIndex: ZIndexes.ScrollablePane
};

return ({
root: [
classNames.root,
{
WebkitOverflowScrolling: 'touch',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this be a lowercase w?

position: 'absolute',
top: 0,
right: 0,
bottom: 0,
left: 0
},
maxHeightStyles,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we make ScrollablePane use position: absolute and top: 0; bottom: 0; left: 0; right: 0? That would make it more intuitive use, because the caller can just supply the bounding rect and this will 'snap' into it.

className
],
contentContainer: [
classNames.contentContainer,
{
overflowY: 'auto',
maxHeight: 'inherit',
height: 'inherit',
position: 'relative',
WebkitOverflowScrolling: 'touch'
},
className
maxHeightStyles
],
stickyAbove: [
{
Expand All @@ -59,6 +80,12 @@ export const getStyles = (
}
},
AboveAndBelowStyles
],
stickyBelowItems: [
{
bottom: 0
},
AboveAndBelowStyles
]
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,12 @@ export interface IScrollablePaneStyles {
* Style set for the stickyAbove element.
*/
stickyBelow: IStyle;
/**
* Style set for the stickyBelowItems element.
*/
stickyBelowItems: IStyle;
/**
* Style set for the contentContainer element.
*/
contentContainer: IStyle;
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Don't use Sticky on elements with margin top or bottom
- Don't use Sticky on elements with `margin-top` or `margin-bottom`
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Ensure that a parent component has a CSS height, or max-height attribute set (and any intermediary containers have an inherit, or explicit height/max-height set).
- ScrollablePane uses `position: absolute`. Ensure that the parent element has an explicit height, or has space already allocated for ScrollablePane (e.g: flexbox).
- Use Sticky component on block level elements
- Sticky component are ideally section headers and/or footers
- Sticky component are ideally section headers and/or footers
- Ensure that the total height of Sticky components do not exceed the height of the ScrollablePane
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,54 @@ import { Sticky, StickyPositionType } from 'office-ui-fabric-react/lib/Sticky';
import { lorem } from '@uifabric/example-app-base';
import './ScrollablePane.Example.scss';

export class ScrollablePaneDefaultExample extends React.Component {
const colors = [
'#eaeaea',
'#dadada',
'#d0d0d0',
'#c8c8c8',
'#a6a6a6',
'#c7e0f4',
'#71afe5',
'#eff6fc',
'#deecf9'
];

public render(): JSX.Element {
export class ScrollablePaneDefaultExample extends React.Component {
public render() {
const contentAreas: JSX.Element[] = [];
for (let i = 0; i < 4; i++) {
for (let i = 0; i < 5; i++) {
contentAreas.push(this._createContentArea(i));
}

return (
<ScrollablePane className='scrollablePaneDefaultExample'>
{ contentAreas.map((ele) => {
return ele;
}) }
</ScrollablePane>
<div
style={ {
height: '900px',
position: 'relative',
maxHeight: 'inherit'
} }
>
<ScrollablePane className='scrollablePaneDefaultExample'>
{ contentAreas.map((ele) => {
return ele;
}) }
</ScrollablePane>
</div>
);
}

private _getRandomColor(): string {
const letters = 'BCDEF'.split('');
let color = '#';
for (let i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * letters.length)];
}
return color;
}

private _createContentArea(index: number): JSX.Element {
const style = this._getRandomColor();
private _createContentArea(index: number) {
const color = colors.splice(Math.floor(Math.random() * colors.length), 1)[0];

return (
<div key={ index }>
<div
key={ index }
style={ {
backgroundColor: color
} }
>
<Sticky
stickyPosition={ StickyPositionType.Both }
stickyClassName='largeFont'
stickyBackgroundColor={ style }
>
<div className='sticky'>
Sticky Component #{ index + 1 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import {
ScrollablePane
} from 'office-ui-fabric-react/lib/ScrollablePane';
import {
Sticky
Sticky,
StickyPositionType
} from 'office-ui-fabric-react/lib/Sticky';
import { MarqueeSelection } from 'office-ui-fabric-react/lib/MarqueeSelection';

Expand Down Expand Up @@ -83,41 +84,49 @@ export class ScrollablePaneDetailsListExample extends React.Component<{}, {
const { items, selectionDetails } = this.state;

return (
<ScrollablePane>
<Sticky>{ selectionDetails }</Sticky>
<TextField
label='Filter by name:'
// tslint:disable-next-line:jsx-no-lambda
onChanged={ text => this.setState({ items: text ? _items.filter(i => i.name.toLowerCase().indexOf(text) > -1) : _items }) }
/>
<Sticky>
<h1 style={ { margin: '0px' } }>Item List</h1>
</Sticky>
<MarqueeSelection selection={ this._selection }>
<DetailsList
items={ items }
columns={ _columns }
setKey='set'
layoutMode={ DetailsListLayoutMode.fixedColumns }
onRenderDetailsHeader={
// tslint:disable-next-line:jsx-no-lambda
(detailsHeaderProps: IDetailsHeaderProps, defaultRender: IRenderFunction<IDetailsHeaderProps>) => (
<Sticky>
{ defaultRender({
...detailsHeaderProps,
onRenderColumnHeaderTooltip: (tooltipHostProps: ITooltipHostProps) => <TooltipHost { ...tooltipHostProps } />
}) }
</Sticky>
) }
selection={ this._selection }
selectionPreservedOnEmptyClick={ true }
ariaLabelForSelectionColumn='Toggle selection'
ariaLabelForSelectAllCheckbox='Toggle selection for all items'
<div
style={ {
height: '10000px',
position: 'relative',
maxHeight: 'inherit'
} }
>
<ScrollablePane>
<Sticky stickyPosition={ StickyPositionType.Header }>{ selectionDetails }</Sticky>
<TextField
label='Filter by name:'
// tslint:disable-next-line:jsx-no-lambda
onItemInvoked={ (item) => alert(`Item invoked: ${item.name}`) }
onChanged={ text => this.setState({ items: text ? _items.filter(i => i.name.toLowerCase().indexOf(text) > -1) : _items }) }
/>
</MarqueeSelection>
</ScrollablePane>
<Sticky stickyPosition={ StickyPositionType.Header }>
<h1 style={ { margin: '0px' } }>Item List</h1>
</Sticky>
<MarqueeSelection selection={ this._selection }>
<DetailsList
items={ items }
columns={ _columns }
setKey='set'
layoutMode={ DetailsListLayoutMode.fixedColumns }
onRenderDetailsHeader={
// tslint:disable-next-line:jsx-no-lambda
(detailsHeaderProps: IDetailsHeaderProps, defaultRender: IRenderFunction<IDetailsHeaderProps>) => (
<Sticky stickyPosition={ StickyPositionType.Header }>
{ defaultRender({
...detailsHeaderProps,
onRenderColumnHeaderTooltip: (tooltipHostProps: ITooltipHostProps) => <TooltipHost { ...tooltipHostProps } />
}) }
</Sticky>
) }
selection={ this._selection }
selectionPreservedOnEmptyClick={ true }
ariaLabelForSelectionColumn='Toggle selection'
ariaLabelForSelectAllCheckbox='Toggle selection for all items'
// tslint:disable-next-line:jsx-no-lambda
onItemInvoked={ (item) => alert(`Item invoked: ${item.name}`) }
/>
</MarqueeSelection>
</ScrollablePane>
</div>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,15 @@
:global {
.scrollablePaneDefaultExample {
max-width: 400px;
max-height: inherit;
border: 1px solid $ms-color-neutralLight;
}

.sticky {
@include ms-fontColor-neutralDark;
padding: 10px 20px;
font-size: 16px;
-webkit-transition: font-size ease 0.3s;
-moz-transition: font-size ease 0.3s;
-o-transition: font-size ease 0.3s;
-ms-transition: font-size ease 0.3s;
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
-o-transform: translateZ(0);
transform: translateZ(0);
will-change: font-size;
box-shadow: 0 0 5px -1px $ms-color-neutralDark;
}

.largeFont {
.sticky {
font-size: 20px;
}
padding: 5px 20px 5px 10px;
font-size: 13px;
border-top: 1px solid $ms-color-black;
border-bottom: 1px solid $ms-color-black;
}

.textContent {
Expand Down
Loading