<Sticky> component should expect a function as a child (#27401)

This commit is contained in:
Andrew Hyndman
2018-07-20 17:50:26 -07:00
committed by Wesley Wigham
parent 1d4e623ccb
commit 6aa9bbdf5c
2 changed files with 35 additions and 20 deletions

View File

@@ -1,14 +1,28 @@
// Type definitions for react-sticky 6.0
// Project: https://github.com/captivationsoftware/react-sticky
// Definitions by: Matej Lednicky <http://www.thinkcreatix.com/>, Curtis Warren <https://github.com/curtisw0>
// Definitions by: Matej Lednicky <http://www.thinkcreatix.com/>,
// Curtis Warren <https://github.com/curtisw0>,
// Andrew Hyndman <https://github.com/ajhyndman>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
import * as React from "react";
export const StickyContainer: React.ComponentClass<React.HTMLAttributes<HTMLDivElement>>;
export const StickyContainer: React.ComponentClass<
React.HTMLAttributes<HTMLDivElement>
>;
export interface StickyChildArgs {
style: React.CSSProperties;
isSticky: boolean;
wasSticky: boolean;
distanceFromTop: number;
distanceFromBottom: number;
calculatedHeight: number;
}
export interface StickyProps {
children: (args: StickyChildArgs) => React.ReactElement<any>;
relative?: boolean;
isActive?: boolean;
className?: string;

View File

@@ -1,26 +1,27 @@
import { Sticky, StickyContainer } from "react-sticky";
import * as React from "react";
const StickyAllOptions: JSX.Element =
const StickyAllOptions: JSX.Element = (
<StickyContainer className="sticky-container">
<Sticky
relative
disableHardwareAcceleration
isActive={true}
className="sticky"
style={{}}
stickyClassName="sticky"
stickyStyle={{}}
topOffset={0}
bottomOffset={0}
onStickyStateChange={(isSticky: boolean): void => undefined}>
<div/>
relative
disableHardwareAcceleration
isActive={true}
className="sticky"
style={{}}
stickyClassName="sticky"
stickyStyle={{}}
topOffset={0}
bottomOffset={0}
onStickyStateChange={(isSticky: boolean): void => undefined}
>
{({ style }) => <div style={style} />}
</Sticky>
</StickyContainer>;
</StickyContainer>
);
const StickyNoOptions: JSX.Element =
const StickyNoOptions: JSX.Element = (
<StickyContainer>
<Sticky>
<div/>
</Sticky>
</StickyContainer>;
<Sticky>{({ style }) => <div style={style} />}</Sticky>
</StickyContainer>
);