问题描述
我正在使用xui和emile制作可折叠面板,但是第一次单击需要双击,然后所有将来的单击都可以正常工作.我需要先单击才能进行单击.对于那些非javascript用户,我还需要首先使用javascript隐藏该列表.
I am using xui and emile to make a collapsible panel but the first click needs a double click then all future clicks works fine on single click. I need the first click to work on single click. I also need to initially hide the list with javascript for those non javascript users.
谁能看到我哪里出问题了?
Can anyone see where I have gone wrong?
在这里我扩展了xui
Here is where I have extended xui
xui.extend( {
xui.extend ( {
togglePanel:function(dur,thePanel)
{
var panel = document.getElementById(thePanel);
var theHeight = document.getElementById(thePanel).scrollHeight;
if(panel.closed){
emile(panel, 'height:'+theHeight+'px',{duration:dur});
panel.closed = false;
}
else{
emile(panel, 'height:0px', {duration:dur});
panel.closed = true;
}
}
});
这是面板的调用和隐藏
x$(window).load(function(e){
emile('item', 'height:0px', {duration:-0});
x$('.panel a.panelItem').click(function(e){
x$().togglePanel(900,'item');})
});
我也尝试过
x$('#item')setStyle ('height','0px');
隐藏内容.
推荐答案
我知道了.还从emile分支中获得了一些补间功能
I have got it. Also nicked a few tweening functions from a fork of emile
xui扩展
xui.extend (
{
togglePanel:function(dur,thePanel)
{
if (dur === "slow"){
dur = 1500;
}
else if (dur === "fast"){
dur = 500;
}
var panel = document.getElementById(thePanel);
var theHeight = document.getElementById(thePanel).scrollHeight;
if(x$(this).hasClass('closed')){
emile(panel, 'height:'+theHeight+'px',{duration:dur,easing:bounce, after: function() {
x$(panel).removeClass('closed');
}});
}
else {
emile(panel, 'height:0px', {duration:dur,easing:easeInStrong, after: function() {
x$(panel).addClass('closed');
}});
}
}
});
初始化
x$(window).load(function(e){
x$('#item').addClass('closed');
x$('.panel a.panelItem').click(function(e){
x$('#item').togglePanel('slow','item');})
});
和 https://github.com/ded/emile
function easeOut (pos) {
return Math.sin(pos * Math.PI / 2);
};
function easeOutStrong (pos) {
return (pos == 1) ? 1 : 1 - Math.pow(2, -10 * pos);
};
function easeIn (pos) {
return pos * pos;
};
function easeInStrong(pos) {
return (pos == 0) ? 0 : Math.pow(2, 10 * (pos - 1));
};
function bounce(pos) {
if (pos < (1/2.75)) {
return (7.5625*pos*pos);
} else if (pos < (2/2.75)) {
return (7.5625*(pos-=(1.5/2.75))*pos + .75);
} else if (pos < (2.5/2.75)) {
return (7.5625*(pos-=(2.25/2.75))*pos + .9375);
} else {
return (7.5625*(pos-=(2.625/2.75))*pos + .984375);
}
};
仍然需要对其进行一些改进,但我们正在实现这一目标.
Still need to improve it a bit but we are getting there.
这篇关于需要双击emile.js和xui动画吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!