我想讓specialist_pagecontent
從左側出現(幻燈片),如blindleftin
從here,但我不能使它與this一起工作。其實,計劃是,而不是hide()
理想將是blindLeftOut('fast');hide()
,而不是show()
我需要show();blindLeftOut('slow')
,但正如我所說,我不能讓blindLeftOut和blindLeftIn爲我工作。從jquery側面滑動(沒有jQuery UI)
回答
給出想要動畫進入和退出viweport
的元素。您期待看到內部元素的圖層。然後將此viewport
的overflow
屬性設置爲hidden
並給它一個特定的寬度/高度。
這樣您就可以動畫viewport
中的元素,以便它們看起來滑入/滑出。
下面是我對您的JS的變化:
//notice the use of the "active" class to save state
$('.specialist_pagecontent').eq(0).addClass("active").animate({ left : 0 }, 500);
$('.specialist').click(function() {
//stop() is used to stop the current animation, so animations don't queue up if many buttons are clicked rapidly
$('.specialist_pagecontent').filter(".active").removeClass("active").stop(true).animate({ left : '-100%' }, 500);
$('.selected-specialist').removeClass('selected-specialist');
$(this).addClass('selected-specialist');
$('.specialist_pagecontent').eq($(this).index('.specialist')).addClass("active").stop(true).animate({ left : 0 }, 500);
});
這裏是我的編輯建議的CSS:
.specialist_pagecontent {
position:absolute;
top:0;
left:-100%;
}
#specialist_lists {
float:left;
border: 1px solid #000000;
position:relative;
width:200px;
height:200px;
overflow:hidden;
}
下面是一個演示:http://jsfiddle.net/Jwkw6/1/
這絕對定位要動畫的元素,這非常有用,因爲它從文檔的常規流中刪除元素(意味着它不會觸發整個頁面重繪當它動畫)。這也創建了我提到的viewport
,創建了一個我們期待看到動畫的窗口。
欣賞努力,但div與「specialist_pagecontent」divs應該留在「專家」權利div –
@Flyer按鈕下方的'.specialist_pagecontent' div放置的原因是因爲沒有足夠的空間水平,我其實並沒有'除了給'#specialist_lists' div一個指定的寬度外,你可以做任何事情,這可以很容易地調整,以匹配你的用戶界面。 – Jasper
我真的很愚蠢。這看起來不錯。因爲它會「動態」,所以唯一需要弄清楚的是specialist_lists的高度 –
我認爲jQuery的animate函數可能對您有用。
你需要做的是將一個隱藏的div放在窗口外面添加到你的HTML中(或者可以使用jquery在document.ready
事件上動態添加它,如果你喜歡的話)以及使用上面提到的動畫函數將其滑入和滑出並將其綁定到菜單項的點擊功能。
工作小提琴
這裏是你
- 1. jQuery show hide從左側滑動面板
- 2. 從右側滑動(jQuery)
- 3. jQuery Mobile滑動到「沒有」
- 4. 沒有使用jQuery UI的頁面滑塊UI
- 5. jquery滑動沒有jQuery移動庫
- 6. 的Jquery滑動至左側
- 7. jquery從右側滑出div
- 8. jQuery:只從右側滑入
- 9. jQuery UI自動滑動
- 10. 沒有數字的JQuery UI滑塊
- 11. jQuery滑動用戶界面不滑動
- 12. 從右側滑動面板
- 13. jQuery滑動內容DIV - 從右側滑動而非從頂部滑動
- 14. 從滑動條外側動畫滑塊的Jquery
- 15. 滑動面板從左側到右側
- 16. JQuery UI平滑列動畫
- 17. jquery沒有jquery UI插件移動img
- 18. jQuery - 側滑菜單
- 19. 使用jQuery/jQuery UI滑動文字
- 20. 滑動面板jquery
- 21. 滑動面板 - jQuery
- 22. jquery滑動面板
- 23. jquery ui滑塊
- 24. 滑動時獲取jquery-UI滑塊值
- 25. 動畫沒有jQuery,左右滑動
- 26. jquery用戶界面無法從左側拖動到右側
- 27. 有頁面從右側滑入離子
- 28. javascript滑動(側面)面板
- 29. jquery滑動圖標的左側菜單
- 30. jQuery的:滑動切換到左側
工作JSFiddle我結合2個小提琴製作於blindLeftOut和blindLeftIn工作的電話。查看我的答案以獲取詳細信息,並讓我知道這是您尋找的內容。另外,是否在你的問題有關'而不是show()的錯字我需要show(); blindLeftOut('slow')'?如果不是'而不是show()我需要show(); blindLeftIn('slow')'而不是看到它正在替換show和'blindLeftIn'來顯示。 – Nope