Socket
Socket
Sign inDemoInstall

react-pannable

Package Overview
Dependencies
3
Maintainers
1
Versions
105
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-pannable


Version published
Weekly downloads
116
increased by100%
Maintainers
1
Install size
452 kB
Created
Weekly downloads
 

Readme

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,
  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.
shouldStartboolean,functiontrueWhether 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 Align = 'auto' | 'center' | 'start' | 'end' | number;
type PadEvent = {
  contentOffset: Point,
  contentVelocity: Point,
  dragging: boolean,
  decelerating: boolean,
  size: Size,
  contentSize: Size,
};
Prop Types
PropertyTypeDefaultValueDescription
childrenelement,ComponentnullRendered content. Can be a react component class, a render function, or a rendered element.:(pad: Pad) => element
widthnumber0The width of the bounding view.
heightnumber0The height of the bounding view.
contentWidthnumber0The width of the content view.
contentHeightnumber0The height of the content view.
scrollEnabledbooleantrueDetermines whether scrolling is enabled.
pagingEnabledbooleanfalseDetermines whether paging is enabled.
directionalLockEnabledbooleanfalsedetermines whether scrolling is disabled in a particular direction.
onScrollfunction() => {}Callback invoked when the content view scrolls.:({evt: PadEvent}) => 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.

GeneralContent

GeneralContent automatically adjusts the width and height of content.

type Size = { width: number, height: number };
Prop Types
PropertyTypeDefaultValueDescription
widthnumber-1The width of the content. If you set this property to -1, it shrinks the content's width.
heightnumber-1The height of the content. If you set this property to -1, it shrinks the content's height.
onResizefunction() => {}Callback invoked when the content resize.:(Size) => element

GridContent

GridContent provides grid layout of content.

type Size = { width: number, height: number };
type Rect = { x: number, y: number, width: number, height: number };
Prop Types
PropertyTypeDefaultValueDescription
rowCountnumber0the number of rows.
columnCountnumber0the number of columns.
rowHeightnumber,function0the height of the specified row.
columnWidthnumber,function0the width of the specified column.
rowHeightHashfunction({ rowIndex }) => rowIndexthe hash of the row's height.
columnWidthHashfunction({ columnIndex }) => columnIndexthe hash of the column's width.
cellKeyfunction({ columnIndex, rowIndex }) => rowIndex + '-' + columnIndexthe key of the specified cell.
renderCellfunction() => nullthe renderer of the specified cell.
visibleRectRect{ x: 0, y: 0, width: 0, height: 0 }the area of the visible content.
onResizefunction() => {}Callback invoked when the content resize.:(Size) => element
Public Methods
getCellRect({ rowIndex: number, columnIndex: number })

Returns the area of cell at the specified indexes.

License

MIT License

Keywords

FAQs

Last updated on 08 Mar 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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc