서로 일치하는 두 가지 유형의 애니메이션을 실행 중입니다.둘째 함수 교대로 jQuery 애니메이션을 조건 적으로 중지합니다.
- 클릭하면 사이드 바가 나타납니다. 사이드 바 내 호버 트윗 애니메이션이 실행 열려, 때
- 사이드 바뿐만 아니라 트윗을 드러내는 가져가,가 나는 트윗 영역을 가져 가면,
내 문제가 (jsFiddle 참조) , 그것은 내가하고 싶지 않은 내 사이드 바를 닫습니다.
수많은 if 및 else 문이 내 스크립트이지만 많은 노력을 기울일 경우에도 필요합니다. 누구든지 도와 줄 수 있습니까? 내가가 완벽한 높이를 밀어 필요가 있기 때문에, 당신은 내가 애니메이션까지 트위터 슬라이드를 결합하고있어 이유를 궁금해하는 경우 http://jsfiddle.net/motocomdigital/c8Mey/15/
// The variables
var $sideBar = $("#sidebar"),
$openClose = $("#menu"),
$tweet = $("#latest-tweet");
// The twitter script load via JSON
$("#tweet").tweet({
count: 1,
username: ["motocomdigital"],
loading_text: "searching twitter...",
intro_text: null,
outro_text: null
}).bind("loaded", function(){
// Binded function and variable because I need the tweet's dynamic height
// Tweet height, once tweet has loaded
var tweetHeight = $("#tweet").innerHeight();
// Tweet (red block) .hover action
$tweet.hover(function() {
// Opens tweet (red block) horizonally and vertically
$tweet.stop().animate({ top: "-" + tweetHeight + "px", right: "0" }, 300);
// Opens sidebar horizonally
$sideBar.stop().animate({ right: "0" }, 300);
}, function() {
// Closes tweet (red block) horizonally and vertically
$tweet.stop().animate({ top: "0", right: "-250px" }, 300);
// Closes sidebar horizonally
$sideBar.stop().animate({ right: "-250px" }, 300);
});
});
// The side bar and tweet animation sequence when "open menu" is clicked.
$openClose.on('click', function() {
if ($openClose.html() == 'Close Menu') { // run if button says "Close Menu"
// Closes sidebar horizonally
$sideBar.stop().animate({ right: "-250px" }, 300);
// Closes tweet horizontally
$tweet.stop().animate({ right: "-250px" }, 300);
// Changes the button text to open
$openClose.html('Open Menu ');
} else { // run if button says "Open Menu"
// Opens sidebar horizonally
$sideBar.stop().animate({ right: "0" }, 300);
// Opens tweet horizontal
$tweet.stop().animate({ right: "0" }, 300);
// Changes the button text to close
$openClose.html('Close Menu');
}
});
-
내 스크립트는 아래이지만, live demo을 보려면이 jsFiddle 참조 짹짹, 그리고 짹짹 높이가 동적이며, 다양한 높이 수 있습니다.
어떤 도움
이 내 국수로 정말 대단가 굽고 것입니다 해결하기 위해 :/http://jsfiddle.net/motocomdigital/c8Mey/15/
Nicosunshine, nearlly 거기에 가도록 해줘서 고마워!하지만 사이드 바를 열고 닫은 후에 빨간색 트윗 영역 위로 스크롤하면 짹짹과 사이드 바가 돌아 가지 않습니다. 그렇지 않으면 이것과 별개로, 그것은해야대로 작동합니다. – Joshc
죄송합니다. 지금은 불편합니다. – NicoSantangelo
야, 너 천재 야! 정말 고맙습니다!!! 진실하고 틀린 것을 가진 좋은 움직임은, 당신이 그것을 할 수 있었다는 것을 몰랐다 – Joshc