File "sample.js"

Full Path: /home/analogde/www/Four/js-motion-detection-master/js/sample.js
File size: 650 bytes
MIME-type: text/plain
Charset: utf-8

(function(){
	// consider using a debounce utility if you get too many consecutive events
	$(window).on('motion', function(ev, data){
		console.log('detected motion at', new Date(), 'with data:', data);
		var spot = $(data.spot.el);
		spot.addClass('active');
		setTimeout(function(){
			spot.removeClass('active');
		}, 230);
	});

	// example using a class
	$('.link').on('motion', function(ev, data){
		console.log('motion detected on a link to', data.spot.el.href);
	});

	// examples for id usage
	$('#one').on('motion', function(){
		console.log('touched one');
	});

	$('#another').on('motion', function(){
		console.log('another');
	});
})();