mp-touch-cell
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,273 +0,1 @@ | ||
module.exports = | ||
/******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) { | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.l = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // define __esModule on exports | ||
/******/ __webpack_require__.r = function(exports) { | ||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
/******/ } | ||
/******/ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/******/ }; | ||
/******/ | ||
/******/ // create a fake namespace object | ||
/******/ // mode & 1: value is a module id, require it | ||
/******/ // mode & 2: merge all properties of value into the ns | ||
/******/ // mode & 4: return value when already ns object | ||
/******/ // mode & 8|1: behave like require | ||
/******/ __webpack_require__.t = function(value, mode) { | ||
/******/ if(mode & 1) value = __webpack_require__(value); | ||
/******/ if(mode & 8) return value; | ||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; | ||
/******/ var ns = Object.create(null); | ||
/******/ __webpack_require__.r(ns); | ||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); | ||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); | ||
/******/ return ns; | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var MIN_DISTANCE = 2; | ||
var ARRAY = []; | ||
Component({ | ||
options: { | ||
addGlobalClass: true, | ||
multipleSlots: true | ||
}, | ||
properties: { | ||
threshold: { | ||
type: Number, | ||
value: 0.3 | ||
}, | ||
name: { | ||
type: null, | ||
value: '' | ||
}, | ||
asyncClose: { | ||
type: Boolean, | ||
value: false | ||
} | ||
}, | ||
offset: 0, | ||
startOffset: 0, | ||
direction: '', | ||
deltaX: 0, | ||
deltaY: 0, | ||
offsetX: 0, | ||
offsetY: 0, | ||
startX: 0, | ||
startY: 0, | ||
dragging: false, | ||
data: { | ||
left_width: 0, | ||
right_width: 0, | ||
catch_move: false, | ||
wrapper_style: '' | ||
}, | ||
methods: { | ||
noop: function noop() {}, | ||
resetTouchStatus: function resetTouchStatus() { | ||
this.direction = ''; | ||
this.deltaX = 0; | ||
this.deltaY = 0; | ||
this.offsetX = 0; | ||
this.offsetY = 0; | ||
}, | ||
handleClick: function handleClick(event) { | ||
var _event$currentTarget$ = event.currentTarget.dataset.key, | ||
key = _event$currentTarget$ === undefined ? 'outside' : _event$currentTarget$; | ||
this.triggerEvent('tap', { position: key }); | ||
if (!this.offset) return; | ||
if (this.data.asyncClose) { | ||
this.triggerEvent('close', { | ||
position: key, | ||
instance: this, | ||
name: this.data.name | ||
}); | ||
} else { | ||
this.swipeMove(0); | ||
} | ||
}, | ||
getDomInfo: function getDomInfo(className) { | ||
var _this = this; | ||
return new Promise(function (resolve) { | ||
_this.createSelectorQuery().select(className).boundingClientRect(function (result) { | ||
if (result) return resolve(result.width); | ||
resolve(0); | ||
}).exec(); | ||
}); | ||
}, | ||
getDirection: function getDirection(x, y) { | ||
if (x > y && x > MIN_DISTANCE) return 'horizontal'; | ||
if (y > x && y > MIN_DISTANCE) return 'vertical'; | ||
return ''; | ||
}, | ||
handleTouchStart: function handleTouchStart(event) { | ||
this.resetTouchStatus(); | ||
this.startOffset = this.offset; | ||
var touch = event.touches[0]; | ||
this.startX = touch.clientX; | ||
this.startY = touch.clientY; | ||
}, | ||
handleTouchEnd: function handleTouchEnd() { | ||
this.swipeLeaveTransition(); | ||
}, | ||
handleTouchCancel: function handleTouchCancel() { | ||
this.swipeLeaveTransition(); | ||
}, | ||
handleTouchMove: function handleTouchMove(event) { | ||
var _this2 = this; | ||
var touch = event.touches[0]; | ||
this.deltaX = touch.clientX - this.startX; | ||
this.deltaY = touch.clientY - this.startY; | ||
this.offsetX = Math.abs(this.deltaX); | ||
this.offsetY = Math.abs(this.deltaY); | ||
this.direction = this.direction || this.getDirection(this.offsetX, this.offsetY); | ||
console.log(this.direction); | ||
if (this.direction !== 'horizontal') return; | ||
this.dragging = true; | ||
ARRAY.filter(function (item) { | ||
return item !== _this2 && item.offset !== 0; | ||
}).forEach(function (item) { | ||
return item.close(); | ||
}); | ||
this.setData({ catch_move: true }); | ||
this.swipeMove(this.startOffset + this.deltaX); | ||
}, | ||
swipeMove: function swipeMove() { | ||
var offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; | ||
this.offset = Math.min(Math.max(offset, -this.data.right_width), this.data.left_width); | ||
var transform = 'translate3d(' + this.offset + 'px, 0, 0)'; | ||
var transition = this.dragging ? 'none' : 'transform .6s cubic-bezier(0.18, 0.89, 0.32, 1)'; | ||
this.setData({ | ||
wrapper_style: '\n\t\t\t\t\t-webkit-transform: ' + transform + ';\n\t\t\t -webkit-transition: ' + transition + ';\n\t\t\t transform: ' + transform + ';\n\t\t\t transition: ' + transition + ';\n\t\t\t\t' | ||
}); | ||
}, | ||
swipeLeaveTransition: function swipeLeaveTransition() { | ||
this.dragging = false; | ||
var _data = this.data, | ||
left_width = _data.left_width, | ||
right_width = _data.right_width, | ||
threshold = _data.threshold; | ||
var offset = this.offset; | ||
if (right_width > 0 && -offset > right_width * threshold) { | ||
this.open('right'); | ||
} else if (left_width > 0 && offset > left_width * threshold) { | ||
this.open('left'); | ||
} else { | ||
this.swipeMove(0); | ||
} | ||
this.setData({ catch_move: false }); | ||
}, | ||
close: function close() { | ||
this.swipeMove(0); | ||
}, | ||
open: function open(position) { | ||
var _data2 = this.data, | ||
left_width = _data2.left_width, | ||
right_width = _data2.right_width; | ||
var offset = position === 'left' ? left_width : -right_width; | ||
this.swipeMove(offset); | ||
this.triggerEvent('open', { position: position, name: this.data.name }); | ||
} | ||
}, | ||
lifetimes: { | ||
created: function created() { | ||
this.offset = 0; | ||
ARRAY.push(this); | ||
}, | ||
attached: function attached() { | ||
var _this3 = this; | ||
this.getDomInfo('.mp-touch-cell__left').then(function (width) { | ||
_this3.setData({ left_width: width }); | ||
}); | ||
this.getDomInfo('.mp-touch-cell__right').then(function (width) { | ||
_this3.setData({ right_width: width }); | ||
}); | ||
}, | ||
detached: function detached() { | ||
var _this4 = this; | ||
ARRAY = ARRAY.filter(function (item) { | ||
return item !== _this4; | ||
}); | ||
} | ||
} | ||
}); | ||
/***/ }) | ||
/******/ ]); | ||
module.exports=function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)i.d(n,s,function(e){return t[e]}.bind(null,s));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=0)}([function(t,e,i){"use strict";var n=[];Component({options:{addGlobalClass:!0,multipleSlots:!0},properties:{threshold:{type:Number,value:.3},name:{type:null,value:""},asyncClose:{type:Boolean,value:!1}},offset:0,startOffset:0,direction:"",deltaX:0,deltaY:0,offsetX:0,offsetY:0,startX:0,startY:0,dragging:!1,data:{left_width:0,right_width:0,catch_move:!1,wrapper_style:""},methods:{noop:function(){},resetTouchStatus:function(){this.direction="",this.deltaX=0,this.deltaY=0,this.offsetX=0,this.offsetY=0},handleClick:function(t){var e=t.currentTarget.dataset.key,i=void 0===e?"outside":e;this.triggerEvent("tap",{position:i}),this.offset&&(this.data.asyncClose?this.triggerEvent("close",{position:i,instance:this,name:this.data.name}):this.swipeMove(0))},getDomInfo:function(t){var e=this;return new Promise((function(i){e.createSelectorQuery().select(t).boundingClientRect((function(t){if(t)return i(t.width);i(0)})).exec()}))},getDirection:function(t,e){return t>e&&t>2?"horizontal":e>t&&e>2?"vertical":""},handleTouchStart:function(t){this.resetTouchStatus(),this.startOffset=this.offset;var e=t.touches[0];this.startX=e.clientX,this.startY=e.clientY},handleTouchEnd:function(){this.swipeLeaveTransition()},handleTouchCancel:function(){this.swipeLeaveTransition()},handleTouchMove:function(t){var e=this,i=t.touches[0];this.deltaX=i.clientX-this.startX,this.deltaY=i.clientY-this.startY,this.offsetX=Math.abs(this.deltaX),this.offsetY=Math.abs(this.deltaY),this.direction=this.direction||this.getDirection(this.offsetX,this.offsetY),console.log(this.direction),"horizontal"===this.direction&&(this.dragging=!0,n.filter((function(t){return t!==e&&0!==t.offset})).forEach((function(t){return t.close()})),this.setData({catch_move:!0}),this.swipeMove(this.startOffset+this.deltaX))},swipeMove:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.offset=Math.min(Math.max(t,-this.data.right_width),this.data.left_width);var e="translate3d("+this.offset+"px, 0, 0)",i=this.dragging?"none":"transform .6s cubic-bezier(0.18, 0.89, 0.32, 1)";this.setData({wrapper_style:"\n\t\t\t\t\t-webkit-transform: "+e+";\n\t\t\t -webkit-transition: "+i+";\n\t\t\t transform: "+e+";\n\t\t\t transition: "+i+";\n\t\t\t\t"})},swipeLeaveTransition:function(){this.dragging=!1;var t=this.data,e=t.left_width,i=t.right_width,n=t.threshold,s=this.offset;i>0&&-s>i*n?this.open("right"):e>0&&s>e*n?this.open("left"):this.swipeMove(0),this.setData({catch_move:!1})},close:function(){this.swipeMove(0)},open:function(t){var e=this.data,i=e.left_width,n=e.right_width,s="left"===t?i:-n;this.swipeMove(s),this.triggerEvent("open",{position:t,name:this.data.name})}},lifetimes:{created:function(){this.offset=0,n.push(this)},attached:function(){var t=this;this.getDomInfo(".mp-touch-cell__left").then((function(e){t.setData({left_width:e})})),this.getDomInfo(".mp-touch-cell__right").then((function(e){t.setData({right_width:e})}))},detached:function(){var t=this;n=n.filter((function(e){return e!==t}))}}})}]); |
{ | ||
"name": "mp-touch-cell", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "wechat mini program component, touch, move, toggle button", | ||
"keywords": ["miniprogram touch-cell"], | ||
"keywords": [ | ||
"miniprogram touch-cell" | ||
], | ||
"main": "miniprogram_dist/index.js", | ||
@@ -48,2 +50,3 @@ "files": [ | ||
"babel-preset-env": "^1.7.0", | ||
"babel-preset-minify": "^0.5.2", | ||
"colors": "^1.3.1", | ||
@@ -50,0 +53,0 @@ "eslint": "^5.14.1", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
8962
33
5
2