controller.min.js 2.2 KB

1
  1. define(function(o,t,n){"use strict";var i=o("../util"),r=o("../base"),e=function(o){e.superclass.constructor.call(this,o),this.userConfig=i.mix({},o),this.init()};return i.extend(e,r,{init:function(){var o=this;o.xscroll=o.userConfig.xscroll},add:function(o,t){var n=this;if(t=i.extend({captureBounce:!1,stopPropagation:!0},t),n.__scrolls||(n.__scrolls={}),o.guid&&!n.__scrolls[o.guid])return o.parentscroll=n.xscroll,n._bind(o),n.__scrolls[o.guid]=o},remove:function(o){var t=this;if(o&&o.guid){var n=t.__scrolls[o.guid];n&&(n.parentscroll=null,t._unbind(o),n=null)}},get:function(o){return o?this.__scrolls[o]:this.__scrolls},_unbind:function(o){},_bind:function(o){var t=this,n=t.xscroll;n.renderTo.addEventListener("touchstart",function(){n._resetLockConfig()}),o.renderTo.addEventListener("touchstart",function(){o._resetLockConfig()}),n.on("panend",n._resetLockConfig),o.on("panend",o._resetLockConfig),o.on("panstart",function(t){if(!o.userConfig.lockY&&!n.userConfig.lockY){if(o.isBoundryOut())return void(n.userConfig.lockY=!0);16==t.direction&&o.getBoundryOutTop()>=0?o.userConfig.lockY=!0:8==t.direction&&o.getBoundryOutTop()>=0&&o.getBoundryOutBottom()<0&&(n.userConfig.lockY=!0),8==t.direction&&o.getBoundryOutBottom()>=0?o.userConfig.lockY=!0:16==t.direction&&o.getBoundryOutBottom()>=0&&o.getBoundryOutTop()<0&&(n.userConfig.lockY=!0),o.getBoundryOutTop()<0&&o.getBoundryOutBottom()<0&&(n.userConfig.lockY=!0)}if(!o.userConfig.lockX&&!n.userConfig.lockX){if(o.isBoundryOut())return void(n.userConfig.lockX=!0);4==t.direction&&o.getBoundryOutLeft()>=0?o.userConfig.lockX=!0:2==t.direction&&o.getBoundryOutLeft()>=0&&o.getBoundryOutRight()<0&&(n.userConfig.lockX=!0),2==t.direction&&o.getBoundryOutRight()>=0?o.userConfig.lockX=!0:4==t.direction&&o.getBoundryOutRight()>=0&&o.getBoundryOutLeft()<0&&(n.userConfig.lockX=!0),o.getBoundryOutLeft()<0&&o.getBoundryOutRight()<0&&(n.userConfig.lockX=!0)}!o.userConfig.lockX&&n.userConfig.lockX&&(2==t.direction||4==t.direction?n.userConfig.lockY=!0:o.userConfig.lockX=!0),!o.userConfig.lockY&&n.userConfig.lockY&&(8==t.direction||16==t.direction?n.userConfig.lockX=!0:o.userConfig.lockY=!0)})}}),"object"==typeof n&&n.exports?void(n.exports=e):e});