UNPKG

xcandy

Version:
37 lines 1.12 kB
import { Component } from "@tarojs/taro-h5"; import Nerv from "nervjs"; import { View } from '@tarojs/components'; import ComputeTransform from './computeTransform'; class XcArrow extends Component { constructor() { super(...arguments); this.computeTransform = new ComputeTransform(); } shouldComponentUpdate(nextProps) { return Object.keys(nextProps).some(key => nextProps[key] !== this.props[key]); } render() { const { className, color, size, weight, degree, offsetDegree } = this.props; const trans = this.computeTransform.compute({ degree: degree || degree === 0 ? degree : 90, offsetDegree }); const finalStyle = { borderStyle: 'solid', borderTopColor: color, borderRightColor: color, borderWidth: `${weight} ${weight} 0 0`, width: size, height: size, transform: trans }; return <View style={finalStyle} className={className} />; } handleClick = e => { const { onClick } = this.props; onClick && onClick(e); }; } XcArrow.defaultProps = { weight: '1px', color: '#dedede', size: '10px' }; export default XcArrow;