This repository has been archived by the owner on Aug 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
panels.min.js
2 lines (2 loc) · 2.56 KB
/
panels.min.js
1
2
/*! panels by quoid v0.2.0 | GPL V2 License | http://quoid.github.io/panels/index.html */
!function(e){"use strict";function n(n){var a=".panel-"+n,s=e(a).outerHeight(!0),o=e(a).outerWidth(!0);if(e("body").addClass("panel-"+n+"-active").css("overflow","hidden"),e(a).addClass("panel-opening"),r=2,e(a).is(".push-panel, .reveal-panel"))switch(n){case"top":c.css("transform","translate3d(0px, "+s+"px, 0px)");break;case"bottom":c.css("transform","translate3d(0px, "+-s+"px, 0px)");break;case"left":c.css("transform","translate3d("+o+"px, 0px, 0px)");break;case"right":c.css("transform","translate3d("+-o+"px, 0px, 0px)")}}function a(n){var a=".panel-"+n,s="panel-top-active panel-bottom-active panel-left-active panel-right-active";e("body").removeClass(s),c.css("transform",""),e(a).addClass("panel-closing").removeClass("panel-force-close"),r=2}function s(){c.bind("touchmove",function(){return!1})}function o(){c.unbind("touchmove")}function t(){var n=e(".panel-focus");n.css("overflow-y","hidden"),setTimeout(function(){n.css("overflow-y","auto"),n.attr("style","")})}var r=1,l=350,i="transitionend webkitTransitionEnd",c=e(".panel-wrapper");e.panels={show:function(a){var o=a.position,t=".panel-"+o,i=e(t).length;if(1!=i)return console.error("only one panel element of the same position is allowed"),!1;switch(a.forceClose===!0&&e(t).addClass("panel-force-close"),null!==a.timeOut&&(l=a.timeOut),o){case"top":case"bottom":case"left":case"right":1===r?(n(o),s()):2===r?console.error("panel animation in progress"):console.error("panel already shown");break;default:console.error("incorrect argument")}},hide:function(e){var n=e.position;switch(n){case"top":case"bottom":case"left":case"right":1===r?console.error("panel already hidden"):2===r?console.error("panel already in progress"):(null!==e.timeOut&&(l=e.timeOut),a(n),o());break;default:console.error("incorrect argument")}}},e(".panel").on(i,function(n){"z-index"==n.originalEvent.propertyName&&(e(this).hasClass("panel-opening")?(e(this).addClass("panel-focus"),t(),setTimeout(function(){e(".panel-focus").removeClass("panel-opening"),r=3},l)):e(this).hasClass("panel-closing")&&(e(this).removeClass("panel-focus"),e("body").attr("style",""),o(),setTimeout(function(){e(".panel-closing").removeClass("panel-closing"),r=1},l)))}),e("body").click(function(n){e(n.target).closest(".panel").length||e(".panel-focus").hasClass("panel-force-close")||3!=r||a("focus")}),e("body").keydown(function(n){var a=e(n.target).parent(),s=[32,33,34,35,36,37,38,39,40],o=n.which;if(!a.hasClass("panel"))switch(r){case 1:break;case 2:case 3:if(-1!==e.inArray(o,s))return!1}})}(jQuery);