1 |
- "use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames=_interopRequireDefault(require("../helpers/libs/classNames")),_styleToCssString=_interopRequireDefault(require("../helpers/libs/styleToCssString")),_nearest=require("../helpers/shared/nearest"),_gestures=require("../helpers/shared/gestures"),_useNativeAPI=require("../helpers/hooks/useNativeAPI"),_rubberband=require("../helpers/shared/rubberband");function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _defineProperty(t,e,r){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _toPropertyKey(t){t=_toPrimitive(t,"string");return"symbol"==_typeof(t)?t:String(t)}function _toPrimitive(t,e){if("object"!=_typeof(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0===r)return("string"===e?String:Number)(t);r=r.call(t,e||"default");if("object"!=_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(0,_baseComponent.default)({useExport:!0,properties:{prefixCls:{type:String,value:"wux-floating-panel"},defaultAnchors:{type:Array,value:[]}},data:{wrapStyle:"",possibles:[],moving:!1},computed:{classes:["prefixCls",function(t){return{wrap:(0,_classNames.default)(t),hd:"".concat(t,"__hd"),bd:"".concat(t,"__bd"),bar:"".concat(t,"__bar"),mask:"".concat(t,"__mask")}}]},methods:_defineProperty({onTouchStart:function(t){this.data.moving||1<(0,_gestures.getPointsNumber)(t)||(this.startY=(0,_gestures.getTouchPoints)(t).y,this.moveY=0,this.endY=0,this.setData({moving:!0}))},onTouchMove:function(t){!this.data.moving||1<(0,_gestures.getPointsNumber)(t)||(this.moveY=(0,_gestures.getTouchPoints)(t).y,t=this.moveY-this.startY,t=(0,_rubberband.rubberbandIfOutOfBounds)(Math.abs(this.lastY+t),-this.bounds.bottom,-this.bounds.top),this.setTransform(-Math.round(t)))},onTouchEnd:function(t){var e=this;!this.data.moving||1<(0,_gestures.getPointsNumber)(t)||(this.endY=(0,_gestures.getTouchPoints)(t).y,t=this.endY-this.startY,t=this.lastY+t,this.lastY=(0,_nearest.nearest)(this.data.possibles,t),this.setTransform(Math.round(this.lastY),.3),setTimeout(function(){return e.setData({moving:!1})},300))},setTransform:function(t,e){var r=this,s=(0,_styleToCssString.default)({height:"".concat(-this.bounds.top,"px"),transform:"translate3d(0, calc(100% + ".concat(t,"px), 0)"),transition:e?"cubic-bezier(0, 0, 0.2, 1.15) ".concat(e,"s"):"none"});this.data.wrapStyle!==s&&(this.setData({wrapStyle:s},function(){e&&setTimeout(function(){return r.setTransform(t)},1e3*e)}),this.triggerEvent("heightChange",{height:-t,minHeight:-this.bounds.bottom,maxHeight:-this.bounds.top,animating:!!e}))}},"export",function(){var e=this;return{setHeight:function(t){e.setTransform(-t,(1<arguments.length&&void 0!==arguments[1]?arguments[1]:{immediate:!1}).immediate?.3:0),e.lastY=-t}}}),created:function(){this.moveY=0,this.endY=0,this.startY=0,this.lastY=0},attached:function(){var t=this.data.defaultAnchors.filter(function(t){return"number"==typeof t}).filter(function(t){return 0<t}),t=0===t.length?[-(0,_useNativeAPI.getSystemInfoSync)(["window"]).windowHeight]:t.map(function(t){return-t}),e={top:Math.round(t[t.length-1]),bottom:Math.round(t[0])};this.bounds=e,this.lastY=e.bottom,this.setData({possibles:t}),this.setTransform(e.bottom)}});
|