diff --git a/common/changes/office-ui-fabric-react/arkgupta-dragDropBorderAnimation_2018-11-23-13-59.json b/common/changes/office-ui-fabric-react/arkgupta-dragDropBorderAnimation_2018-11-23-13-59.json new file mode 100644 index 00000000000000..3a8e43b9073b0b --- /dev/null +++ b/common/changes/office-ui-fabric-react/arkgupta-dragDropBorderAnimation_2018-11-23-13-59.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "packageName": "office-ui-fabric-react", + "comment": "DetailsList: Re-adding border fade animation as transition on column reorder", + "type": "patch" + } + ], + "packageName": "office-ui-fabric-react", + "email": "arkgupta@microsoft.com" +} diff --git a/packages/office-ui-fabric-react/src/components/DetailsList/DetailsColumn.base.tsx b/packages/office-ui-fabric-react/src/components/DetailsList/DetailsColumn.base.tsx index e4255eb941e5db..6fa78700a490d5 100644 --- a/packages/office-ui-fabric-react/src/components/DetailsList/DetailsColumn.base.tsx +++ b/packages/office-ui-fabric-react/src/components/DetailsList/DetailsColumn.base.tsx @@ -12,6 +12,9 @@ import { IDetailsColumnStyleProps, IDetailsColumnProps } from './DetailsColumn.t const MOUSEDOWN_PRIMARY_BUTTON = 0; // for mouse down event we are using ev.button property, 0 means left button const getClassNames = classNamesFunction(); +const TRANSITION_DURATION_DRAG = 200; // ms +const TRANSITION_DURATION_DROP = 1500; // ms +const CLASSNAME_ADD_INTERVAL = 20; // ms export class DetailsColumnBase extends BaseComponent { private _root: any; @@ -41,7 +44,9 @@ export class DetailsColumnBase extends BaseComponent { isIconVisible: column.isSorted || column.isGrouped || column.isFiltered, isPadded: column.isPadded, isIconOnly: column.isIconOnly, - cellStyleProps + cellStyleProps, + transitionDurationDrag: TRANSITION_DURATION_DRAG, + transitionDurationDrop: TRANSITION_DURATION_DROP }); const classNames = this._classNames; @@ -142,12 +147,20 @@ export class DetailsColumnBase extends BaseComponent { if (this.props.isDropped) { if (this._root!.current!) { this._root!.current!.classList!.add(classNames.borderAfterDropping); + + this._async.setTimeout(() => { + if (this._root!.current!) { + this._root!.current!.classList!.add(classNames.noBorderAfterDropping); + } + }, CLASSNAME_ADD_INTERVAL); } + this._async.setTimeout(() => { if (this._root!.current!) { this._root!.current!.classList!.remove(classNames.borderAfterDropping); + this._root!.current!.classList!.remove(classNames.noBorderAfterDropping); } - }, 1500); + }, TRANSITION_DURATION_DROP + CLASSNAME_ADD_INTERVAL); } } @@ -245,6 +258,11 @@ export class DetailsColumnBase extends BaseComponent { if (itemIndex) { this._updateHeaderDragInfo(itemIndex); this._root.current.classList.add(classNames.borderWhileDragging); + this._async.setTimeout(() => { + if (this._root!.current!) { + this._root!.current!.classList!.add(classNames.noBorderWhileDragging); + } + }, CLASSNAME_ADD_INTERVAL); } } @@ -254,6 +272,7 @@ export class DetailsColumnBase extends BaseComponent { this._updateHeaderDragInfo(-1, event); } this._root.current.classList.remove(classNames.borderWhileDragging); + this._root.current.classList.remove(classNames.noBorderWhileDragging); } private _updateHeaderDragInfo(itemIndex: number, event?: MouseEvent) { diff --git a/packages/office-ui-fabric-react/src/components/DetailsList/DetailsColumn.styles.ts b/packages/office-ui-fabric-react/src/components/DetailsList/DetailsColumn.styles.ts index 85ad345b764e6d..a148f976eaedc4 100644 --- a/packages/office-ui-fabric-react/src/components/DetailsList/DetailsColumn.styles.ts +++ b/packages/office-ui-fabric-react/src/components/DetailsList/DetailsColumn.styles.ts @@ -33,7 +33,9 @@ export const getStyles = (props: IDetailsColumnStyleProps): IDetailsColumnStyles isIconVisible, isPadded, isIconOnly, - cellStyleProps = DEFAULT_CELL_STYLE_PROPS + cellStyleProps = DEFAULT_CELL_STYLE_PROPS, + transitionDurationDrag, + transitionDurationDrop } = props; const { semanticColors, palette } = theme; @@ -53,6 +55,20 @@ export const getStyles = (props: IDetailsColumnStyleProps): IDetailsColumnStyles paddingLeft: 8 }; + const borderWhileDragging: IStyle = [ + { + borderStyle: 'solid', + borderWidth: 1, + borderColor: palette.themePrimary + } + ]; + + const borderAfterDragOrDrop: IStyle = [ + { + borderColor: 'transparent' + } + ]; + return { root: [ getCellStyles(props), @@ -179,26 +195,12 @@ export const getStyles = (props: IDetailsColumnStyleProps): IDetailsColumnStyles accessibleLabel: [hiddenContentStyle], - borderAfterDropping: [ - { - borderStyle: 'solid', - borderWidth: 1, - borderColor: palette.themePrimary, - left: -1, - lineHeight: 31 - } - ], + borderWhileDragging: borderWhileDragging, - borderWhileDragging: [ - { - selectors: { - '.ms-DetailsHeader &.ms-DetailsHeader-cell': { - borderStyle: 'solid', - borderWidth: 1, - borderColor: palette.themePrimary - } - } - } - ] + noBorderWhileDragging: [borderAfterDragOrDrop, { transition: `border-color ${transitionDurationDrag}ms ease` }], + + borderAfterDropping: [borderWhileDragging, { left: -1, lineHeight: 31 }], + + noBorderAfterDropping: [borderAfterDragOrDrop, { transition: `border-color ${transitionDurationDrop}ms ease` }] }; }; diff --git a/packages/office-ui-fabric-react/src/components/DetailsList/DetailsColumn.types.ts b/packages/office-ui-fabric-react/src/components/DetailsList/DetailsColumn.types.ts index b2cb453ee8e5ee..76c5886b085474 100644 --- a/packages/office-ui-fabric-react/src/components/DetailsList/DetailsColumn.types.ts +++ b/packages/office-ui-fabric-react/src/components/DetailsList/DetailsColumn.types.ts @@ -33,6 +33,8 @@ export type IDetailsColumnStyleProps = Required