theshtify 1.0.0 → 1.0.2

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.
@@ -0,0 +1,734 @@
1
+ let theshtify_infos = {
2
+ message: '',
3
+ type: '',
4
+ lang: 'en',
5
+ config: {
6
+ x_pos: 'right',
7
+ y_pos: 'top',
8
+ font: {
9
+ family: 'arial',
10
+ size: 14,
11
+ weight: ''
12
+ },
13
+ min_duration: 1000,
14
+ max_duration: 5000,
15
+ duration: 5000,
16
+ borderWidth: 2,
17
+ bordered: false,
18
+ progress: false,
19
+ progressHeight: 2,
20
+ closer: false,
21
+ trans: false,
22
+ display: {
23
+ width: 300,
24
+ colors: {
25
+ custom: {
26
+ color: 'white',
27
+ bg: '#000',
28
+ border: {
29
+ type: 'solid',
30
+ color: 'transparent',
31
+ },
32
+ progress: {
33
+ bg: '#fff'
34
+ }
35
+ },
36
+ success: {
37
+ color: 'white',
38
+ bg: 'rgba(1, 191, 102, 0.822)',
39
+ border: {
40
+ type: 'solid',
41
+ color: 'transparent',
42
+ },
43
+ progress: {
44
+ bg: '#fff'
45
+ }
46
+ },
47
+ danger: {
48
+ bg: 'red',
49
+ color: 'white',
50
+ border: {
51
+ type: 'solid',
52
+ color: 'transparent',
53
+ },
54
+ progress: {
55
+ bg: '#fff'
56
+ }
57
+ },
58
+ info: {
59
+ bg: 'rgba(7, 133, 250, 0.822)',
60
+ color: 'white',
61
+ border: {
62
+ type: 'solid',
63
+ color: 'transparent',
64
+ },
65
+ progress: {
66
+ bg: '#fff'
67
+ }
68
+ },
69
+ warning: {
70
+ bg: '#f89406',
71
+ color: 'black',
72
+ border: {
73
+ type: 'solid',
74
+ color: 'transparent',
75
+ },
76
+ progress: {
77
+ bg: '#fff'
78
+ }
79
+ },
80
+ },
81
+ padding: {
82
+ left: 10,
83
+ right: 10,
84
+ top: 10,
85
+ bottom: 10
86
+ },
87
+ margin: {
88
+ left: 20,
89
+ right: 20,
90
+ top: 20,
91
+ bottom: 20
92
+ },
93
+ radius: 5,
94
+ }
95
+ }
96
+ };
97
+ const types = ['success', 'info', 'danger', 'warning', 'custom'];
98
+ const positions = {
99
+ x: ["middle", "left", "right"],
100
+ y: ["middle", "top", "bottom"],
101
+ }
102
+ const messages = {
103
+ en: {
104
+ errors: {
105
+ type_error: 'the {name} have to be {type} ',
106
+ type: '{name} is {type}',
107
+ duration: "the {type} duration is {ms}MS ({sec}s)",
108
+ position: "the {axis}_pos property have to be one the listed values {values}"
109
+ },
110
+ labels: {
111
+ empty: "empty",
112
+ undefined: "undefined",
113
+ min: "min",
114
+ max: "max",
115
+ }
116
+ }
117
+ }
118
+ /**
119
+ *
120
+ * @param {*} infos
121
+ */
122
+ export function theshtify(infos) {
123
+ let notif = buildBox(infos);
124
+ if (notif != false) {
125
+ addAndPositionNotif(notif);
126
+ animProgress(notif);
127
+ moveDisplayedNotifications(notif)
128
+ fadeShow(notif);
129
+ fadeHide(notif);
130
+ }
131
+ }
132
+ /**
133
+ * Allow to set all the notification box configuration
134
+ * @param {*} config
135
+ * @returns
136
+ */
137
+ function configure(datas) {
138
+ let config = datas.config??{};
139
+ // trying to set message
140
+ try {
141
+ datas.message ? message(datas.message) : '';
142
+ config.duration ? duration(config.duration) : '';
143
+ config.custom_colors ? setCustomColors(config.custom_colors) : '';
144
+ datas.type ? type(datas.type) : '';
145
+ config.bordered ? bordered(config.border) : '';
146
+ config.bordered && config.border_width ? borderWidth(config.border_width) : '';
147
+ config.radius ? radius(config.radius) : '';
148
+ config.colors ? customColors(config.colors) : '';
149
+ config.x_align ? setBoxPosition('x', config.x_align) : '';
150
+ config.y_align ? setBoxPosition('y', config.y_align) : '';
151
+ config.font ? font(config.font) : '';
152
+ config.closer ? withCloser(config.closer) : '';
153
+ config.progress ? haveProgress(config.progress) : '';
154
+ config.progress && config.progress_height ? progressHeight(config.progress_height) : '';
155
+ } catch (error) {
156
+ console.error(`theshtify error \n ${error}`);
157
+ return false
158
+ }
159
+ return true;
160
+ }
161
+ /**
162
+ *
163
+ */
164
+ function setCustomColors(customColors) {
165
+ for (const key in customColors) {
166
+ if (Object.prototype.hasOwnProperty.call(customColors, key)) {
167
+ if (getColor(key)) {
168
+ theshtify_infos.type = key;
169
+ configureColor(customColors[key]);
170
+ }
171
+
172
+ }
173
+ }
174
+ }
175
+ /**
176
+ *
177
+ * @param {*} notif
178
+ */
179
+ function addAndPositionNotif(notif) {
180
+ document.querySelector("body").before(notif);
181
+
182
+ let pos = getPosition({ width: notif.offsetWidth, height: notif.offsetHeight });
183
+ notif.style.left = `${pos.x}px`;
184
+ notif.style.top = `${pos.y}px`;
185
+ }
186
+
187
+ /**setters */
188
+ /**
189
+ * set or return the message
190
+ * @param {*} message
191
+ * @returns
192
+ */
193
+ function message(message = null) {
194
+ if (message != null) {
195
+ switch (true) {
196
+ case message == '':
197
+ throw (cMessages().errors.type, { name: "message", type: cMessages().labels.empty });
198
+ case checkType(message, "undefined"):
199
+ throw (cMessages().errors.type, { name: "message", type: cMessages().labels.undefined });
200
+ case !checkType(message, "string"):
201
+ throw (getMessage(cMessages().errors.type_error, { name: "message", type: "string" }));
202
+
203
+ default:
204
+ theshtify_infos.message = message;
205
+ break;
206
+ }
207
+ } else {
208
+ return message
209
+ }
210
+ }
211
+ /**
212
+ *
213
+ */
214
+ function setBoxPosition(axis, value) {
215
+ if (checkType(value, "string")) {
216
+ if (positions[axis].includes(value)) {
217
+ theshtify_infos.config[`${axis}_pos`] = value
218
+ } else {
219
+ throw (getMessage(cMessages().errors.position, { axis: axis, values: positions[axis].join(',') }));
220
+
221
+ }
222
+ } else {
223
+ throw (getMessage(cMessages().errors.type_error, { name: "colors.color", type: "string" }));
224
+ }
225
+ }
226
+ /**
227
+ *
228
+ * @param {*} colors
229
+ */
230
+ function customColors(colors) {
231
+ if (checkType(colors, "object")) {
232
+ if (theshtify_infos.type == "custom") {
233
+ // box background
234
+ configureColor(colors)
235
+ }
236
+ } else {
237
+ throw (getMessage(cMessages().errors.type_error, { name: "colors", type: "object" }));
238
+ }
239
+ }
240
+ function configureColor(colors) {
241
+ colors.bg ? background(colors.bg) : '';
242
+ // box text colors
243
+ colors.color ? textColor(colors.color) : '';
244
+ // borders
245
+ if (colors.border && theshtify_infos.config.bordered) {
246
+ colors.border.type ? borderType(colors.border.type) : '';
247
+ colors.border.color ? borderColor(colors.border.color) : '';
248
+ }
249
+ if (colors.progress) {
250
+ colors.progress.bg ? progressColor(colors.progress.bg) : '';
251
+ }
252
+ }
253
+ function getColor(name) {
254
+ return theshtify_infos.config.display.colors[name] ?? false;
255
+ }
256
+ /**
257
+ *
258
+ * @param {*} bg
259
+ */
260
+ function background(bg) {
261
+ if (checkType(bg, "string")) {
262
+ currentColor().bg = bg
263
+ } else {
264
+ throw (getMessage(cMessages().errors.type_error, { name: "colors.bg", type: "string" }));
265
+ }
266
+ }
267
+ /**
268
+ *
269
+ * @param {*} color
270
+ */
271
+ function textColor(color) {
272
+ if (checkType(color, "string")) {
273
+ currentColor().color = color
274
+ } else {
275
+ throw (getMessage(cMessages().errors.type_error, { name: "colors.color", type: "string" }));
276
+ }
277
+ }
278
+ /**
279
+ *
280
+ * @param {*} borders
281
+ */
282
+ function borderColor(color) {
283
+ //borders colors
284
+ if (checkType(color, "string")) {
285
+ currentColor().border.color = color
286
+ } else {
287
+ throw (getMessage(cMessages().errors.type_error, { name: "colors.border.color", type: "string" }));
288
+ }
289
+ }
290
+ /**
291
+ *
292
+ * @param {*} type
293
+ */
294
+ function borderType(type) {
295
+ // border type
296
+ if (checkType(type, "string")) {
297
+ currentColor().border.type = type
298
+ } else {
299
+ throw (getMessage(cMessages().errors.type_error, { name: "colors.border.type", type: "string" }));
300
+ }
301
+ }
302
+ /**
303
+ *
304
+ * @param {*} width
305
+ */
306
+ function borderWidth(width) {
307
+ if (checkType(width, "number")) {
308
+ theshtify_infos.config.borderWidth = width
309
+ } else {
310
+ throw (getMessage(cMessages().errors.type_error, { name: "borderWidth", type: "number" }));
311
+ }
312
+ }
313
+ /**
314
+ *
315
+ * @param {*} width
316
+ */
317
+ function radius(radius) {
318
+ if (checkType(radius, "number")) {
319
+ theshtify_infos.config.display.radius = radius
320
+ } else {
321
+ throw (getMessage(cMessages().errors.type_error, { name: "radius", type: "number" }));
322
+ }
323
+ }
324
+ /**
325
+ *
326
+ * @param {*} bordered
327
+ */
328
+ function bordered(bordered = false) {
329
+ if (checkType(bordered, "boolean")) {
330
+ theshtify_infos.config.bordered = bordered
331
+ } else {
332
+ throw (getMessage(cMessages().errors.type_error, { name: "bordered", type: "boolean" }));
333
+ }
334
+ }
335
+ /**
336
+ *
337
+ * @param {*} progress
338
+ */
339
+ function haveProgress(progress = false) {
340
+ if (checkType(progress, "boolean")) {
341
+ theshtify_infos.config.progress = progress
342
+ } else {
343
+ throw (getMessage(cMessages().errors.type_error, { name: "progress", type: "boolean" }));
344
+ }
345
+ }
346
+ /**
347
+ *
348
+ * @param {*} closer
349
+ */
350
+ function withCloser(closer = false) {
351
+ if (checkType(closer, "boolean")) {
352
+ theshtify_infos.config.closer = closer
353
+ } else {
354
+ throw (getMessage(cMessages().errors.type_error, { name: "closer", type: "boolean" }));
355
+ }
356
+ }
357
+ /**
358
+ *
359
+ * @param {*} width
360
+ */
361
+ function progressHeight(height) {
362
+ if (checkType(height, "number")) {
363
+ theshtify_infos.config.progressHeight = height
364
+ } else {
365
+ throw (getMessage(cMessages().errors.type_error, { name: "progressHeight", type: "number" }));
366
+ }
367
+ }
368
+ /**
369
+ *
370
+ * @param {*} color
371
+ */
372
+ function progressColor(color) {
373
+ if (checkType(color, "string")) {
374
+ currentColor().progress.bg = color
375
+ } else {
376
+ throw (getMessage(cMessages().errors.type_error, { name: "progress.bg", type: "string" }));
377
+ }
378
+ }
379
+
380
+ /**
381
+ * set the display duration of the notification box
382
+ * @param {*} duration
383
+ */
384
+ function duration(duration) {
385
+ if (checkType(duration, "number")) {
386
+ if (duration <= theshtify_infos.config.max_duration) {
387
+ theshtify_infos.config.duration = duration;
388
+ } else {
389
+ throw (getMessage(cMessages().errors.duration, { type: cMessages().labels.max, ms: `${theshtify_infos.config.max_duration}`, sec: `${theshtify_infos.config.max_duration / 1000}` }));
390
+ }
391
+ if (duration >= theshtify_infos.config.min_duration) {
392
+ theshtify_infos.config.duration = duration;
393
+ } else {
394
+ throw (getMessage(cMessages().errors.duration, { type: cMessages().labels.min, ms: `${theshtify_infos.config.min_duration}`, sec: `${theshtify_infos.config.min_duration / 1000}` }));
395
+ }
396
+ } else {
397
+ throw (getMessage(cMessages().errors.type_error, { name: "duration", type: "number" }));
398
+
399
+ }
400
+ }
401
+ /**
402
+ * set or return the type of the notification type
403
+ * @param {*} type
404
+ * @returns
405
+ */
406
+ function type(type) {
407
+ if (type != null) {
408
+ if (types.includes(type)) {
409
+ theshtify_infos.type = type;
410
+ } else {
411
+ throw ('the given type is not supported')
412
+ }
413
+ } else {
414
+ return type
415
+ }
416
+ }
417
+ /**
418
+ * allow you to configure the font properties
419
+ * @param {*} font
420
+ * @returns
421
+ */
422
+ function font(font) {
423
+ if (font) {
424
+ //
425
+ if (font.size) {
426
+ if (checkType(font.size, 'number')) {
427
+ theshtify_infos.config.font.size = font.size;
428
+ } else {
429
+ throw (getMessage(cMessages().errors.type_error, { name: 'font.size', type: 'number' }))
430
+ }
431
+ }
432
+ if (font.weight) {
433
+ if (checkType(font.weight, 'number')) {
434
+ theshtify_infos.config.font.weight = font.weight;
435
+ } else {
436
+ throw (getMessage(cMessages().errors.type_error, { name: 'font.weight', type: 'number' }))
437
+ }
438
+ }
439
+ if (font.family) {
440
+ if (checkType(font.family, 'string')) {
441
+ theshtify_infos.config.font.family = font.family;
442
+ } else {
443
+ throw (getMessage(cMessages().errors.type_error, { name: 'font.family', type: 'string' }))
444
+ }
445
+ }
446
+ } else {
447
+ return theshtify_infos.config.font;
448
+ }
449
+ }
450
+ /**
451
+ * allow to get the messages of the current lang
452
+ * @returns
453
+ */
454
+ function cMessages() {
455
+ return messages[theshtify_infos.lang];
456
+ }
457
+ /**
458
+ * allow to get the message
459
+ * @param {*} message
460
+ * @param {*} params
461
+ * @returns
462
+ */
463
+ function getMessage(message = '', params = {}) {
464
+ let mes = message;
465
+ for (const key in params) {
466
+ if (Object.prototype.hasOwnProperty.call(params, key)) {
467
+ mes = mes.replace(`{${key}}`, params[key])
468
+ }
469
+ }
470
+ return mes;
471
+ }
472
+ /**
473
+ * return the current colors that matches the selected type
474
+ * @returns
475
+ */
476
+ function currentColor() {
477
+ return theshtify_infos.config.display.colors[theshtify_infos.type];
478
+ }
479
+ /**
480
+ * return the position of the notigications boxes according with the current position
481
+ * @param {*} boxSize
482
+ * @returns
483
+ */
484
+ function getPosition(boxSize) {
485
+ let retPos = {
486
+ x: 0,
487
+ y: 0
488
+ }
489
+ theshtify_infos.config.x_pos == 'left' ? retPos.x = theshtify_infos.config.display.margin.left : 0;
490
+ theshtify_infos.config.x_pos == 'right' ? retPos.x = window.innerWidth - (boxSize.width + theshtify_infos.config.display.margin.right) : 0;
491
+ theshtify_infos.config.x_pos == 'middle' ? retPos.x = (window.innerWidth - boxSize.width) / 2 : 0;
492
+ theshtify_infos.config.y_pos == 'top' ? retPos.y = 0 + theshtify_infos.config.display.margin.top : 0;
493
+ theshtify_infos.config.y_pos == 'bottom' ? retPos.y = window.innerHeight - (boxSize.height + theshtify_infos.config.display.margin.bottom) : 0;
494
+ theshtify_infos.config.y_pos == 'middle' ? retPos.y = (window.innerHeight - boxSize.height) / 2 : 0;
495
+ return retPos;
496
+ }
497
+ /**controllers */
498
+ /**
499
+ * allow to verify element type (is mostly used to check configuration property type)
500
+ * @param {*} value
501
+ * @param {*} neededType
502
+ * @returns
503
+ */
504
+ function checkType(value, neededType) {
505
+ return typeof (value) === neededType;
506
+ }
507
+ /** builders */
508
+ /**
509
+ *
510
+ * @param {*} config
511
+ * @returns
512
+ */
513
+ function buildBox(config) {
514
+ if (configure(config)) {
515
+ let box = mainContainer();
516
+ theshtify_infos.config.closer ? box.append(dismiss()) : '';
517
+ box.append(body());
518
+ theshtify_infos.config.progress ? box.append(progress()) : '';
519
+ return box;
520
+
521
+ } else {
522
+ return false;
523
+ }
524
+ }
525
+ /**
526
+ *
527
+ * @returns
528
+ */
529
+ function mainContainer() {
530
+ var notif = document.createElement("div");
531
+
532
+ notif.setAttribute("class", "Thesharsol-notifyer");
533
+ notif.style.width = `${theshtify_infos.config.display.width}px`;
534
+ notif.style.position = 'fixed';
535
+ notif.style.zIndex = 999, 999;
536
+ notif.style.opacity = 0;
537
+
538
+ notif.style.fontFamily = `${theshtify_infos.config.font.family}`;
539
+ notif.style.fontSize = `${theshtify_infos.config.font.size}px`;
540
+ notif.style.fontWeight = `${theshtify_infos.config.font.weight}`;
541
+
542
+ notif.style.borderRadius = `${theshtify_infos.config.display.radius}px`;
543
+ notif.style.backgroundColor = theshtify_infos.config.display.colors[theshtify_infos.type].bg;
544
+ notif.setAttribute('index', document.querySelectorAll('.Thesharsol-notifyer').length)
545
+ if (theshtify_infos.config.bordered) {
546
+ notif.style.border = `${theshtify_infos.config.borderWidth}px ${currentColor().border.type} ${currentColor().border.color}`
547
+ }
548
+
549
+ return notif;
550
+ }
551
+
552
+ /**
553
+ * Build the boy of the notification
554
+ * @returns
555
+ */
556
+ function body() {
557
+ let body = document.createElement('div');
558
+ let bodyContent = document.createElement('div');
559
+ body.setAttribute('style', 'width:100%')
560
+ // bodyContent.setAttribute('style','width:100%')
561
+
562
+ bodyContent.style.color = theshtify_infos.config.display.colors[theshtify_infos.type].color;
563
+ bodyContent.style.paddingLeft = `${theshtify_infos.config.display.padding.left}px`;
564
+ bodyContent.style.paddingRight = `${theshtify_infos.config.display.padding.right}px`;
565
+ bodyContent.style.paddingTop = `${theshtify_infos.config.display.padding.top}px`;
566
+ bodyContent.style.paddingBottom = `${theshtify_infos.config.display.padding.bottom}px`;
567
+ bodyContent.innerText = theshtify_infos.message;
568
+ body.append(bodyContent);
569
+ return body;
570
+ }
571
+ /**
572
+ * Buildand return the dismiss notification part
573
+ * @returns
574
+ */
575
+ function dismiss() {
576
+ let dismiss = document.createElement('div');
577
+ let dismissContent = document.createElement('button');
578
+ // style
579
+ dismissContent.classList.add('close-icon');
580
+ dismissContent.fontSize = `22px`
581
+ dismiss.setAttribute('style', `display:flex;padding:${theshtify_infos.config.display.padding.top}px ${theshtify_infos.config.display.padding.top}px 0px ${theshtify_infos.config.display.padding.top}px;`);
582
+ dismissContent.setAttribute('style', `font-weight:bold;margin-left:auto;background:transparent;border:0px;color:${currentColor().color}`);
583
+
584
+ dismiss.append(dismissContent);
585
+
586
+ dismissContent.addEventListener('click', () => {
587
+ let boxToRemove = dismissContent.parentNode.parentNode;
588
+ moveDisplayedNotifications(boxToRemove, "remove", parseInt(boxToRemove.getAttribute("index")));
589
+ boxToRemove.remove()
590
+ })
591
+ return dismiss;
592
+ }
593
+
594
+ /**
595
+ * Build and return the pargress bar of the notification box
596
+ * @returns
597
+ */
598
+ function progress() {
599
+ let progress = document.createElement('div');
600
+ let progressContent = document.createElement('div');
601
+ progress.style.width = '100%';
602
+ progress.style.borderRadius = `${theshtify_infos.config.display.radius}px`;
603
+ progress.style.overflow = 'hidden'
604
+ progress.classList.add('progress');
605
+ progressContent.setAttribute('style', 'height:2px;width:0px');
606
+
607
+ progressContent.style.minHeight = `${theshtify_infos.config.progressHeight}px`;
608
+ progressContent.style.width = '0px';
609
+ progressContent.classList.add('content');
610
+ progressContent.style.background = `${currentColor().progress ? currentColor().progress.bg : 'white'}`;
611
+ progress.append(progressContent);
612
+ return progress;
613
+ }
614
+ /**
615
+ * animate the progress bar
616
+ * @param {*} box
617
+ */
618
+ function animProgress(box) {
619
+ let progressBar = box.querySelector('.progress');
620
+ if (progressBar != undefined) {
621
+ let progressBoxContent = box.querySelector('.content');
622
+
623
+ //
624
+ let maxProgressContentWidth = progressBar.offsetWidth;
625
+ let increment = maxProgressContentWidth / (theshtify_infos.config.duration / 30);
626
+ let width = 0;
627
+ let incInt = setInterval(() => {
628
+ width += increment;
629
+ progressBoxContent.style.width = `${width}px`;
630
+
631
+ if (maxProgressContentWidth <= width) {
632
+ clearInterval(incInt);
633
+ }
634
+ }, 30);
635
+ }
636
+
637
+
638
+ }
639
+ /** animations */
640
+ /**
641
+ * Move the displayed notification afer creating or destroying one
642
+ * @param {*} createdBox
643
+ * @param {*} moveType
644
+ * @param {*} startIndex
645
+ */
646
+ function moveDisplayedNotifications(createdBox, moveType = "add", startIndex = 0) {
647
+ let notifBoxes = document.querySelectorAll('.Thesharsol-notifyer');
648
+ let offset = createdBox.offsetHeight + 20;
649
+ //
650
+ let boxesCumulatedHeihgt = offset;
651
+
652
+ switch (moveType) {
653
+ case "add":
654
+ for (let i = startIndex; i < notifBoxes.length; i++) {
655
+ boxesCumulatedHeihgt = changeBoxPosition(notifBoxes, i, moveType, boxesCumulatedHeihgt, createdBox, offset);
656
+ }
657
+ break;
658
+ case "remove":
659
+ console.log('remove')
660
+ let si = Array.prototype.indexOf.call(notifBoxes, createdBox);
661
+ for (let i = si; i >= 0; i--) {
662
+ boxesCumulatedHeihgt = changeBoxPosition(notifBoxes, i, moveType, boxesCumulatedHeihgt, createdBox, offset);
663
+ }
664
+ for (let j = (si + 1); j < notifBoxes.length; j++) {
665
+ notifBoxes[j].setAttribute('index', j - 1);
666
+ console.log((si))
667
+ }
668
+ break;
669
+ default:
670
+ break;
671
+ }
672
+
673
+ if (boxesCumulatedHeihgt > ((window.innerHeight * 50) / 100)) {
674
+ notifBoxes[0].remove();
675
+ }
676
+ }
677
+ /**
678
+ *
679
+ * @param {*} notifBoxes
680
+ * @param {*} i
681
+ * @param {*} moveType
682
+ * @param {*} boxesCumulatedHeihgt
683
+ * @param {*} createdBox
684
+ * @param {*} offset
685
+ * @returns
686
+ */
687
+ function changeBoxPosition(notifBoxes, i, moveType, boxesCumulatedHeihgt, createdBox, offset) {
688
+ let box = notifBoxes[i];
689
+
690
+ if (createdBox != box && box != undefined) {
691
+
692
+ if (theshtify_infos.config.y_pos == 'bottom') {
693
+ box.style.top = moveType == "add" ? `${box.offsetTop - offset}px` : `${box.offsetTop + offset}px`;
694
+ }
695
+ if (theshtify_infos.config.y_pos == 'top') {
696
+ box.style.top = moveType == "add" ? `${box.offsetTop + offset}px` : `${box.offsetTop - offset}px`;
697
+ }
698
+ boxesCumulatedHeihgt += box.offsetHeight;
699
+ }
700
+ return boxesCumulatedHeihgt;
701
+ }
702
+ /**
703
+ *
704
+ * @param {*} notif
705
+ */
706
+ function fadeShow(notif) {
707
+ var op = 0;
708
+ var it = setInterval(function () {
709
+ op = op + 0.01;
710
+ notif.style.opacity = op;
711
+ // console.log(notif)
712
+ if (op > 0.9) {
713
+ clearInterval(it);
714
+ }
715
+ }, 1);
716
+ }
717
+ /**
718
+ *
719
+ * @param {*} notif
720
+ */
721
+ function fadeHide(notif) {
722
+ setTimeout(function () {
723
+ var op = 1;
724
+ var it = setInterval(function () {
725
+ op = op - 0.01;
726
+ notif.style.opacity = op;
727
+ // console.log(notif)
728
+ if (op < 0.01) {
729
+ notif.remove();
730
+ clearInterval(it);
731
+ }
732
+ }, 1);
733
+ }, theshtify_infos.config.duration);
734
+ }