qq_那些年_30
应该是因为div上并没有定义触发事件,并没有事件来触发所以看不到效果。你可以在div上定义事件测试一下。
dky
源码有浏览器兼容性问题。。ie10,火狐,谷歌,要点击两次item(例如资产)才有相应的nav-content的div出现,而搜狗浏览器只需点击一次
言长寸短
(function(){
var SideBar=function(eId,closeId){
this.state="opened";
this.el=document.getElementById(eId||'sideBar');
this.closeBar=document.getElementById(closeId||'closeBar');
var self=this;
this.el.addEventListener('click',function(event){
if (event.target !== self.el){
self.triggerSwitch();
}
});
};
SideBar.prototype.triggerSwitch=function(){
if (this.state==="opened") {
this.close();
}else{
this.open();
}
};
SideBar.prototype.close=function(){
this.state="closed";
};
SideBar.prototype.open=function(){
this.state=="opened";
};
var sidebar=new SideBar();
})();
Lee_Zf
http://www.oschina.net/translate/20-powerful-sublimetext-plugins
可以看看这个 想要的里面解释的很详细
yyc大win
老师的意思是做一个判断,用来防止你点击的不是span元素,而是sidebar那个整体框架的其他地方时,就用一个事件来监听:如果你点击的不是这些地方,那我就执行triggerSwich函数~~这是一个逆向思维,效果就是比你一个一个的去监听closebar和sidebar里其他的元素,要来的方便多了~
jeanneze
夏木家的猫
dedoyle
coolText
活著会是美事106549
活著会是美事106549