可在所有平台(Web,Android,iOS)上一起使用的鼠标/触摸事件是什么?

时间:2018-09-13 00:41:39

标签: javascript android ios css reactjs

我正在编写React应用,iOS遇到一个独特的问题,即onClickonMouseEnter一起使用时无法按预期工作。第一次按下时,onMouseEnter会触发,只有第二次按下时,onClick会触发。预期的行为是单按,省略了onMouseEnter

该项目的目标是使行为尽可能一致和通用。

    <ItemContainer
      onMouseEnter={() => {
        if (expand) this.setState({ hover: true })
      }}
      onMouseLeave={() => {
        if (expand) this.setState({ hover: false })
      }}
      onClick={() => {
        if (expand) expand({
          expand: true,
          carl: true
        })
      }}
      hover={this.state.hover}
    >
    </ItemContainer>

行为:

const ItemContainer = styled.article`
  cursor: pointer;

  ${ props => props.hover ?
    css`
      transform: scale(1.1);
    `
  : null}
`

请注意,这是仅限iOS的行为,Android会正确忽略onMouseEnter悬停属性。鉴于此问题,我想知道哪些事件可以在Web,Android和iOS上针对触摸和鼠标正常运行(忽略或不执行任何操作)。

0 个答案:

没有答案
相关问题