The Hammer.js JavaScript library allows us to handle gesture touch events that take place when running our code on a touch screen device.

The following code sample shows how simple it is to use this library. You just need to pass over the name of the gesture touch event you want to handle and the function you want to be invoked when that event takes place.

<!DOCTYPE html>
    <title>hammer.js demo</title>
    <script src="hammer.min.js" type="text/javascript"></script>
    <div id="something"><h1>something</h1></div>
    <script type="text/javascript">
        var element = document.getElementById('something');
        Hammer(element).on("drag", function(event) {
        Hammer(element).on("tap", function(event) {

The following video clip overviews this code sample, shows its execution and explains it step by step.

You can find more video clips, code samples and various other training material for learning how to use this JavaScript library in my free courses web site at

Leave a Reply

Your email address will not be published. Required fields are marked *