1
我有一个场景,我想概括页面滚动事件按钮单击使用dojo。我有一段时间没有能够取得突破。我是DOJO的初学者,希望得到一些好的解决方案。我有一个小提琴:动态dojo/on事件
http://jsfiddle.net/sacnayak/Ej39D/3/
粘贴代码中再为第一参考:
require(["dojo/fx", "dojox/fx/scroll", "dojo/dom", "dojo/dom-style", "dojo/on", "dojo/domReady!", "dojo/window", "dojo/dom-geometry", "dojo/_base/fx", "dojo/Deferred", "dojo/query"],
function (coreFx, easing, dom, style, on, ready, win, domGeometry, fx, Deferred, query) {
function asyncProcess() {
var deferred = new Deferred();
setTimeout(function() {
deferred.resolve("success");
}, 500);
return deferred.promise;
}
var currentActiveDomButton = query("#screens .screen.active .card-footer-button")[0];
console.log(currentActiveDomButton);
on(dom.byId(currentActiveDomButton.id), "click", function() {
var currentActiveDomNode = query("#screens .screen.active")[0];
console.log(currentActiveDomNode);
var screens = query("#screens .screen");
var nextActiveDiv;
for (i = 0; i < screens.length; i++) {
if (dojo.attr(currentActiveDomNode, "id") != dojo.attr(screens[i], "id")) {
nextActiveDiv = screens[i];
console.log(nextActiveDiv);
break;
}
}
fx.animateProperty({
node: currentActiveDomNode.id,
duration: 500,
properties: {
opacity: {
start: '1',
end: '0.5'
}
}
}).play();
var process = asyncProcess();
process.then(function() {
style.set(nextActiveDiv.id, "display", "block");
//dojo.byId(currentActiveDomButton.id).style.display = 'none';
dojox.fx.smoothScroll({
node: nextActiveDiv.id,
win: window
}).play();
require(["dojo/dom-class"], function (domClass) {
domClass.remove(currentActiveDomNode.id, "active");
domClass.add(currentActiveDomNode.id, "visited");
domClass.add(nextActiveDiv.id, "active");
currentActiveDomButton = query("#screens .screen.active .card-footer-button")[0];
console.log(currentActiveDomButton.id);
});
});
});
});