什么构成用户手势 [英] what constitues user gesture

查看:81
本文介绍了什么构成用户手势的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近为javascript编程了一个菜单界面,该界面可让您动态地向其添加选项,并且大多数情况下可与mouseEnter Events一起使用.我在请求/退出全屏上添加了一些基本的视频控件,这些控件在大多数情况下都会在其中一次显示Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture.时在这些mouseEnter事件之一上触发,但是(奇怪的部分:)有时会起作用,而且我不确定浏览器api如何决定动作是用户手势还是不是手势,谢谢您的帮助

I recently programmed a menu interface for javascript that lets you dynamically add options to it and mostly works with mouseEnter Events . I thne added some basic video Controls to it with request/exit Fullscreen that trigger on one of these mouseEnter events most of the time it displays Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture. however (weird part :) sometimes it works and im not sure how the browser api decides wether an action is a user gesture or not oO any help would be appreciated thanks

推荐答案

以下是可以触发用户通过"的事件的列表. spec.whatwg.org/multipage/interaction.html#triggered-by-user-activation"rel =" noreferrer>规范定义的:

Here is the list of events that can trigger "by user activation" as defined by the specs:

  • 更改
  • 点击
  • 上下文菜单
  • dblclick
  • 鼠标
  • pointerup
  • 重置
  • 提交
  • touchend
  • change
  • click
  • contextmenu
  • dblclick
  • mouseup
  • pointerup
  • reset
  • submit
  • touchend

这是您的错误消息所指的,当他们说用户手势"时.

This is what your error message refers to when they say "a user gesture".

mouseenter不属于该列表.

最有可能的是,当它起作用时,是因为其中一个事件发生的时间少于几毫秒(IIRC目前在Chrome中是50毫秒).

Most likely, when it worked, it was because one of those event did happen less than a few ms before (IIRC it's 50ms in Chrome currently).

这篇关于什么构成用户手势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆