@ray-js/gesture
TypeScript icon, indicating that this package has built-in type declarations

0.1.6 • Public • Published

English | 简体中文

@ray-js/gesture

latest download

Tuya Ray 手势库

Installation

$ npm install @ray-js/gesture
# or
$ yarn add @ray-js/gesture

Usage

Class Component

import React from 'react';
import { View, Text } from '@ray-js/components';
import Gesture from '@ray-js/gesture';

export default () => (
  <Gesture
    onTap={event => {
      console.log('onTap', event);
    }}
  >
    <View />
  </Gesture>
);

useGesture

import React from 'react';
import { View, Text } from '@ray-js/components';
import { useGesture } from '@ray-js/gesture';

export default () => {
  const gesture = useGesture({
    onTap: event => {
      console.log('onTap', event);
    },
  });
  <View {...gesture} />;
};

useRect

import React from 'react';
import { View, Text } from '@ray-js/components';
import useRect from '@ray-js/gesture';

export default props => {
  const [id, ref, rect] = useRect();
  console.log(rect.width, rect.height); // 150 150
  return <View ref={ref} id={id} style={{ width: '150px', height: '150px' }} />;
};

References

Readme

Keywords

none

Package Sidebar

Install

npm i @ray-js/gesture

Weekly Downloads

181

Version

0.1.6

License

MIT

Unpacked Size

22.1 kB

Total Files

12

Last publish

Collaborators

  • tuyafe