"Lodash throttle, debounce"의 두 판 사이의 차이

28번째 줄: 28번째 줄:
* [[Lodash]]
* [[Lodash]]
* [[스로틀, 디바운스]]
* [[스로틀, 디바운스]]
* [[jQuery throttle, debounce]]


[[분류: Lodash]]
[[분류: Lodash]]

2018년 6월 24일 (일) 17:21 판

1 개요

Lodash throttle, debounce
Lodash 스로틀, 디바운스
<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/lodash.js/3.10.1/lodash.min.js'></script>
<script>
$(window).mousemove( function(e) {
	$('#output1').val( e.clientX + ', ' + e.clientY )
})
$(window).mousemove( _.throttle( function(e) {
	$('#output2').val( e.clientX + ', ' + e.clientY )
}, 500))
$(window).mousemove( _.debounce( function(e) {
	$('#output3').val( e.clientX + ', ' + e.clientY )
}, 500))
</script>

2 같이 보기

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