第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

課程代碼——20170503

如果鼠標(biāo)移出菜單欄,然后再進(jìn)去時(shí),顯示就會(huì)不正確了,是不是因?yàn)関ar leftCorner=mouseTrack[mouseTrack.length-2];計(jì)算會(huì)出錯(cuò)。

代碼如下:

<script?src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script>
??//二進(jìn)制的正負(fù)表示是在最高位,1表示負(fù),0表示正,抑或運(yùn)算是僅當(dāng)對(duì)應(yīng)的2位有一位為1時(shí)才返回1,反過(guò)來(lái)如果抑或運(yùn)算返回的結(jié)果是0(正),則一定是2個(gè)1,或者2個(gè)0.反之,則是一個(gè)0,一個(gè)1
??function?sameSign(a,b){
????return?(a^b)>=0;
??}
??//向量的定義
??function?vector(a,b){
????return?{
??????x:b.x-a.x,//終點(diǎn)的坐標(biāo)減去起點(diǎn)的坐標(biāo)
??????y:b.y-a.y
????}
??}
??//向量叉乘公式
??function?vectorProduct(v1,v2){
????return?v1.x*v2.y-v2.x*v1.y
??}
??//叉乘判斷方法
??function?isPointInTrangle(p,a,b,c){//p:鼠標(biāo)當(dāng)前點(diǎn)的坐標(biāo),a:鼠標(biāo)上一次的坐標(biāo),b,c:二級(jí)菜單上下邊緣坐標(biāo)
????var?pa=vector(p,a);
????var?pb=vector(p,b);
????var?pc=vector(p,c);

????var?t1=vectorProduct(pa,pb);
????var?t2=vectorProduct(pb,pc);
????var?t3=vectorProduct(pc,pa);

????return?sameSign(t1,t2)&&sameSign(t2,t3);
??}

??function?needDelay(elem,leftCorner,currMousePos){//用offset方法獲取上下邊緣
????var?offset=elem.offset();

????var?topLeft={
??????x:offset.left,
??????y:offset.top
????};

????var?bottomLeft={
??????x:offset.left,
??????y:offset.top+elem.height()
????};
????return?isPointInTrangle(currMousePos,leftCorner,topLeft,bottomLeft)
??}
</script>
<script>
??$(function(){
????var?sub=$('#sub');
????var?activeRow;//選中的行
????var?activeMenu;//選中的行對(duì)應(yīng)的二級(jí)菜單
????var?timer;//setTimeout返回的計(jì)時(shí)器id
????var?mouseInSub=false;//當(dāng)前鼠標(biāo)是否在子菜單里
????sub.on('mouseenter',function(e){
??????mouseInSub=true;
????}).on('mouseleave',function(e){
??????mouseInSub=false;
????});

????//創(chuàng)建數(shù)組,記錄
????var?mouseTrack=[];//數(shù)組跟蹤記錄鼠標(biāo)的位置
????var?moveHandler=function(e){//鼠標(biāo)離開(kāi)菜單時(shí),需要對(duì)綁定在document上的mousemove事件解綁,以免影響頁(yè)面中其他組件,所以將事件監(jiān)聽(tīng)函數(shù)獨(dú)立出來(lái),方便后續(xù)解綁操作
??????mouseTrack.push({
????????x:e.pageX,
????????y:e.pageY
??????});
??????if(mouseTrack.length>3){
????????mouseTrack.shift();
??????}
????};
????$('#test')
??????.on('mouseenter',function(e){
????????//sub.removeClass('none');

????????$(document).bind('mousemove',moveHandler);//mousemove事件一般綁定在document上
??????})
??????.on('mouseleave',function(e){
????????sub.addClass('none');//鼠標(biāo)移動(dòng)到一級(jí)菜單時(shí),二級(jí)菜單隱藏

????????if(activeRow){//鼠標(biāo)離開(kāi)一級(jí)菜單,如果存在激活的行,樣式要去掉,并把變量置空
??????????activeRow.removeClass('active');
??????????activeRow=null;
????????}
????????if(activeMenu){
??????????activeMenu.addClass('none');
??????????activeMenu=null;
????????}

????????$(document).unbind('mouseove',moveHandler);
??????})
??????.on('mouseenter','li',function(e){//一級(jí)菜單的列表項(xiàng)綁定事件
????????sub.removeClass('none');//鼠標(biāo)移動(dòng)到一級(jí)菜單時(shí),二級(jí)菜單顯示
????????if(!activeRow){//移過(guò)去沒(méi)有激活的一級(jí)菜單
??????????activeRow=$(e.target);
??????????activeRow.addClass('active');

??????????activeMenu=$('#'+activeRow.data('id'));
??????????activeMenu.removeClass('none');
??????????return;
????????}
????????//debounce:mouseenter頻繁觸發(fā)時(shí),只執(zhí)行最后一次
????????if(timer){
??????????clearTimeout(timer);
????????}
????????console.log(mouseTrack)
????????var?currMousePos=mouseTrack[mouseTrack.length-1];
????????var?leftCorner=mouseTrack[mouseTrack.length-2];
????????var?delay=needDelay(sub,leftCorner,currMousePos);//是否需要延遲
????????if(delay){//如果在三角形內(nèi),需要延遲
??????????timer=setTimeout(function(){
????????????if(mouseInSub){
??????????????return;
????????????}
????????????activeRow.removeClass('active');
????????????activeMenu.addClass('none');

????????????activeRow=$(e.target);
????????????activeRow.addClass('active');
????????????activeMenu=$('#'+activeRow.data('id'));
????????????activeMenu.removeClass('none');
????????????timer=null;//事件觸發(fā)時(shí),如果計(jì)時(shí)器并沒(méi)有執(zhí)行,就把它清掉,這樣能保證事件觸發(fā)停止時(shí),會(huì)執(zhí)行最后一次,而其他的都會(huì)被忽略
??????????},300);
????????}else{
??????????var?prevActiveRow=activeRow;
??????????var?prevActiveMenu=activeMenu;

??????????activeRow=$(e.target);
??????????activeMenu=$('#'+activeRow.data('id'));

??????????prevActiveRow.removeClass('active');
??????????prevActiveMenu.addClass('none');//上一次二級(jí)菜單隱藏
??????????activeRow.addClass('active');
??????????activeMenu.removeClass('none');//上一次二級(jí)菜單顯示
????????}
??????});

??});
</script>


正在回答

5 回答

你好, 你90行的代碼有問(wèn)題,mousemove

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

aSuncat 提問(wèn)者

非常感謝!
2017-05-22 回復(fù) 有任何疑惑可以回復(fù)我~
#2

aSuncat 提問(wèn)者

謝謝。
2017-05-22 回復(fù) 有任何疑惑可以回復(fù)我~

不會(huì)報(bào)錯(cuò)么

0 回復(fù) 有任何疑惑可以回復(fù)我~

?非常感謝哦。。我正好非常懶得寫(xiě)。。復(fù)制粘貼了。我真的非常懶啊啊啊啊啊啊啊啊啊

0 回復(fù) 有任何疑惑可以回復(fù)我~

border-right-width? !===?border-raight-width

css 第十四行

0 回復(fù) 有任何疑惑可以回復(fù)我~

html和css代碼:

??<style>
????.wrap{
??????position:relative;
??????width:200px;
??????left:50px;
??????top:50px;
????}
????ul{
??????padding:15px?0;
??????margin:9px;
??????list-style:none;
??????background:#6c6669;
??????color:#fff;
??????border-raight-width:0;
????}
????li{
??????display:block;
??????height:30px;
??????line-height:30px;
??????padding-left:12px;
??????cursor:pointer;
??????font-size:14px;
??????position:relative;
????}
????li.active{
??????background:#999395;
????}
????li?span:hover{
??????color:#c81623;
????}
????.none{
??????display:none;
????}
????#sub{
??????width:600px;
??????position:absolute;
??????border:1px?solid?#f7f7f7;
??????background:#f7f7f7;
??????box-shadow:2px?0?5px?rgba(0,0,0,.3);
??????left:200px;
??????top:0;
??????box-sizing:border-box;
??????margin:0;
??????padding:10px;
????}
????.sub_content?a{
??????font-size:12px;
??????color:#666;
??????text-decoration:none;
????}
????.sub_content?dd?a{
??????border-left:1px?solid?#e0e0e0;
??????padding:0?10px;
??????margin:4px?0;
????}
????.sub_content?dl{
??????overflow:hidden;
????}
????.sub_content?dt{
??????float:left;
??????width:70px;
??????font-weight:bold;
??????clear:left;
??????position:relative;
????}
????.sub_content?dd{
??????float:left;
??????margin-left:5px;
??????border-top:1px?solid?#eee;
??????margin-bottom:5px;
????}
????.sub_content?dt?i{
??????width:4px;
??????height:14px;
??????font:400?9px/14px?consolas;
??????position:absolute;
??????right:5px;
??????top:5px;
????}
??</style>
</head>
<body>
<div?class="wrap"?id="test">
??<ul>
????<li?data-id="a">
??????<span>家用電器</span>
????</li>
????<li?data-id="b">
??????<span>家用電器</span>
????</li>
????<li?data-id="c">
??????<span>家用電器</span>
????</li>
????<li?data-id="d">
??????<span>家用電器</span>
????</li>
????<li?data-id="e">
??????<span>家用電器</span>
????</li>
??</ul>
??<div?id="sub"?class="none">
????<div?id="a"?class="sub_content?none">
??????<dl>
????????<dt>
??????????<a?href="#">電視<i>&gt;</i></a>
????????</dt>
????????<dd>
??????????<a?href="#">合資品牌</a>
??????????<a?href="#">國(guó)產(chǎn)品牌</a>
??????????<a?href="#">互聯(lián)網(wǎng)品牌</a>
????????</dd>
??????</dl>
??????<dl>
????????<dt>
??????????<a?href="#">電視<i>&gt;</i></a>
????????</dt>
????????<dd>
??????????<a?href="#">合資品牌</a>
??????????<a?href="#">國(guó)產(chǎn)品牌</a>
??????????<a?href="#">互聯(lián)網(wǎng)品牌</a>
????????</dd>
????????<dd>
??????????<a?href="#">合資品牌</a>
??????????<a?href="#">國(guó)產(chǎn)品牌</a>
??????????<a?href="#">互聯(lián)網(wǎng)品牌</a>
????????</dd>
??????</dl>
????</div>
????<div?id="b"?class="sub_content?none">
??????<dl>
????????<dt>
??????????<a?href="#">電視<i>&gt;</i></a>
????????</dt>
????????<dd>
??????????<a?href="#">合資品牌</a>
??????????<a?href="#">國(guó)產(chǎn)品牌</a>
??????????<a?href="#">互聯(lián)網(wǎng)品牌</a>
????????</dd>
??????</dl>
????</div>
????<div?id="c"?class="sub_content?none">
??????<dl>
????????<dt>
??????????<a?href="#">電視<i>&gt;</i></a>
????????</dt>
????????<dd>
??????????<a?href="#">合資品牌</a>
??????????<a?href="#">國(guó)產(chǎn)品牌</a>
??????????<a?href="#">互聯(lián)網(wǎng)品牌</a>
????????</dd>
????????<dd>
??????????<a?href="#">合資品牌</a>
??????????<a?href="#">國(guó)產(chǎn)品牌</a>
??????????<a?href="#">互聯(lián)網(wǎng)品牌</a>
????????</dd>
??????</dl>
????</div>
????<div?id="d"?class="sub_content?none">
??????<dl>
????????<dt>
??????????<a?href="#">電視<i>&gt;</i></a>
????????</dt>
????????<dd>
??????????<a?href="#">合資品牌</a>
??????????<a?href="#">國(guó)產(chǎn)品牌</a>
??????????<a?href="#">互聯(lián)網(wǎng)品牌</a>
????????</dd>
????????<dd>
??????????<a?href="#">合資品牌</a>
??????????<a?href="#">國(guó)產(chǎn)品牌</a>
??????????<a?href="#">互聯(lián)網(wǎng)品牌</a>
????????</dd>
??????</dl>
????</div>
????<div?id="e"?class="sub_content?none">
??????<dl>
????????<dt>
??????????<a?href="#">電視<i>&gt;</i></a>
????????</dt>
????????<dd>
??????????<a?href="#">合資品牌</a>
??????????<a?href="#">合資品牌</a>
??????????<a?href="#">國(guó)產(chǎn)品牌</a>
??????????<a?href="#">互聯(lián)網(wǎng)品牌</a>
????????</dd>
????????<dd>
??????????<a?href="#">合資品牌</a>
??????????<a?href="#">國(guó)產(chǎn)品牌</a>
??????????<a?href="#">互聯(lián)網(wǎng)品牌</a>
??????????<a?href="#">互聯(lián)網(wǎng)品牌</a>
??????????<a?href="#">互聯(lián)網(wǎng)品牌</a>
????????</dd>
??????</dl>
????</div>
??</div>

</div>


1 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

課程代碼——20170503

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)