Socket
Socket
Sign inDemoInstall

mp-touch-cell

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

97

miniprogram_dist/mp-touch-cell/mp-touch-cell.js

@@ -1,1 +0,96 @@

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}))}}})}]);
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,ARRAY=[];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 a(){},resetTouchStatus:function a(){this.direction='',this.deltaX=0,this.deltaY=0,this.offsetX=0,this.offsetY=0},handleClick:function d(a){var b=a.currentTarget.dataset.key,c=b===void 0?'outside':b;this.triggerEvent('tap',{position:c});this.offset&&(this.data.asyncClose?this.triggerEvent('close',{position:c,instance:this,name:this.data.name}):this.swipeMove(0))},getDomInfo:function c(a){var b=this;return new Promise(function(c){b.createSelectorQuery().select(a).boundingClientRect(function(a){return a?c(a.width):void c(0)}).exec()})},getDirection:function c(a,b){return a>b&&a>MIN_DISTANCE?'horizontal':b>a&&b>MIN_DISTANCE?'vertical':''},handleTouchStart:function c(a){this.resetTouchStatus(),this.startOffset=this.offset;var b=a.touches[0];this.startX=b.clientX,this.startY=b.clientY},handleTouchEnd:function a(){this.swipeLeaveTransition()},handleTouchCancel:function a(){this.swipeLeaveTransition()},handleTouchMove:function e(a){var b=Math.abs,c=this,d=a.touches[0];this.deltaX=d.clientX-this.startX,this.deltaY=d.clientY-this.startY,this.offsetX=b(this.deltaX),this.offsetY=b(this.deltaY),this.direction=this.direction||this.getDirection(this.offsetX,this.offsetY),console.log(this.direction);'horizontal'!==this.direction||(this.dragging=!0,ARRAY.filter(function(a){return a!==c&&0!==a.offset}).forEach(function(a){return a.close()}),this.setData({catch_move:!0}),this.swipeMove(this.startOffset+this.deltaX))},swipeMove:function d(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:0;this.offset=Math.min(Math.max(a,-this.data.right_width),this.data.left_width);var b='translate3d('+this.offset+'px, 0, 0)',c=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: '+b+';\n\t\t\t -webkit-transition: '+c+';\n\t\t\t transform: '+b+';\n\t\t\t transition: '+c+';\n\t\t\t\t'})},swipeLeaveTransition:function f(){this.dragging=!1;var a=this.data,b=a.left_width,c=a.right_width,d=a.threshold,e=this.offset;0<c&&-e>c*d?this.open('right'):0<b&&e>b*d?this.open('left'):this.swipeMove(0),this.setData({catch_move:!1})},close:function a(){this.swipeMove(0)},open:function f(a){var b=this.data,c=b.left_width,d=b.right_width,e='left'===a?c:-d;this.swipeMove(e),this.triggerEvent('open',{position:a,name:this.data.name})}},lifetimes:{created:function a(){this.offset=0,ARRAY.push(this)},attached:function b(){var a=this;this.getDomInfo('.mp-touch-cell__left').then(function(b){a.setData({left_width:b})}),this.getDomInfo('.mp-touch-cell__right').then(function(b){a.setData({right_width:b})})},detached:function b(){var a=this;ARRAY=ARRAY.filter(function(b){return b!==a})}}});
/***/ })
/******/ ]);

2

package.json
{
"name": "mp-touch-cell",
"version": "1.0.1",
"version": "1.0.2",
"description": "wechat mini program component, touch, move, toggle button",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc