jiaqingjiayi-xiaochengxu/甲情_甲意/node_modules/antd-mini/less/SwipeAction/index.sjs
2024-11-15 11:51:28 +08:00

144 lines
6.7 KiB
JavaScript

var getWidth = function getWidth(rightWidth, leftWidth, inertiaWidth) {
var num = (rightWidth || leftWidth) * 2 + inertiaWidth;
var width = rightWidth > leftWidth ? rightWidth : leftWidth;
return rightWidth && leftWidth ? "calc(100% + ".concat(width + inertiaWidth, "px)") : "calc(100% + ".concat(num / 2, "px)");
};
var getMarginLeft = function getMarginLeft(rightWidth, leftWidth, inertiaWidth) {
var width = rightWidth > leftWidth ? rightWidth : leftWidth;
return "calc(-".concat((width + inertiaWidth) / 2, "px)");
};
var getSlotWidthStyle = function getSlotWidthStyle(rightWidth, leftWidth) {
var left = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
var right = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
var inertiaWidth = arguments.length > 4 ? arguments[4] : undefined;
// 右
if (right.length > 0 && left.length === 0) {
return "calc(100% - ".concat((1 + inertiaWidth) / 2, "px)");
}
// 左
if (left.length > 0 && right.length === 0) {
return "width: calc(100% - ".concat(leftWidth / 2, "px); margin-left: ").concat((leftWidth + inertiaWidth) / 2, "px;");
}
if (left.length > 0 && right.length > 0) {
return "width: 100%;margin-left: 0;";
}
};
var getLeft = function getLeft(tapType, idx, right, isLeft) {
var tip = !isLeft ? 'L-' : 'R-';
if (right.length === 1) {
return tapType && tapType === "".concat(tip).concat(idx) ? 'text-move-midd' : '';
}
if (right.length === 3 && idx === 1) {
return tapType && tapType === "".concat(tip).concat(idx) ? 'text-move-midd' : '';
}
var cls = '';
if (idx === 0) {
cls = isLeft ? 'text-move-left' : 'text-move-right';
} else {
cls = isLeft ? 'text-move-right' : 'text-move-left';
}
return tapType && tapType === "".concat(tip).concat(idx) ? cls : '';
};
var getWidth2 = function getWidth2(rightWidth, leftWidth, inertiaWidth) {
var width = rightWidth > leftWidth ? rightWidth : leftWidth;
return rightWidth && leftWidth ? "calc(100% - ".concat(width + inertiaWidth, "px)") : "calc(100% - ".concat((width + inertiaWidth) / 2, "px)");
};
var getMarginLeft2 = function getMarginLeft2(rightWidth, leftWidth, inertiaWidth) {
var num = rightWidth > 0 ? inertiaWidth : 0;
var width = rightWidth > leftWidth ? rightWidth : leftWidth;
return leftWidth && rightWidth ? "".concat((width + num) / 2, "px") : leftWidth > 0 ? 0 : "".concat((width + inertiaWidth) / 2, "px");
};
var getMarginLeft3 = function getMarginLeft3(rightWidth, leftWidth, inertiaWidth) {
var width = rightWidth > leftWidth ? rightWidth : leftWidth;
return leftWidth && rightWidth ? "calc(100% - ".concat((width + inertiaWidth) / 2, "px)") : "calc(100% - ".concat(rightWidth / 2 - 1, "px)");
};
var getMoveX = function getMoveX(rightButtons, idx) {
var arr = rightButtons.slice(idx, rightButtons.length);
return arr.reduce(function (tolal, cur) {
return parseFloat(tolal) + cur.width;
}, 0);
};
var getMovableContentRightStyle = function getMovableContentRightStyle(item, tapTypeR, idx, rightWidth, inTouch, inertiaWidth, myStyle) {
var isTapTypeR = tapTypeR && tapTypeR === "R-".concat(idx);
var myStyleString = isTapTypeR ? styleObjectToString(myStyle) : '';
return "\n font-size: ".concat((item.fontSize || 28) / 2, "px;\n color: ").concat(item.color, ";\n background: ").concat(item.bgColor, ";\n height: calc(100% + 2px);\n ").concat(isTapTypeR ? "width: ".concat((rightWidth + 1 + (item.confirmType === 'move' && inTouch ? inertiaWidth : 0)) / 2, "px;") : "width: ".concat(item.width / 2, "px;"), "\n ").concat(myStyleString);
};
var styleKeyMap = {
'marginRight': 'margin-right',
'marginLeft': 'margin-left',
'fontSize': 'font-size',
zIndex: 'z-index'
};
function styleObjectToString(myStyle) {
var styleKeys = keys(myStyle);
var res = '';
for (var i = 0; i < styleKeys.length; i++) {
var key = styleKeys[i];
res = res + "".concat(styleKeyMap[key] || key, ": ").concat(myStyle[key], "; ");
}
return res;
}
var getMovableContentLeftStyle = function getMovableContentLeftStyle(itemL, tapTypeL, idx, leftWidth, inTouch, inertiaWidth, myStyle) {
var isTapTypeL = tapTypeL && tapTypeL === "L-".concat(idx);
var myStyleString = isTapTypeL ? styleObjectToString(myStyle) : '';
return "\n background: ".concat(itemL.bgColor, ";\n height: calc(100% + 2px);\n font-size: ").concat((itemL.fontSize || 28) / 2, "px;\n color: ").concat(itemL.color, ";\n ").concat(isTapTypeL ? "width: ".concat((leftWidth + 1 + (itemL.confirmType === 'move' && inTouch ? inertiaWidth : 0)) / 2, "px;") : "width: ".concat(itemL.width / 2, "px;"), "\n ").concat(myStyleString);
};
var getLeftSlotName = function getLeftSlotName(tapTypeL, idx, itemL) {
if (!itemL.slotName) {
return '';
}
return tapTypeL && tapTypeL === "L-".concat(idx) ? "".concat(itemL.slotName, "-confirm") : itemL.slotName;
};
var getRightSlotName = function getRightSlotName(tapTypeR, idx, item) {
if (!item.slotName) {
return '';
}
return tapTypeR && tapTypeR === "R-".concat(idx) ? "".concat(item.slotName, "-confirm") : item.slotName;
};
var getLeftText = function getLeftText(tapTypeL, idx, itemL) {
return tapTypeL && tapTypeL === "L-".concat(idx) ? itemL.confirmText || itemL.text : itemL.text;
};
var getRightText = function getRightText(tapTypeR, idx, item) {
return tapTypeR && tapTypeR === "R-".concat(idx) ? item.confirmText || item.text : item.text;
};
var getRightMovableContentStyle = function getRightMovableContentStyle(tapTypeR, idx, rightWidth, leftWidth, inertiaWidth) {
return styleObjectToString({
zIndex: tapTypeR === "R-".concat(idx) ? 1 : 0,
marginLeft: getMarginLeft3(rightWidth, leftWidth, inertiaWidth),
width: (rightWidth - 0.1) / 2 + 'px'
});
};
var getLeftMovableContentStyle = function getLeftMovableContentStyle(tapTypeL, idx, leftWidth, inertiaWidth) {
return styleObjectToString({
zIndex: tapTypeL === "L-".concat(idx) ? 1 : 0,
marginLeft: "".concat(inertiaWidth / 2, "px"),
width: (leftWidth - 1) / 2 + 'px'
});
};
var axmlObj = function axmlObj(obj) {
return obj;
};
export default {
axmlObj: axmlObj,
getWidth2: getWidth2,
getMarginLeft2: getMarginLeft2,
getMarginLeft3: getMarginLeft3,
getRightMovableContentStyle: getRightMovableContentStyle,
getLeftMovableContentStyle: getLeftMovableContentStyle,
getLeft: getLeft,
getWidth: getWidth,
getSlotWidthStyle: getSlotWidthStyle,
getMarginLeft: getMarginLeft,
getMoveX: getMoveX,
getMovableContentRightStyle: getMovableContentRightStyle,
getMovableContentLeftStyle: getMovableContentLeftStyle,
getRightText: getRightText,
getLeftText: getLeftText,
getLeftSlotName: getLeftSlotName,
getRightSlotName: getRightSlotName
};
function keys(obj) {
if (typeof Object.keys === 'function') {
return Object.keys(obj);
}
}