Sha256: 6151a8d2aad4143c6436f8887acf28edc51f35a9966846a1b24584433ba5ce0a

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

//= require evil-front/jquery

// Add events to add special class on touch events. It will much faster, than
// `:hover` selector.
//
// By default it add listener to all links and inputs on body.
// But you can add it to any elements:
//
//   $('.pseudolink').evil.tappable();
//
// Or you can set listeners as “live” delegate:
//
//   $('.ajax-updated').evil.tappable('.pseudolink');
//
// Don’t forget about `no-hover` and `styled-taps` Sass mixins.
(function () {
    var start = function () {
        this.classList.add('is-tapped');
    };
    var end = function () {
        var link = $(this);
        setTimeout(function () {
            link.removeClass('is-tapped').
                 addClass('was-tapped').
                 one('mouseenter', function () {
                     link.removeClass('was-tapped');
                 });
        }, 100);
    };

    evil.$.extend({
        tappable: function (selector) {
            if ( selector ) {
                this.on('touchstart', selector, start);
                this.on('touchend touchmove', selector, end);
            } else {
                this.on('touchstart', start);
                this.on('touchend touchmove', end);
            }
        }
    });

    evil.doc.ready(function ($) {
        evil.body.evil.tappable('a, input, label');
    });
})();

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
evil-front-0.3.4 lib/assets/javascripts/evil-front/tappable.js
evil-front-0.3.3 lib/assets/javascripts/evil-front/tappable.js
evil-front-0.3.2 lib/assets/javascripts/evil-front/tappable.js
evil-front-0.3.1 lib/assets/javascripts/evil-front/tappable.js