jiaqingjiayi-xiaochengxu/甲情_甲意/miniprogram/node_modules/antd-mini/es/Badge/index.sjs

54 lines
1.7 KiB
Plaintext
Raw Normal View History

2024-12-01 11:56:54 +00:00
function setPositionStyle(position) {
var offsetX = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '-50%';
var offsetY = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '-50%';
var transformStyle = "transform: translate(calc(".concat(offsetX, "), calc(").concat(offsetY, "));");
2024-11-10 07:01:22 +00:00
switch (position) {
case 'top-left':
2024-12-01 11:56:54 +00:00
return "top: 0; left: 0; ".concat(transformStyle);
2024-11-10 07:01:22 +00:00
case 'top-center':
2024-12-01 11:56:54 +00:00
return "top: 0; left: 50%; ".concat(transformStyle);
2024-11-10 07:01:22 +00:00
case 'top-right':
2024-12-01 11:56:54 +00:00
return "top: 0; left: 100%; ".concat(transformStyle);
2024-11-10 07:01:22 +00:00
case 'left':
2024-12-01 11:56:54 +00:00
return "top: 50%; left: 0; ".concat(transformStyle);
2024-11-10 07:01:22 +00:00
case 'right':
2024-12-01 11:56:54 +00:00
return "top: 50%; left: 100%; ".concat(transformStyle);
2024-11-10 07:01:22 +00:00
case 'bottom-left':
2024-12-01 11:56:54 +00:00
return "top: 100%; left: 0; ".concat(transformStyle);
2024-11-10 07:01:22 +00:00
case 'bottom-center':
2024-12-01 11:56:54 +00:00
return "top: 100%; left: 50%; ".concat(transformStyle);
2024-11-10 07:01:22 +00:00
case 'bottom-right':
2024-12-01 11:56:54 +00:00
return "top: 100%; left: 100%; ".concat(transformStyle);
2024-11-10 07:01:22 +00:00
default:
2024-12-01 11:56:54 +00:00
return "top: 0; left: 0; ".concat(transformStyle);
2024-11-10 07:01:22 +00:00
}
}
function setBubbleStyle(type, position) {
if (type !== 'bubble') return '';
switch (position) {
case 'top-left':
return 'border-bottom-right-radius: 0;';
case 'top-right':
return 'border-bottom-left-radius: 0;';
case 'bottom-left':
return 'border-top-right-radius: 0;';
case 'bottom-right':
return 'border-top-left-radius: 0;';
default:
return '';
}
}
2024-12-01 11:56:54 +00:00
function getOverCount(text) {
var overCount = false;
if (typeof text === 'number') {
if (text >= 100) {
overCount = true;
}
}
return overCount;
}
export default {
setPositionStyle: setPositionStyle,
setBubbleStyle: setBubbleStyle,
getOverCount: getOverCount
};