-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathjquery.slideandswipe.min.js
1 lines (1 loc) · 1.43 KB
/
jquery.slideandswipe.min.js
1
!function(a,b,c,d){"use strict";a.fn.slideAndSwipe=function(b){function g(a,b,g,h){"start"==b&&(e=c.hasClass("ssm-nav-visible")?0:d);var i;"move"==b&&"left"==g?(i=e<0?e-h:-h,j(i,0)):"move"==b&&"right"==g?(i=e<0?e+h:h,j(i,0)):"cancel"==b&&"left"==g&&0===e?j(0,f.speed):"end"==b&&"left"==g?k():"end"!=b&&"cancel"!=b||"right"!=g||console.log("end")}function h(){return/Safari/.test(navigator.userAgent)&&/Apple Computer/.test(navigator.vendor)}function i(){return/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)}function j(b,e){c.css("transition-duration",(e/1e3).toFixed(1)+"s"),b>=0&&(b=0),b<=d&&(b=d),h()||i()?c.css("-webkit-transform","translate("+b+"px,0)"):c.css("transform","translate("+b+"px,0)"),"0"==b&&(a(".ssm-toggle-nav").addClass("ssm-nav-visible"),a("html").addClass("is-navOpen"),a(".ssm-overlay").fadeIn())}var c=a(this),d=-c.outerWidth(),e=d,f=a.extend({triggerOnTouchEnd:!0,swipeStatus:g,allowPageScroll:"vertical",threshold:100,excludedElements:"label, button, input, select, textarea, .noSwipe",speed:250},b);c.swipe(f);var k=function(){c.removeClass("ssm-nav-visible"),j(d,f.speed),a("html").removeClass("is-navOpen"),a(".ssm-overlay").fadeOut()},l=function(){c.addClass("ssm-nav-visible"),j(0,f.speed)};a(".ssm-toggle-nav").click(function(a){c.hasClass("ssm-nav-visible")?k():l(),a.preventDefault()})}}(window.jQuery||window.$,document,window),"undefined"!=typeof module&&module.exports&&(module.exports=slideAndSwipe);