@lenne.tech/ng-base 0.3.4 → 0.3.8
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/lenne.tech-ng-base-src-lib-base.umd.js +27 -89
- package/bundles/lenne.tech-ng-base-src-lib-base.umd.js.map +1 -1
- package/bundles/lenne.tech-ng-base.umd.js +27 -89
- package/bundles/lenne.tech-ng-base.umd.js.map +1 -1
- package/esm2015/lib/base/directives/match-height.directive.js +5 -17
- package/esm2015/lib/base/services/graphql.service.js +3 -3
- package/esm2015/lib/base/services/image.service.js +14 -32
- package/esm2015/lib/base/services/scroll.service.js +9 -30
- package/esm2015/src/lib/base/directives/match-height.directive.js +5 -17
- package/esm2015/src/lib/base/services/graphql.service.js +3 -3
- package/esm2015/src/lib/base/services/image.service.js +14 -32
- package/esm2015/src/lib/base/services/scroll.service.js +9 -30
- package/fesm2015/lenne.tech-ng-base-src-lib-base.js +27 -78
- package/fesm2015/lenne.tech-ng-base-src-lib-base.js.map +1 -1
- package/fesm2015/lenne.tech-ng-base.js +27 -78
- package/fesm2015/lenne.tech-ng-base.js.map +1 -1
- package/lib/base/directives/match-height.directive.d.ts +5 -6
- package/lib/base/services/image.service.d.ts +0 -1
- package/lib/base/services/scroll.service.d.ts +1 -2
- package/package.json +1 -1
- package/src/lib/base/directives/match-height.directive.d.ts +5 -6
- package/src/lib/base/lenne.tech-ng-base-src-lib-base.metadata.json +1 -1
- package/src/lib/base/services/image.service.d.ts +0 -1
- package/src/lib/base/services/scroll.service.d.ts +1 -2
|
@@ -1173,13 +1173,10 @@
|
|
|
1173
1173
|
ImageService.prototype.preLoadImages = function (options) {
|
|
1174
1174
|
var _this = this;
|
|
1175
1175
|
// Init configuration
|
|
1176
|
-
var config = Object.assign({ doneFunnction: undefined, elements: document, regExp: undefined
|
|
1176
|
+
var config = Object.assign({ doneFunnction: undefined, elements: document, regExp: undefined }, options);
|
|
1177
1177
|
return new Promise(function (resolve) {
|
|
1178
1178
|
var e_1, _b;
|
|
1179
1179
|
var _a;
|
|
1180
|
-
// Init variables
|
|
1181
|
-
var resolved = false;
|
|
1182
|
-
var timeoutId;
|
|
1183
1180
|
// Convert element(s) into array
|
|
1184
1181
|
if (!Array.isArray(config.elements)) {
|
|
1185
1182
|
// NodeList or HTMLCollection
|
|
@@ -1202,22 +1199,24 @@
|
|
|
1202
1199
|
var src = image.getAttribute('src');
|
|
1203
1200
|
// Check if changes are necessary and possible
|
|
1204
1201
|
if ((image.complete && image.naturalHeight !== 0) || // already laoded
|
|
1205
|
-
image.getAttribute('loading') !== 'lazy' || // loading attribute !== lazy
|
|
1206
1202
|
!src || // Image has no src
|
|
1207
1203
|
((_a = config.regExp) === null || _a === void 0 ? void 0 : _a.test(src)) // Test if src matches regular expression
|
|
1208
1204
|
) {
|
|
1209
1205
|
return "continue";
|
|
1210
1206
|
}
|
|
1211
1207
|
// Replace lazy loading image with immediately loading image
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1208
|
+
if (image.getAttribute('loading') === 'lazy') {
|
|
1209
|
+
var newImage_1 = document.createElement('img');
|
|
1210
|
+
Array.from(image.attributes).forEach(function (attr) {
|
|
1211
|
+
if (attr.name !== 'loading' && attr.name !== 'src') {
|
|
1212
|
+
newImage_1.setAttribute(attr.name, attr.value);
|
|
1213
|
+
}
|
|
1214
|
+
});
|
|
1215
|
+
image.replaceWith(newImage_1);
|
|
1216
|
+
image = newImage_1;
|
|
1217
|
+
}
|
|
1219
1218
|
// Wait for laoding
|
|
1220
|
-
promises.push(_this.loadImage(
|
|
1219
|
+
promises.push(_this.loadImage(image, src));
|
|
1221
1220
|
};
|
|
1222
1221
|
try {
|
|
1223
1222
|
// Prepare images
|
|
@@ -1233,24 +1232,6 @@
|
|
|
1233
1232
|
}
|
|
1234
1233
|
finally { if (e_1) throw e_1.error; }
|
|
1235
1234
|
}
|
|
1236
|
-
if (config.timeout) {
|
|
1237
|
-
timeoutId = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1238
|
-
return __generator(this, function (_b) {
|
|
1239
|
-
switch (_b.label) {
|
|
1240
|
-
case 0:
|
|
1241
|
-
resolved = true;
|
|
1242
|
-
if (!config.doneFunnction) return [3 /*break*/, 2];
|
|
1243
|
-
return [4 /*yield*/, config.doneFunction()];
|
|
1244
|
-
case 1:
|
|
1245
|
-
_b.sent();
|
|
1246
|
-
_b.label = 2;
|
|
1247
|
-
case 2:
|
|
1248
|
-
resolve(undefined);
|
|
1249
|
-
return [2 /*return*/];
|
|
1250
|
-
}
|
|
1251
|
-
});
|
|
1252
|
-
}); });
|
|
1253
|
-
}
|
|
1254
1235
|
// Wait until all images loaded
|
|
1255
1236
|
Promise.all(promises)
|
|
1256
1237
|
.catch(function (e) { return console.error('Error during image loading', e); })
|
|
@@ -1259,14 +1240,6 @@
|
|
|
1259
1240
|
return __generator(this, function (_b) {
|
|
1260
1241
|
switch (_b.label) {
|
|
1261
1242
|
case 0:
|
|
1262
|
-
// Check if already resolved
|
|
1263
|
-
if (resolved) {
|
|
1264
|
-
return [2 /*return*/];
|
|
1265
|
-
}
|
|
1266
|
-
// Stop timeout
|
|
1267
|
-
if (timeoutId) {
|
|
1268
|
-
clearTimeout(timeoutId);
|
|
1269
|
-
}
|
|
1270
1243
|
if (!config.doneFunnction) return [3 /*break*/, 2];
|
|
1271
1244
|
return [4 /*yield*/, config.doneFunction()];
|
|
1272
1245
|
case 1:
|
|
@@ -1316,29 +1289,16 @@
|
|
|
1316
1289
|
this.el = el;
|
|
1317
1290
|
this.imageService = imageService;
|
|
1318
1291
|
// Replace lazy loading images with immediate loading images
|
|
1319
|
-
this.
|
|
1292
|
+
this.loadImages = true;
|
|
1320
1293
|
this.isBrowser = common.isPlatformBrowser(platformId);
|
|
1321
1294
|
}
|
|
1322
1295
|
MatchHeightDirective.prototype.onResize = function () {
|
|
1323
1296
|
this.matchHeight(this.el.nativeElement, this.ltMatchHeight);
|
|
1324
1297
|
};
|
|
1325
|
-
MatchHeightDirective.prototype.
|
|
1298
|
+
MatchHeightDirective.prototype.ngOnInit = function () {
|
|
1326
1299
|
this.matchHeight(this.el.nativeElement, this.ltMatchHeight);
|
|
1327
1300
|
};
|
|
1328
1301
|
MatchHeightDirective.prototype.matchHeight = function (parent, target) {
|
|
1329
|
-
var _this = this;
|
|
1330
|
-
if (this.isBrowser) {
|
|
1331
|
-
// Timeout is set to force Angular to wait for all actions and only continue once the process has run through.
|
|
1332
|
-
// Otherwise, an infinite loop will occur.
|
|
1333
|
-
setTimeout(function () {
|
|
1334
|
-
_this.matchHeightHelper(parent, target);
|
|
1335
|
-
}, 1);
|
|
1336
|
-
}
|
|
1337
|
-
else {
|
|
1338
|
-
this.matchHeightHelper(parent, target);
|
|
1339
|
-
}
|
|
1340
|
-
};
|
|
1341
|
-
MatchHeightDirective.prototype.matchHeightHelper = function (parent, target) {
|
|
1342
1302
|
return __awaiter(this, void 0, void 0, function () {
|
|
1343
1303
|
var classNames, _loop_1, this_1, classNames_1, classNames_1_1, className, e_1_1;
|
|
1344
1304
|
var e_1, _a;
|
|
@@ -1363,7 +1323,7 @@
|
|
|
1363
1323
|
if (!children || children.length < 2) {
|
|
1364
1324
|
return [2 /*return*/, "continue"];
|
|
1365
1325
|
}
|
|
1366
|
-
if (!this_1.
|
|
1326
|
+
if (!this_1.loadImages) return [3 /*break*/, 2];
|
|
1367
1327
|
return [4 /*yield*/, this_1.imageService.preLoadImages({ elements: children })];
|
|
1368
1328
|
case 1:
|
|
1369
1329
|
_c.sent();
|
|
@@ -1432,7 +1392,7 @@
|
|
|
1432
1392
|
]; };
|
|
1433
1393
|
MatchHeightDirective.propDecorators = {
|
|
1434
1394
|
ltMatchHeight: [{ type: i0.Input }],
|
|
1435
|
-
|
|
1395
|
+
loadImages: [{ type: i0.Input }],
|
|
1436
1396
|
onResize: [{ type: i0.HostListener, args: ['window:resize',] }]
|
|
1437
1397
|
};
|
|
1438
1398
|
|
|
@@ -2337,7 +2297,7 @@
|
|
|
2337
2297
|
.filter(function (field) { return !argsData.usedArgs.includes(field); });
|
|
2338
2298
|
console.log({ argsData: argsData, filtered: filtered, unused: unused });
|
|
2339
2299
|
}
|
|
2340
|
-
var args = argsData.argsString || '';
|
|
2300
|
+
var args = (argsData === null || argsData === void 0 ? void 0 : argsData.argsString) || '';
|
|
2341
2301
|
// Log
|
|
2342
2302
|
if (config.log) {
|
|
2343
2303
|
console.log({ graphQL: graphql, args: args, fields: fields, type: config.type });
|
|
@@ -2509,7 +2469,7 @@
|
|
|
2509
2469
|
return "continue";
|
|
2510
2470
|
}
|
|
2511
2471
|
// Skip value if not exists
|
|
2512
|
-
if (value === undefined
|
|
2472
|
+
if (value === undefined || value === null) {
|
|
2513
2473
|
return "continue";
|
|
2514
2474
|
}
|
|
2515
2475
|
// Add current key to metadata
|
|
@@ -2873,7 +2833,7 @@
|
|
|
2873
2833
|
return __generator(this, function (_a) {
|
|
2874
2834
|
switch (_a.label) {
|
|
2875
2835
|
case 0:
|
|
2876
|
-
config = Object.assign({ checkUrl:
|
|
2836
|
+
config = Object.assign({ checkUrl: false, loadImagesBefore: true, resetStyles: false, setOverflow: true, stopPropagation: true }, options);
|
|
2877
2837
|
if (!(config.checkUrl && this.router.url !== '/' && !this.router.url.startsWith('/#'))) return [3 /*break*/, 2];
|
|
2878
2838
|
return [4 /*yield*/, this.router.navigate(['/'], { fragment: id })];
|
|
2879
2839
|
case 1:
|
|
@@ -2955,48 +2915,26 @@
|
|
|
2955
2915
|
* Scroll done promise
|
|
2956
2916
|
*/
|
|
2957
2917
|
ScrollService.prototype.scrollDone = function (options) {
|
|
2958
|
-
var _this = this;
|
|
2959
2918
|
if (options === void 0) { options = {}; }
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
// Return promise for scroll done
|
|
2963
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
2964
|
-
var rejected, timeoutId, result;
|
|
2919
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2920
|
+
var config;
|
|
2965
2921
|
return __generator(this, function (_a) {
|
|
2966
2922
|
switch (_a.label) {
|
|
2967
2923
|
case 0:
|
|
2968
|
-
|
|
2969
|
-
// Set timeout handling if necessary
|
|
2970
|
-
if (config.timeout) {
|
|
2971
|
-
timeoutId = window.setTimeout(function () {
|
|
2972
|
-
rejected = true;
|
|
2973
|
-
reject(new Error('Timeout for scrollDone after:' + config.timeout));
|
|
2974
|
-
}, config.timeout);
|
|
2975
|
-
}
|
|
2924
|
+
config = Object.assign({ doneFunction: undefined }, options);
|
|
2976
2925
|
// Wait for scroll done
|
|
2977
2926
|
return [4 /*yield*/, this.scrollDoneDetection()];
|
|
2978
2927
|
case 1:
|
|
2979
2928
|
// Wait for scroll done
|
|
2980
2929
|
_a.sent();
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
window.clearTimeout(timeoutId);
|
|
2930
|
+
// Get result
|
|
2931
|
+
if (config.doneFunction) {
|
|
2932
|
+
return [2 /*return*/, config.doneFunction()];
|
|
2985
2933
|
}
|
|
2986
|
-
|
|
2987
|
-
if (!config.doneFunction) return [3 /*break*/, 3];
|
|
2988
|
-
return [4 /*yield*/, config.doneFunction()];
|
|
2989
|
-
case 2:
|
|
2990
|
-
result = _a.sent();
|
|
2991
|
-
_a.label = 3;
|
|
2992
|
-
case 3:
|
|
2993
|
-
// Scroll done
|
|
2994
|
-
resolve(result);
|
|
2995
|
-
_a.label = 4;
|
|
2996
|
-
case 4: return [2 /*return*/];
|
|
2934
|
+
return [2 /*return*/];
|
|
2997
2935
|
}
|
|
2998
2936
|
});
|
|
2999
|
-
});
|
|
2937
|
+
});
|
|
3000
2938
|
};
|
|
3001
2939
|
/**
|
|
3002
2940
|
* Scroll done detecton
|