我正在阅读“HTML 动画库示例” http://code.msdn.microsoft.com/windowsapps/Using-the-Animation-787f3720 并注意到 javascript 中没有声明任何元素变量。
target1、target2 等的变量声明或 getelement 在哪里?注意顶部的严格声明。这是来自 Microsoft 的示例代码。
来自pointerFeedback.js
(function () {
"use strict";
var page = WinJS.UI.Pages.define("/html/pointerFeedback.html", {
ready: function (element, options) {
target1.addEventListener("MSPointerDown", onPointerDown, false);
target1.addEventListener("MSPointerUp", onPointerUp, false);
target2.addEventListener("MSPointerDown", onPointerDown, false);
target2.addEventListener("MSPointerUp", onPointerUp, false);
target3.addEventListener("MSPointerDown", onPointerDown, false);
target3.addEventListener("MSPointerUp", onPointerUp, false);
}
});
function onPointerDown(evt) {
WinJS.UI.Animation.pointerDown(evt.srcElement);
}
function onPointerUp(evt) {
WinJS.UI.Animation.pointerUp(evt.srcElement);
}
})();
来自pointerFeedback.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link rel="stylesheet" href="/css/pointerFeedback.css" />
<script src="/js/pointerFeedback.js"></script>
</head>
<body>
<div id="input" data-win-control="SdkSample.ScenarioInput">
<p>Use the Pointer Up and Pointer Down animations to
show tap and click feedback on elements. These animations should be used on elements
that can be interacted with and can trigger actions. They should not be used on
elements that are disabled or on standard web controls that already have other feedback, such as buttons.</p>
</div>
<div id="output" data-win-control="SdkSample.ScenarioOutput">
<div class="example">
<h3>Applied to different sized elements:</h3>
<p>Click or tap on the boxes below to see the animation.</p>
<div id="target1" class="large">
200 pixels
</div>
<div id="target2" class="medium">
100 pixels
</div>
<div id="target3" class="small">
50 pixels
</div>
</div>
</div>
</body>
</html>