2017-01-27 12 views
1

JS를 일시 중지하고 나는 마우스 H1 태그를 마우스를 가져 가면 슬라이더를 일시 정지하고 싶지만, 나는이 자바 스크립트에 문제가 있다고 알고하지 않습니다하지만 난 그것을 작동하게 할 수 아니에요fullpagejs 호버

http://jsfiddle.net/2dhkR/405/

$(document).ready(function() { 
    $('#fullpage').fullpage({ 
     sectionsColor: ['#1bbc9b', '#4BBFC3'], 
     loopBottom: true, 
     afterRender: function() { 
      setInterval(function() { 
       $.fn.fullpage.moveSlideRight(); 
      }, 3000); 
     } 
    }); 


    // the function - set var up just in case 
    // the timer isn't running yet 
    var timer = null; 

    function startSetInterval() { 
     timer = setInterval(showDiv, 5000); 
    } 
    // start function on page load 
    startSetInterval(); 

    // hover behaviour 
    function showDiv() { 
     $('#fullpage h1').hover(function() { 
      clearInterval(timer); 
     }, function() { 
      startSetInterval(); 
     }); 
    } 

}); 

어떤 도움을 주시면 감사하겠습니다, 감사합니다

답변

2

http://jsfiddle.net/2dhkR/407/

var interval = undefined; 
$(document).ready(function() { 

    $('#fullpage').fullpage({ 
     sectionsColor: ['#1bbc9b', '#4BBFC3'], 
     loopBottom: true, 
     afterRender: function() { 
      interval = setInterval(function() { 
       $.fn.fullpage.moveSlideRight(); 
      }, 100); 
     } 
    }); 
    $('#fullpage h1').mouseover(function() { 
    clearInterval(interval); 
    interval = null; 
    }) 
    $('#fullpage h1').mouseout(function() { 
      interval = setInterval(function() { 
       $.fn.fullpage.moveSlideRight(); 
      }, 100); 
    }); 


}); // end document ready 
+0

좋은 반응을 얻으 셨습니다. 꽤 좋은 – colapsnux

0

시도는, mouseenter에 jQuery의 호버()를 사용하는 MouseLeave에 다시 슬라이더를 시작합니다.

$(function() { 
var interval = setInterval(slideSwitch, 10000); 

$('#slideshow').hover(function() { 
    clearInterval(interval); 
}, function() { 
    interval = setInterval(slideSwitch, 10000); 
}); 

});

+0

감사하지만 다음과 같은 오류 ReferenceError가 얻을 : slideSwitch이 정의되지 않은 – colapsnux

+0

u는 UR HTML을 말할 수 있습니다 –

2

아주 간단한 방법 (아마 깨끗한) 부울로 :

var go = true; 

if (go)$.fn.fullpage.moveSlideRight(); 

$('#fullpage h1').hover(function() { 
     go = false; 
     clearInterval(timer); 
    }, function() { 
     go = true; 
     startSetInterval(); 
    }); 
+0

다음 오류가 발생합니다. - ReferenceError : 타이머가 정의되지 않았습니다. - ReferenceError : startSetInterval이 정의되지 않았습니다. 작업 버전으로 바이올린을 업데이트 할 수 있습니까? http://jsfiddle.net/2dhkR/405/ – colapsnux

+0

죄송합니다. 추가해야 할 곳을 설명하지 않았습니다. 다음은 피들입니다. http://jsfiddle.net/2dhkR/410/ – Matteo