"Jquery-throttle-debounce"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
7번째 줄: 7번째 줄:


==예제==
==예제==
<source lang='html'>
<syntaxhighlight lang='html'>
<b>Mousemove Event</b>
<b>Mousemove Event</b>
<br>Nothing <input type='text' id='output1' disabled>
<br>Nothing <input type='text' id='output1' disabled>
26번째 줄: 26번째 줄:
}))
}))
</script>
</script>
</source>
</syntaxhighlight>
<jsfiddle height='400'>w7qvuh12</jsfiddle>
<jsfiddle height='400'>w7qvuh12</jsfiddle>



2020년 11월 2일 (월) 02:54 판

1 개요

jQuery throttle / debounce
jQuery 스로틀 / 디바운스
jquery-throttle-debounce

2 예제

<b>Mousemove Event</b>
<br>Nothing <input type='text' id='output1' disabled>
<br>Throttled <input type='text' id='output2' disabled>
<br>Debounced <input type='text' id='output3' disabled>

<script src='//cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>
<script src='//cdnjs.cloudflare.com/ajax/libs/jquery-throttle-debounce/1.1/jquery.ba-throttle-debounce.min.js'></script>
<script>
$(window).mousemove( function(e) {
	$('#output1').val( e.clientX + ', ' + e.clientY );
})
$(window).mousemove( $.throttle( 500, function(e) {
	$('#output2').val( e.clientX + ', ' + e.clientY );
}))
$(window).mousemove( $.debounce( 500, function(e) {
	$('#output3').val( e.clientX + ', ' + e.clientY );
}))
</script>

3 같이 보기

4 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}