MouseEvent.mozPressure 已弃用。改用 PointerEvent.pressure
Posted
技术标签:
【中文标题】MouseEvent.mozPressure 已弃用。改用 PointerEvent.pressure【英文标题】:MouseEvent.mozPressure is deprecated. Use PointerEvent.pressure instead 【发布时间】:2019-08-31 01:22:01 【问题描述】:如何在代码中解决这个问题?
这很奇怪,因为我在代码中找不到,但 Firefox 抱怨“不推荐使用 MouseEvent.mozPressure。请改用 PointerEvent.pressure。”在控制台中。
有没有办法解决这个问题?我不明白我需要做什么来解决这个问题。
jsfiddle、gitHub pages、codepen中出现此错误信息。
https://jsfiddle.net/p5f3xc0b/3/
const videoPlayer = (function makeVideoPlayer()
"use strict";
const players = [];
function onPlayerReady(event)
const player = event.target;
player.setVolume(100); // percent
let hasShuffled = false;
function onPlayerStateChange(event)
const player = event.target;
if (!hasShuffled)
player.setShuffle(true);
player.playVideoAt(0);
hasShuffled = true;
if (event.data === YT.PlayerState.PLAYING)
for (let i = 0; i < players.length; i++)
if (players[i] !== event.target) players[i].pauseVideo();
const playerVars = player.b.b.playerVars;
if (playerVars.loop && event.data === YT.PlayerState.ENDED)
player.seekTo(playerVars.start);
function addVideo(video, settings)
players.push(new YT.Player(video, Object.assign(
videoId: video.dataset.id,
host: "https://www.youtube-nocookie.com",
events:
"onReady": onPlayerReady,
"onStateChange": onPlayerStateChange
, settings)));
function init(video, settings)
load.js("https://www.youtube.com/player_api").then(function ()
YT.ready(function ()
addVideo(video, settings);
);
);
return
init
;
());
function loadPlayer(opts)
"use strict";
function show(el)
el.classList.remove("hide");
function initPlayer(wrapper)
const video = wrapper.querySelector(".video");
opts.width = opts.width || 198;
opts.height = opts.height || 198;
opts.autoplay = 1;
opts.controls = 1;
opts.rel = 0;
opts.iv_load_policy = 3;
opts.fs = 0;
opts.disablekb = 1;
function paramInOpts(settings, param)
if (opts[param] !== undefined)
settings[param] = opts[param];
return settings;
const settingsParams = ["width", "height", "videoid", "host"];
const settings = settingsParams.reduce(paramInOpts, );
const playerVarsParams = ["autoplay", "cc_load_policy",
"controls", "disablekb", "end", "fs", "iv_load_policy",
"list", "listType", "loop", "playlist", "rel", "start"
];
settings.playerVars = playerVarsParams.reduce(paramInOpts, );
videoPlayer.init(video, settings);
function coverClickHandler(evt)
const wrapper = evt.currentTarget.nextElementSibling;
show(wrapper);
initPlayer(wrapper);
evt.currentTarget.classList.add("hide");
const cover = document.querySelector(opts.target);
cover.addEventListener("click", coverClickHandler);
const playlist = "0dgNc5S8cLI,mnfmQe8Mv1g,-Xgi_way56U,CHahce95B1g";
loadPlayer(
target: ".jacket-left",
width: 277,
height: 207
);
loadPlayer(
target: ".jacket-middle",
width: 277,
height: 207
);
loadPlayer(
target: ".jacket-right",
width: 277,
height: 207
);
loadPlayer(
target: ".jacketc",
width: 600,
height: 338,
loop: true,
playlist
);
loadPlayer(
target: ".alpha",
start: 0,
end: 280,
loop: true
);
loadPlayer(
target: ".beta",
start: 0,
end: 240,
loop: true
);
loadPlayer(
target: ".gamma",
start: 0,
end: 265,
loop: true
);
loadPlayer(
target: ".delta",
start: 4,
end: 254,
loop: true
);
loadPlayer(
target: ".epsilon",
start: 0,
end: 242,
loop: true
);
loadPlayer(
target: ".zeta",
start: 0,
end: 285,
loop: true
);
loadPlayer(
target: ".eta",
start: 23,
end: 312,
loop: true
);
loadPlayer(
target: ".theta",
start: 2
);
loadPlayer(
target: ".iota"
);
【问题讨论】:
【参考方案1】:错误可能来自其他原因。这只是一个警告,因为它与您的代码无关,所以我不会担心。如果您访问大多数网站,即使它们在控制台中有错误消息,也不会以任何方式影响您正在执行的操作。如果您所做的一切正常,我就不会担心。祝你好运,这看起来是一个很酷的项目!
【讨论】:
YouTube 也有【参考方案2】:正如 Marci 回答 on another forum,此警告来自 YouTube 嵌入。它实际上是在您在 Firefox 中访问 youtube.com 时触发的。相关代码在desktop_polymer_inlined_html_polymer_flags_v2.js的第1355行。
【讨论】:
【参考方案3】:这是一个警告,而不是错误。看起来您的代码仍然有效......但是要摆脱警告,您可以使用 try-catch 块。我无法确定您的警告来自何处,因为我没有收到错误消息。如果你指定行,我可以为你添加 try-catch。
【讨论】:
以上是关于MouseEvent.mozPressure 已弃用。改用 PointerEvent.pressure的主要内容,如果未能解决你的问题,请参考以下文章
已弃用:指令 'allow_url_include' 在第 0 行的 Unknown 中已弃用
Modernizr.load 已弃用。 Yepnope.js 已弃用。怎么办?
UIAlertView 已弃用:首先在 iOS 9.0 中弃用 - UIAlertView 已弃用。将 UIAlertController 与首选样式一起使用
已弃用:each() 函数已弃用。 C:\xampp\htdocs\phprojekt\library\Zend\Cache\Backend.php 在第 66 行 [重复]