Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-pannable

Package Overview
Dependencies
Maintainers
1
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-pannable

Simulate pan gesture and scroll view for touch devices with React

  • 0.10.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
67
decreased by-34.31%
Maintainers
1
Weekly downloads
 
Created
Source

react-pannable

Simulate pan gesture and scroll view for touch devices with React

npm version npm license

Getting started

Install react-pannable using npm.

npm install --save react-pannable

Examples

All the examples!

Some Pannable demos

Some Pad demos

API Reference

Pannable

Pannable provides a pan gesture simulation on recent mobile browsers for iOS and Android. It can also be used on mouse-base devices across on all evergreen browsers.

type Point = { x: number, y: number };
type PanEvent = {
  translation: Point,
  velocity: Point,
  interval: number,
  target: HTMLElement,
};
Prop Types
PropertyTypeDefaultValueDescription
enabledbooleantrueIndicate whether the gesture listener is enabled. If you change this property to false while the gesture is listening, the gesture transitions to cancel.
shouldStartfunction() => trueWhether to start gesture listening. : (evt: PanEvent) => void
onStartfunction() => {}Callback invoked when the gesture starts listening.: (evt: PanEvent) => void
onMovefunction() => {}Callback invoked when the gesture moves.: (evt: PanEvent) => void
onEndfunction() => {}Callback invoked when the gesture ended listening.: (evt: PanEvent) => void
onCancelfunction() => {}Callback invoked when the gesture cancelled.: (evt: PanEvent) => void

Pad

Pad provides a scrollable content component on which overflow scrollbars are not natively supported. It also provides paging scroll implementation and multiple content layout mode.

type Point = { x: number, y: number };
type Size = { width: number, height: number };
type Rect = { x: number, y: number, width: number, height: number };
type AlignEnum = 'auto' | 'center' | 'start' | 'end' | number;
type Align = { x: AlignEnum, y: AlignEnum } | AlignEnum;
type PadEvent = {
  contentOffset: Point,
  contentVelocity: Point,
  dragging: boolean,
  decelerating: boolean,
  size: Size,
  contentSize: Size,
};
Prop Types
PropertyTypeDefaultValueDescription
childrenelement,functionnullRendered content. Can be a render function, or a rendered element.:(pad: Pad) => element
widthnumber0The width of the bounding view.
heightnumber0The height of the bounding view.
scrollEnabledbooleantrueDetermines whether scrolling is enabled.
pagingEnabledbooleanfalseDetermines whether paging is enabled.
directionalLockEnabledbooleanfalseDetermines whether scrolling is disabled in a particular direction.
alwaysBounceXbooleantrueDetermines whether bouncing always occurs when horizontal scrolling reaches the end of the content.
alwaysBounceYbooleantrueDetermines whether bouncing always occurs when vertical scrolling reaches the end of the content.
onScrollfunction() => {}Callback invoked when the content view scrolls.:(evt: PadEvent) => void
onDragStartfunction() => {}Callback invoked when start dragging the content.:() => void
onDragEndfunction() => {}Callback invoked when end dragging the content.:() => void
onDecelerationStartfunction() => {}Callback invoked when the content start decelerating.:() => void
onDecelerationEndfunction() => {}Callback invoked when the content end decelerating.:() => void
onContentResizefunction() => {}Callback invoked when the content view resize.:(size: Size) => void
Public Methods
scrollTo({ offset: Point, animated: boolean })

Sets the offset from the content view’s origin.

scrollToRect({ rect: Rect, align: Align, animated: boolean })

Scrolls a specific area of the content so that it is visible.

AutoResizing

AutoResizing calculates the filling size of the view automatically.

type Size = { width: number, height: number };
Prop Types
PropertyTypeDefaultValueDescription
childrenelement,functionnullThe render function passing the calculated width and height.:(size: Size) => element
widthnumbernullThe width of the content. If not specified, it calculates the filling width of the view.
heightnumbernullThe height of the content. If not specified, it calculates the filling height of the view.
onResizefunction() => {}Invoked when the view resize.:(size: Size) => void
Public Methods
getSize()

Returns the real size of the view.

calculateSize()

Calculate the size of the view manually.

ItemContent

ItemContent calculates the fitting size of the content.

type Size = { width: number, height: number };
Prop Types
PropertyTypeDefaultValueDescription
widthnumbernullThe width of the content. If not specified, it calculates the fitting width of the content.
heightnumbernullThe width of the content. If not specified, it calculates the fitting height of the content.
visibleRectRect{ x: 0, y: 0, width: 0, height: 0 }The area of the visible content.
onResizefunction() => {}Invoked when the content resize.:(size: Size) => void
connectWithPadbooleantrueAutomatic synchronize the content size and visible rectangle with Pad
Public Methods
getSize()

Returns the real size of the content.

calculateSize()

Calculate the size of the content manually.

GeneralContent

GeneralContent is similar to ItemContent. The difference between them is that GeneralContent listens the content and automatically calculates the size when the content resize.

ListContent

ListContent displays data in a single line of customizable items.

type Size = { width: number, height: number };
type Rect = { x: number, y: number, width: number, height: number };
type ItemProps = {
  key: string,
  hash: string,
  forceRender: boolean,
  style: object,
};
type Item = React.Element<ItemProps>;
type LayoutAttrs = {
  itemIndex: number,
  rect: Rect,
  visibleRect: Rect,
  needsRender: boolean,
  Item: Item,
};
Prop Types
PropertyTypeDefaultValueDescription
direction'x','y''y'The direction of the list.
widthnumbernullThe suggested width of the content.
heightnumbernullThe suggested height of the content.
spacingnumber0The minimum spacing to use between items in the list.
itemCountnumber0The number of items.
estimatedItemWidthnumber0The estimated width of the item.
estimatedItemHeightnumber0The estimated height of the item.
renderItemfunction() => nullThe renderer of the item.:(attrs: LayoutAttrs) => element
visibleRectRect{ x: 0, y: 0, width: 0, height: 0 }The area of the visible content.
onResizefunction() => {}Callback invoked when the content resize.:(size: Size) => void
connectWithPadbooleantrueAutomatic synchronize the content size and visible rectangle with Pad
Public Methods
getItemRect({ itemIndex: number })

Returns the area of item at the specified index.

GridContent

GridContent displays data in multiple rows and columns with the same size.

type Size = { width: number, height: number };
type Rect = { x: number, y: number, width: number, height: number };
type ItemProps = {
  key: string,
  forceRender: boolean,
  style: object,
};
type Item = React.Element<ItemProps>;
type LayoutAttrs = {
  itemIndex: number,
  rowIndex: number,
  columnIndex: number,
  rect: Rect,
  visibleRect: Rect,
  needsRender: boolean,
  Item: Item,
};
Prop Types
PropertyTypeDefaultValueDescription
direction'x','y''y'The direction of the grid.
widthnumbernullThe suggested width of the content.
heightnumbernullThe suggested height of the content.
rowSpacingnumber0The minimum spacing to use between rows of items in the grid.
columnSpacingnumber0The minimum spacing to use between columns of items in the grid.
itemCountnumber0The number of items.
itemWidthnumber0The width of the item.
itemHeightnumber0The height of the item.
renderItemfunction() => nullThe renderer of the item.:(attrs: LayoutAttrs) => element
visibleRectRect{ x: 0, y: 0, width: 0, height: 0 }The area of the visible content.
onResizefunction() => {}Callback invoked when the content resize.:(size: Size) => void
connectWithPadbooleantrueAutomatic synchronize the content size and visible rectangle with Pad
Public Methods
getItemRect({ itemIndex: number, rowIndex: number, columnIndex: number })

Returns the area of item at the specified indexes.

License

MIT License

Keywords

FAQs

Package last updated on 11 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc