Skip to content

Instantly share code, notes, and snippets.

View ivanlucci1's full-sized avatar

Ivan Lucci ivanlucci1

  • DataArt
  • Brazil
View GitHub Profile
@AlexEmashev
AlexEmashev / swipe-detect.js
Last active August 17, 2023 09:54
Simple snippet to detect swipe in jQuery without jQuery mobile. Works for touch as well as mouse input.
// Demo http://codepen.io/AlexEmashev/pen/BKgQdx
(function ($) {
$.fn.swipeDetector = function (options) {
// States: 0 - no swipe, 1 - swipe started, 2 - swipe released
var swipeState = 0;
// Coordinates when swipe started
var startX = 0;
var startY = 0;
// Distance of swipe
var pixelOffsetX = 0;