react-klasha
Version:
This is an reactJS library for implementing klasha payment gateway
1 lines • 3.48 kB
JavaScript
var GestureController=function(){function t(){this.gestureId=0;this.requestedStart=new Map;this.disabledGestures=new Map;this.disabledScroll=new Set}t.prototype.createGesture=function(t){return new GestureDelegate(this,this.newID(),t.name,t.priority||0,!!t.disableScroll)};t.prototype.createBlocker=function(t){if(t===void 0){t={}}return new BlockerDelegate(this,this.newID(),t.disable,!!t.disableScroll)};t.prototype.start=function(t,e,r){if(!this.canStart(t)){this.requestedStart.delete(e);return false}this.requestedStart.set(e,r);return true};t.prototype.capture=function(t,e,r){if(!this.start(t,e,r)){return false}var i=this.requestedStart;var s=-1e4;i.forEach((function(t){s=Math.max(s,t)}));if(s===r){this.capturedId=e;i.clear();var l=new CustomEvent("ionGestureCaptured",{detail:{gestureName:t}});document.dispatchEvent(l);return true}i.delete(e);return false};t.prototype.release=function(t){this.requestedStart.delete(t);if(this.capturedId===t){this.capturedId=undefined}};t.prototype.disableGesture=function(t,e){var r=this.disabledGestures.get(t);if(r===undefined){r=new Set;this.disabledGestures.set(t,r)}r.add(e)};t.prototype.enableGesture=function(t,e){var r=this.disabledGestures.get(t);if(r!==undefined){r.delete(e)}};t.prototype.disableScroll=function(t){this.disabledScroll.add(t);if(this.disabledScroll.size===1){document.body.classList.add(BACKDROP_NO_SCROLL)}};t.prototype.enableScroll=function(t){this.disabledScroll.delete(t);if(this.disabledScroll.size===0){document.body.classList.remove(BACKDROP_NO_SCROLL)}};t.prototype.canStart=function(t){if(this.capturedId!==undefined){return false}if(this.isDisabled(t)){return false}return true};t.prototype.isCaptured=function(){return this.capturedId!==undefined};t.prototype.isScrollDisabled=function(){return this.disabledScroll.size>0};t.prototype.isDisabled=function(t){var e=this.disabledGestures.get(t);if(e&&e.size>0){return true}return false};t.prototype.newID=function(){this.gestureId++;return this.gestureId};return t}();var GestureDelegate=function(){function t(t,e,r,i,s){this.id=e;this.name=r;this.disableScroll=s;this.priority=i*1e6+e;this.ctrl=t}t.prototype.canStart=function(){if(!this.ctrl){return false}return this.ctrl.canStart(this.name)};t.prototype.start=function(){if(!this.ctrl){return false}return this.ctrl.start(this.name,this.id,this.priority)};t.prototype.capture=function(){if(!this.ctrl){return false}var t=this.ctrl.capture(this.name,this.id,this.priority);if(t&&this.disableScroll){this.ctrl.disableScroll(this.id)}return t};t.prototype.release=function(){if(this.ctrl){this.ctrl.release(this.id);if(this.disableScroll){this.ctrl.enableScroll(this.id)}}};t.prototype.destroy=function(){this.release();this.ctrl=undefined};return t}();var BlockerDelegate=function(){function t(t,e,r,i){this.id=e;this.disable=r;this.disableScroll=i;this.ctrl=t}t.prototype.block=function(){if(!this.ctrl){return}if(this.disable){for(var t=0,e=this.disable;t<e.length;t++){var r=e[t];this.ctrl.disableGesture(r,this.id)}}if(this.disableScroll){this.ctrl.disableScroll(this.id)}};t.prototype.unblock=function(){if(!this.ctrl){return}if(this.disable){for(var t=0,e=this.disable;t<e.length;t++){var r=e[t];this.ctrl.enableGesture(r,this.id)}}if(this.disableScroll){this.ctrl.enableScroll(this.id)}};t.prototype.destroy=function(){this.unblock();this.ctrl=undefined};return t}();var BACKDROP_NO_SCROLL="backdrop-no-scroll";var GESTURE_CONTROLLER=new GestureController;export{GESTURE_CONTROLLER as G};