dojotoolkit中DOM更新有轻微延迟
DOM updates with slight delay in dojotoolkit
我有一个dojox.mobile.IconMenu,上面有6个dojox.mobile.IconMenuItems。当我按下图标菜单项时,按钮应该被按进去。我通过简单地在适当的时间切换按钮的图像来实现这种行为。
现在出现的问题是:
在桌面(Chrome):当我只是点击按钮的视图变化如此之快,你不能看到新的,按下,图形!我必须按住按钮大约半秒钟,然后释放它,直到按钮显示新的图像。
在Android/iOS设备上(测试:Chrome, Firefox, Opera, Skyfire, Board Browser, Dolphin, Safari):按钮更改图像,但我看不到变化,因为图形更改速度太慢。
下面是代码(html)
<ul data-dojo-type="dojox.mobile.IconMenu" id="portalMenu" style="border: none; outline: none; background-image: url('../deliverables_800x480/backgrounds/img_bg_portal.gif'); position: absolute; z-index: 900; background-repeat: no-repeat; background-size: cover; height: 100%; width: 100%; top: 26px;">
<li label="IconMenuItem" data-dojo-type="dojox.mobile.IconMenuItem" id="portalButton1" icon="../deliverables_800x480/buttons/portal/btn_portal_freetext_big_normal.gif" style="border-top-color: transparent; border-right-color: transparent; border-bottom-color: transparent; border-left-color: transparent; line-height: 0px; text-align: center;" moveTo="null" onmousedown="toggleImg1()" onmousdown="toggleView1()"></li>
[其他按钮]
这里是我调用的函数(javascript):
onmousedown = " toggleImg1 ()
// press button1
// press button1
function toggleImg1(){
portalButton1.set("icon", "../deliverables_800x480/buttons/portal/btn_portal_freetext_big_armed.gif");
}
function toggleView1() {
portalButton1.set("moveTo", "messaging");
portalButton1.set("selected", true);
portalButton1.set("icon", "../deliverables_800x480/buttons/portal/btn_portal_freetext_big_normal.gif");
}
首先是不是有一个错误在你的标记?我看到onmousedown和onmousdown,不应该是onmousedown/onmouseup吗?
但是我认为你应该使用dojo/touch和listen to touch。按下/释放而不是鼠标向下/向上。这将确保您听触摸或鼠标,这取决于设备。
或者,也许你可以观察项目的"选定"状态,并在项目被选中时更改图标?比如:
item.watch("selected", function(){
this.set("icon", this.selected?"selected.png":"deselected.png");
});
然后,让项目保持选中一段时间,你可以设置_selEndMethod="timer"。如果你愿意,你也可以改变_duration(默认为800,可能对你来说应该短一点)。
相关文章:
- 可以简化嵌套的延迟Q Promises解析吗
- onclick函数需要双击,因为类分配延迟
- 更多延迟动画
- 对父作用域的指令更新延迟了一步
- 为JS函数添加延迟
- 带有延迟的循环每次应运行5次
- 关键帧之间的css3动画延迟
- 如何在有延迟的情况下对两个代码进行积分
- 如何为.css状态的更改添加延迟
- Angular.js延迟控制器初始化
- 在延迟时设置Whois脚本
- 如何在Javascript中延迟setInterval
- 如何在一个元素动画之后延迟
- 如何将一个方法延迟到另一个方法首先完成,javascript
- jQuery延迟了ajax调用的循环
- 如何减少在移动网络应用程序上播放声音的延迟
- 如何将GreaseMonkey中的XMLHttpRequest延迟到目标页面加载完成
- 提交javascript有轻微延迟
- 我能做些什么来阻止由这段代码引起的轻微页面延迟吗?
- dojotoolkit中DOM更新有轻微延迟