raise-common-lib 0.0.214 → 0.0.215
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/raise-common-lib.umd.js +96 -5
- package/bundles/raise-common-lib.umd.js.map +1 -1
- package/bundles/raise-common-lib.umd.min.js +1 -1
- package/bundles/raise-common-lib.umd.min.js.map +1 -1
- package/esm2015/lib/float-box/index.component.js +97 -6
- package/esm5/lib/float-box/index.component.js +97 -6
- package/fesm2015/raise-common-lib.js +96 -5
- package/fesm2015/raise-common-lib.js.map +1 -1
- package/fesm5/raise-common-lib.js +96 -5
- package/fesm5/raise-common-lib.js.map +1 -1
- package/lib/float-box/index.component.d.ts +1 -0
- package/package.json +1 -1
- package/raise-common-lib.metadata.json +1 -1
|
@@ -1076,10 +1076,57 @@ class FloatBoxComponent {
|
|
|
1076
1076
|
* @return {?}
|
|
1077
1077
|
*/
|
|
1078
1078
|
setFixedContentPosition() {
|
|
1079
|
+
const { top: y, left: x, width, height, } = this.rootElement.nativeElement.getBoundingClientRect();
|
|
1080
|
+
// 临时显示内容以获取尺寸
|
|
1081
|
+
/** @type {?} */
|
|
1082
|
+
const wasVisible = this.contentElement.nativeElement.style.display !== "none";
|
|
1083
|
+
this.contentElement.nativeElement.style.visibility = "hidden";
|
|
1084
|
+
this.contentElement.nativeElement.style.display = "block";
|
|
1085
|
+
/** @type {?} */
|
|
1086
|
+
const contentRect = this.contentElement.nativeElement.getBoundingClientRect();
|
|
1087
|
+
/** @type {?} */
|
|
1088
|
+
const contentWidth = contentRect.width;
|
|
1089
|
+
/** @type {?} */
|
|
1090
|
+
const contentHeight = contentRect.height;
|
|
1091
|
+
// 获取视口尺寸
|
|
1092
|
+
/** @type {?} */
|
|
1093
|
+
const viewportWidth = window.innerWidth;
|
|
1094
|
+
/** @type {?} */
|
|
1095
|
+
const viewportHeight = window.innerHeight;
|
|
1096
|
+
/** @type {?} */
|
|
1097
|
+
const SAFE_MARGIN = 12;
|
|
1098
|
+
// 边界检测:计算最佳 placement
|
|
1099
|
+
/** @type {?} */
|
|
1100
|
+
let finalPlacement = this.placement;
|
|
1101
|
+
if (this.placement === "top" && y < contentHeight + SAFE_MARGIN) {
|
|
1102
|
+
if (viewportHeight - (y + height) >= contentHeight + SAFE_MARGIN) {
|
|
1103
|
+
finalPlacement = "bottom";
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
else if (this.placement === "bottom" && viewportHeight - (y + height) < contentHeight + SAFE_MARGIN) {
|
|
1107
|
+
if (y >= contentHeight + SAFE_MARGIN) {
|
|
1108
|
+
finalPlacement = "top";
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
else if (this.placement === "left" && x < contentWidth + SAFE_MARGIN) {
|
|
1112
|
+
if (viewportWidth - (x + width) >= contentWidth + SAFE_MARGIN) {
|
|
1113
|
+
finalPlacement = "right";
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
else if (this.placement === "right" && viewportWidth - (x + width) < contentWidth + SAFE_MARGIN) {
|
|
1117
|
+
if (x >= contentWidth + SAFE_MARGIN) {
|
|
1118
|
+
finalPlacement = "left";
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
// 保存调整后的 placement
|
|
1122
|
+
this.actualPlacement = finalPlacement;
|
|
1123
|
+
// 对于 fixed="no" 的情况,只更新 data-placement,让 CSS 处理
|
|
1079
1124
|
if (this.fixed === "no") {
|
|
1125
|
+
this.contentElement.nativeElement.style.visibility = "";
|
|
1126
|
+
this.contentElement.nativeElement.style.display = wasVisible ? "" : "none";
|
|
1080
1127
|
return;
|
|
1081
1128
|
}
|
|
1082
|
-
|
|
1129
|
+
// 对于 fixed="yes" 的情况,计算具体位置
|
|
1083
1130
|
/** @type {?} */
|
|
1084
1131
|
let top = "0";
|
|
1085
1132
|
/** @type {?} */
|
|
@@ -1088,7 +1135,7 @@ class FloatBoxComponent {
|
|
|
1088
1135
|
let translateX = "0";
|
|
1089
1136
|
/** @type {?} */
|
|
1090
1137
|
let translateY = "0";
|
|
1091
|
-
switch (
|
|
1138
|
+
switch (finalPlacement + "_" + this.position) {
|
|
1092
1139
|
case "top_start":
|
|
1093
1140
|
top = y + "px";
|
|
1094
1141
|
left = x - 8 + "px";
|
|
@@ -1152,9 +1199,49 @@ class FloatBoxComponent {
|
|
|
1152
1199
|
translateX = "-100%";
|
|
1153
1200
|
break;
|
|
1154
1201
|
}
|
|
1202
|
+
// 计算实际渲染位置(考虑 transform)进行边界调整
|
|
1203
|
+
/** @type {?} */
|
|
1204
|
+
let actualLeft = parseFloat(left) || 0;
|
|
1205
|
+
/** @type {?} */
|
|
1206
|
+
let actualTop = parseFloat(top) || 0;
|
|
1207
|
+
if (translateX === "-50%") {
|
|
1208
|
+
actualLeft = actualLeft - contentWidth / 2;
|
|
1209
|
+
}
|
|
1210
|
+
else if (translateX === "-100%") {
|
|
1211
|
+
actualLeft = actualLeft - contentWidth;
|
|
1212
|
+
}
|
|
1213
|
+
if (translateY === "-50%") {
|
|
1214
|
+
actualTop = actualTop - contentHeight / 2;
|
|
1215
|
+
}
|
|
1216
|
+
else if (translateY === "-100%") {
|
|
1217
|
+
actualTop = actualTop - contentHeight;
|
|
1218
|
+
}
|
|
1219
|
+
// 水平边界调整
|
|
1220
|
+
if (finalPlacement === "top" || finalPlacement === "bottom") {
|
|
1221
|
+
if (actualLeft < SAFE_MARGIN) {
|
|
1222
|
+
left = (x + SAFE_MARGIN) + "px";
|
|
1223
|
+
translateX = "0";
|
|
1224
|
+
}
|
|
1225
|
+
else if (actualLeft + contentWidth > viewportWidth - SAFE_MARGIN) {
|
|
1226
|
+
left = (viewportWidth - contentWidth - SAFE_MARGIN) + "px";
|
|
1227
|
+
translateX = "0";
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
// 垂直边界调整
|
|
1231
|
+
else {
|
|
1232
|
+
if (actualTop < SAFE_MARGIN) {
|
|
1233
|
+
top = (y + SAFE_MARGIN) + "px";
|
|
1234
|
+
translateY = "0";
|
|
1235
|
+
}
|
|
1236
|
+
else if (actualTop + contentHeight > viewportHeight - SAFE_MARGIN) {
|
|
1237
|
+
top = (viewportHeight - contentHeight - SAFE_MARGIN) + "px";
|
|
1238
|
+
translateY = "0";
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1155
1241
|
this.contentElement.nativeElement.style.top = top;
|
|
1156
1242
|
this.contentElement.nativeElement.style.left = left;
|
|
1157
1243
|
this.contentElement.nativeElement.style.transform = `translate(${translateX}, ${translateY})`;
|
|
1244
|
+
this.contentElement.nativeElement.style.visibility = "visible";
|
|
1158
1245
|
}
|
|
1159
1246
|
/**
|
|
1160
1247
|
* @return {?}
|
|
@@ -1172,13 +1259,15 @@ class FloatBoxComponent {
|
|
|
1172
1259
|
* @return {?}
|
|
1173
1260
|
*/
|
|
1174
1261
|
onMouseEnter() {
|
|
1175
|
-
if (this.
|
|
1262
|
+
if (this.trigger !== "hover") {
|
|
1176
1263
|
return;
|
|
1177
1264
|
}
|
|
1178
1265
|
this.opened = "yes";
|
|
1179
1266
|
this.openChange.emit(true);
|
|
1180
1267
|
this.setFixedContentPosition();
|
|
1181
|
-
|
|
1268
|
+
if (this.fixed === "yes") {
|
|
1269
|
+
window.addEventListener("mousemove", this.onMoveOutside);
|
|
1270
|
+
}
|
|
1182
1271
|
}
|
|
1183
1272
|
/**
|
|
1184
1273
|
* @return {?}
|
|
@@ -1198,7 +1287,7 @@ class FloatBoxComponent {
|
|
|
1198
1287
|
FloatBoxComponent.decorators = [
|
|
1199
1288
|
{ type: Component, args: [{
|
|
1200
1289
|
selector: "rs-float-box",
|
|
1201
|
-
template: "<div\r\n #element\r\n class=\"float-box-container\"\r\n [attr.data-trigger]=\"trigger\"\r\n (click)=\"onClickContainer()\"\r\n (mouseenter)=\"onMouseEnter()\"\r\n>\r\n <ng-content></ng-content>\r\n <div\r\n #content\r\n class=\"float-box-content\"\r\n [attr.data-placement]=\"placement\"\r\n [attr.data-position]=\"position\"\r\n [attr.data-animation]=\"animation\"\r\n [attr.data-fixed]=\"fixed\"\r\n [attr.data-opened]=\"opened\"\r\n >\r\n <div class=\"float-box-show-content\">\r\n <ng-content select=\"[float-content]\"></ng-content>\r\n </div>\r\n </div>\r\n</div>\r\n",
|
|
1290
|
+
template: "<div\r\n #element\r\n class=\"float-box-container\"\r\n [attr.data-trigger]=\"trigger\"\r\n (click)=\"onClickContainer()\"\r\n (mouseenter)=\"onMouseEnter()\"\r\n>\r\n <ng-content></ng-content>\r\n <div\r\n #content\r\n class=\"float-box-content\"\r\n [attr.data-placement]=\"actualPlacement || placement\"\r\n [attr.data-position]=\"position\"\r\n [attr.data-animation]=\"animation\"\r\n [attr.data-fixed]=\"fixed\"\r\n [attr.data-opened]=\"opened\"\r\n >\r\n <div class=\"float-box-show-content\">\r\n <ng-content select=\"[float-content]\"></ng-content>\r\n </div>\r\n </div>\r\n</div>\r\n",
|
|
1202
1291
|
styles: [".float-box-container{position:relative}.float-box-container[data-trigger=click]>.float-box-content[data-opened=no],.float-box-container[data-trigger=hover]:not(:hover)>.float-box-content{display:none}.float-box-container>.float-box-content[data-fixed=no]{padding:8px;--top:0;--left:0;--translate-x:0;--translate-y:0;position:absolute;top:var(--top);left:var(--left);transform:translate(var(--translate-x),var(--translate-y));z-index:10}.float-box-container>.float-box-content[data-fixed=no][data-animation=yes]{-webkit-animation:.25s ease-in-out;animation:.25s ease-in-out}.float-box-container>.float-box-content[data-fixed=no][data-placement=top]{--translate-y:-100%}.float-box-container>.float-box-content[data-fixed=no][data-placement=top][data-animation=true]{-webkit-animation-name:open-from-top;animation-name:open-from-top}.float-box-container>.float-box-content[data-fixed=no][data-placement=left]{--translate-x:-100%}.float-box-container>.float-box-content[data-fixed=no][data-placement=right]{--left:100%}.float-box-container>.float-box-content[data-fixed=no][data-placement=bottom]{--top:100%}.float-box-container>.float-box-content[data-fixed=no][data-placement=bottom][data-animation=yes]{-webkit-animation-name:open-from-bottom;animation-name:open-from-bottom}.float-box-container>.float-box-content[data-fixed=no][data-placement=bottom][data-position=start],.float-box-container>.float-box-content[data-fixed=no][data-placement=top][data-position=start]{--left:-8px}.float-box-container>.float-box-content[data-fixed=no][data-placement=bottom][data-position=center],.float-box-container>.float-box-content[data-fixed=no][data-placement=top][data-position=center]{--left:50%;--translate-x:-50%}.float-box-container>.float-box-content[data-fixed=no][data-placement=bottom][data-position=end],.float-box-container>.float-box-content[data-fixed=no][data-placement=top][data-position=end]{--left:calc(100% + 8px);--translate-x:-100%}.float-box-container>.float-box-content[data-fixed=no][data-placement=left][data-position=start],.float-box-container>.float-box-content[data-fixed=no][data-placement=right][data-position=start]{--top:-8px}.float-box-container>.float-box-content[data-fixed=no][data-placement=left][data-position=start][data-animation=yes],.float-box-container>.float-box-content[data-fixed=no][data-placement=right][data-position=start][data-animation=yes]{-webkit-animation-name:open-from-bottom;animation-name:open-from-bottom}.float-box-container>.float-box-content[data-fixed=no][data-placement=left][data-position=center],.float-box-container>.float-box-content[data-fixed=no][data-placement=right][data-position=center]{--top:50%;--translate-y:-50%}.float-box-container>.float-box-content[data-fixed=no][data-placement=left][data-position=center][data-animation=yes],.float-box-container>.float-box-content[data-fixed=no][data-placement=right][data-position=center][data-animation=yes]{-webkit-animation-name:open-from-bottom;animation-name:open-from-bottom}.float-box-container>.float-box-content[data-fixed=no][data-placement=left][data-position=end],.float-box-container>.float-box-content[data-fixed=no][data-placement=right][data-position=end]{--top:calc(100% + 8px);--translate-y:-100%}.float-box-container>.float-box-content[data-fixed=no][data-placement=left][data-position=end][data-animation=yes],.float-box-container>.float-box-content[data-fixed=no][data-placement=right][data-position=end][data-animation=yes]{-webkit-animation-name:open-from-top;animation-name:open-from-top}@-webkit-keyframes open-from-top{from{margin-top:-8px;opacity:.4}to{margin:0;opacity:1}}@keyframes open-from-top{from{margin-top:-8px;opacity:.4}to{margin:0;opacity:1}}@-webkit-keyframes open-from-bottom{from{margin-top:8px;opacity:.4}to{margin:0;opacity:1}}@keyframes open-from-bottom{from{margin-top:8px;opacity:.4}to{margin:0;opacity:1}}::ng-deep #kt-float-box-fixed-container{width:0;height:0;z-index:100000}::ng-deep #kt-float-box-fixed-container .float-box-content[data-fixed=yes]{padding:8px;position:fixed;z-index:10}::ng-deep #kt-float-box-fixed-container .float-box-content[data-fixed=yes][data-opened=no]{display:none}.float-box-show-content{padding:8px 8px 12px;border-radius:8px;background:#fff;box-shadow:0 0 8px 0 rgba(0,0,0,.25)}"]
|
|
1203
1292
|
}] }
|
|
1204
1293
|
];
|
|
@@ -1228,6 +1317,8 @@ if (false) {
|
|
|
1228
1317
|
/** @type {?} */
|
|
1229
1318
|
FloatBoxComponent.prototype._fixed;
|
|
1230
1319
|
/** @type {?} */
|
|
1320
|
+
FloatBoxComponent.prototype.actualPlacement;
|
|
1321
|
+
/** @type {?} */
|
|
1231
1322
|
FloatBoxComponent.prototype.openChange;
|
|
1232
1323
|
/** @type {?} */
|
|
1233
1324
|
FloatBoxComponent.prototype.rootElement;
|