@kizmann/nano-ui 0.8.27 → 0.8.28

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kizmann/nano-ui",
3
- "version": "0.8.27",
3
+ "version": "0.8.28",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "author": "Eduard Kizmann <kizmann@protonmail.ch>",
@@ -279,27 +279,33 @@ export default {
279
279
  value.fallback);
280
280
  });
281
281
 
282
- let element = alias.replace(/:.*?$/, '');
282
+ let component = alias.replace(/:.*?$/, '');
283
283
 
284
- let component = null;
285
-
286
- try {
287
- component = resolveComponent(element);
288
- } catch (e) {
289
- component = element;
284
+ if ( !Arr.has(['div', 'p'], component) ) {
285
+ component = resolveComponent(component);
290
286
  }
291
287
 
292
288
  if ( Any.isEmpty(component) ) {
293
289
  return null;
294
290
  }
295
291
 
296
- if ( ! this.propExists(setup['vShow']) ) {
292
+ if ( !this.propExists(setup['vShow']) ) {
297
293
  props.style = "display: none;";
298
294
  }
299
295
 
300
- return h(component, props, () => {
301
- return Arr.each(setup.content, (value, key) => this.ctor('renderSetup')(value, key));
296
+ let render = () => Arr.each(setup.content, (value, key) => {
297
+ return this.ctor('renderSetup')(value, key)
302
298
  });
299
+
300
+ if ( Any.isFunction(setup.content) ) {
301
+ render = setup.content.apply(this.scope);
302
+ }
303
+
304
+ if ( Any.isString(setup.content) ) {
305
+ render = setup.content;
306
+ }
307
+
308
+ return h(component, props, render);
303
309
  },
304
310
 
305
311
  render()
@@ -87,9 +87,9 @@ export default {
87
87
  'n-preview-image'
88
88
  ];
89
89
 
90
- if ( Arr.has(window.ImageCache, this.src) ) {
91
- classList.push('n-cached');
92
- }
90
+ // if ( Arr.has(window.ImageCache, this.src) ) {
91
+ // classList.push('n-cached');
92
+ // }
93
93
 
94
94
  if ( ! this.load ) {
95
95
  classList.push('n-ready');
@@ -97,7 +97,7 @@ export default {
97
97
  computed: {
98
98
 
99
99
  touch() {
100
- return !! ('ontouchstart' in window ||
100
+ return !! ('ontouchstart' in window ||
101
101
  navigator.msMaxTouchPoints);
102
102
  },
103
103
 
@@ -145,10 +145,10 @@ export default {
145
145
  Event.bind('NResizer:moved',
146
146
  this.onUpdate, this._.uid);
147
147
 
148
- Dom.find(window).on('resize',
148
+ Dom.find(window).on('resize',
149
149
  this.onResize, passive);
150
-
151
- Dom.find(this.$refs.content).on('scroll',
150
+
151
+ Dom.find(this.$refs.content).on('scroll',
152
152
  this.onScroll, passive);
153
153
  },
154
154
 
@@ -168,16 +168,16 @@ export default {
168
168
  passive: true, uid: this._.uid
169
169
  };
170
170
 
171
- Event.unbind('NScrollbar:resize',
171
+ Event.unbind('NScrollbar:resize',
172
172
  this._.uid);
173
173
 
174
- Event.unbind('NResizer:moved',
174
+ Event.unbind('NResizer:moved',
175
175
  this._.uid);
176
176
 
177
- Dom.find(window).off('resize',
177
+ Dom.find(window).off('resize',
178
178
  null, passive);
179
179
 
180
- Dom.find(this.$el).off('scroll',
180
+ Dom.find(this.$el).off('scroll',
181
181
  null, passive);
182
182
  },
183
183
 
@@ -253,7 +253,7 @@ export default {
253
253
 
254
254
  adaptScrollHeight()
255
255
  {
256
- if ( this.native ) {
256
+ if ( this.native && this.allowNative ) {
257
257
  return;
258
258
  }
259
259
 
@@ -264,7 +264,11 @@ export default {
264
264
  // this.$refs.content.offsetWidth;
265
265
 
266
266
  let outerHeight = this.$refs.content.
267
- clientHeight|| 0;
267
+ clientHeight || 0;
268
+
269
+ if ( this.native && ! this.allowNative ) {
270
+ outerHeight -= 16;
271
+ }
268
272
 
269
273
  // if ( offsetHeight === 0 && this.overflowX ) {
270
274
  // outerHeight -= 15;
@@ -273,11 +277,15 @@ export default {
273
277
  let innerHeight = this.$refs.content
274
278
  .scrollHeight || 0;
275
279
 
280
+ if ( this.native && ! this.allowNative ) {
281
+ innerHeight -= 16;
282
+ }
283
+
276
284
  // if ( offsetHeight === 0 && this.overflowX ) {
277
285
  // innerHeight -= 15;
278
286
  // }
279
287
 
280
- let isSameOld = outerHeight === this.outerHeight &&
288
+ let isSameOld = outerHeight === this.outerHeight &&
281
289
  innerHeight === this.innerHeight;
282
290
 
283
291
  if ( isSameOld ) {
@@ -287,15 +295,15 @@ export default {
287
295
  this.outerHeight = outerHeight;
288
296
  this.innerHeight = innerHeight;
289
297
 
290
- let height = (outerHeight / innerHeight)
298
+ let height = (outerHeight / innerHeight)
291
299
  * outerHeight;
292
300
 
293
301
  let barHeight = Math.max(height, 50);
294
302
 
295
- let maxHeight = Math.ceil((outerHeight / innerHeight) *
303
+ let maxHeight = Math.ceil((outerHeight / innerHeight) *
296
304
  (innerHeight - outerHeight));
297
-
298
- this.heightRatio = (maxHeight - (barHeight - height)
305
+
306
+ this.heightRatio = (maxHeight - (barHeight - height)
299
307
  - this.offsetY) / maxHeight;
300
308
 
301
309
  Dom.find(this.$refs.vbar).css({
@@ -331,7 +339,7 @@ export default {
331
339
 
332
340
  adaptScrollWidth()
333
341
  {
334
- if ( this.native ) {
342
+ if ( this.native && this.allowNative ) {
335
343
  return;
336
344
  }
337
345
 
@@ -343,7 +351,11 @@ export default {
343
351
 
344
352
  let outerWidth = this.$refs.content.
345
353
  clientWidth || 0;
346
-
354
+
355
+ if ( this.native && ! this.allowNative ) {
356
+ outerWidth -= 16;
357
+ }
358
+
347
359
  // if ( offsetWidth === 0 && this.overflowY ) {
348
360
  // outerWidth -= 15;
349
361
  // }
@@ -351,11 +363,15 @@ export default {
351
363
  let innerWidth = this.$refs.content
352
364
  .scrollWidth || 0;
353
365
 
366
+ if ( this.native && ! this.allowNative ) {
367
+ innerWidth -= 16;
368
+ }
369
+
354
370
  // if ( offsetWidth === 0 && this.overflowY ) {
355
371
  // innerWidth -= 15;
356
372
  // }
357
373
 
358
- let isSameOld = outerWidth === this.outerWidth &&
374
+ let isSameOld = outerWidth === this.outerWidth &&
359
375
  innerWidth === this.innerWidth;
360
376
 
361
377
  if ( isSameOld ) {
@@ -365,15 +381,15 @@ export default {
365
381
  this.outerWidth = outerWidth;
366
382
  this.innerWidth = innerWidth;
367
383
 
368
- let width = (outerWidth / innerWidth)
384
+ let width = (outerWidth / innerWidth)
369
385
  * outerWidth;
370
386
 
371
387
  let barWidth = Math.max(width, 50);
372
388
 
373
- let maxWidth = Math.ceil((outerWidth / innerWidth) *
389
+ let maxWidth = Math.ceil((outerWidth / innerWidth) *
374
390
  (innerWidth - outerWidth));
375
-
376
- this.widthRatio = (maxWidth - (barWidth - width)
391
+
392
+ this.widthRatio = (maxWidth - (barWidth - width)
377
393
  - this.offsetX) / maxWidth;
378
394
 
379
395
  Dom.find(this.$refs.hbar).css({
@@ -381,7 +397,7 @@ export default {
381
397
  });
382
398
 
383
399
  // let hasNativeBar = offsetHeight && this.overflowX;
384
-
400
+
385
401
  // if ( hasNativeBar ) {
386
402
  // Dom.find(this.$el).addClass('has-native-hbar');
387
403
  // }
@@ -409,7 +425,7 @@ export default {
409
425
 
410
426
  adaptScrollPosition(scroll = {})
411
427
  {
412
- if ( this.native ) {
428
+ if ( this.native && this.allowNative ) {
413
429
  return;
414
430
  }
415
431
 
@@ -421,7 +437,7 @@ export default {
421
437
  scroll.left = this.$refs.content.scrollLeft;
422
438
  }
423
439
 
424
- let vbarTop= Math.ceil((this.outerHeight / this.innerHeight) *
440
+ let vbarTop= Math.ceil((this.outerHeight / this.innerHeight) *
425
441
  scroll.top * this.heightRatio) || 0;
426
442
 
427
443
  if ( ! this.vbarTop || vbarTop !== this.vbarTop ) {
@@ -433,7 +449,7 @@ export default {
433
449
  this.vbarTop = vbarTop;
434
450
  }
435
451
 
436
- let hbarLeft = Math.ceil((this.outerWidth / this.innerWidth) *
452
+ let hbarLeft = Math.ceil((this.outerWidth / this.innerWidth) *
437
453
  scroll.left * this.widthRatio) || 0;
438
454
 
439
455
  if ( ! this.hbarLeft || hbarLeft !== this.hbarLeft ) {
@@ -441,7 +457,7 @@ export default {
441
457
  Dom.find(this.$refs.hbar).css({
442
458
  transform: `translateX(${hbarLeft}px) translateZ(0)`
443
459
  });
444
-
460
+
445
461
  this.hbarLeft = hbarLeft;
446
462
  }
447
463
  },
@@ -489,7 +505,7 @@ export default {
489
505
 
490
506
  bindAdaptHeight()
491
507
  {
492
- this.refreshHeight = setInterval(this.adaptHeight,
508
+ this.refreshHeight = setInterval(this.adaptHeight,
493
509
  1000 / this.framerate);
494
510
  },
495
511
 
@@ -539,7 +555,7 @@ export default {
539
555
 
540
556
  bindAdaptWidth()
541
557
  {
542
- this.refreshWidth = setInterval(this.adaptWidth,
558
+ this.refreshWidth = setInterval(this.adaptWidth,
543
559
  1000 / this.framerate);
544
560
  },
545
561
 
@@ -558,7 +574,7 @@ export default {
558
574
  let scrollUpdate = () => {
559
575
  this.$emit('scrollupdate', scroll.top, scroll.left);
560
576
  }
561
-
577
+
562
578
  this.$nextTick(scrollUpdate);
563
579
  this.adaptScrollPosition(scroll);
564
580
  },
@@ -592,7 +608,7 @@ export default {
592
608
 
593
609
  this.resizeTimer = setTimeout(
594
610
  this.onUpdate, 500);
595
-
611
+
596
612
  Dom.find(this.$el).fire('resized');
597
613
  },
598
614
 
@@ -641,10 +657,10 @@ export default {
641
657
 
642
658
  event.stopPropagation();
643
659
 
644
- Dom.find(document).on(this.mousemove,
660
+ Dom.find(document).on(this.mousemove,
645
661
  this.onVbarMousemove, this._.uid);
646
662
 
647
- Dom.find(document).on(this.mouseup,
663
+ Dom.find(document).on(this.mouseup,
648
664
  this.onVbarMouseup, this._.uid);
649
665
 
650
666
  this.scrollTop = this.$refs.content
@@ -659,24 +675,24 @@ export default {
659
675
  let clientY = this.getTouchEvent(event)
660
676
  .clientY;
661
677
 
662
- let top = (this.outerHeight / this.innerHeight) *
678
+ let top = (this.outerHeight / this.innerHeight) *
663
679
  this.scrollTop * this.heightRatio;
664
680
 
665
681
  let offset = (clientY - this.clientY) + top;
666
682
 
667
- let height = (this.outerHeight -
668
- this.barHeight - this.offsetY);
683
+ let height = (this.outerHeight -
684
+ this.barHeight - this.offsetY);
669
685
 
670
- this.$refs.content.scrollTop = offset / height *
686
+ this.$refs.content.scrollTop = offset / height *
671
687
  (this.innerHeight - this.outerHeight);
672
688
  },
673
689
 
674
690
  onVbarMouseup(event)
675
691
  {
676
- Dom.find(document).off(this.mousemove,
692
+ Dom.find(document).off(this.mousemove,
677
693
  null, this._.uid);
678
694
 
679
- Dom.find(document).off(this.mouseup,
695
+ Dom.find(document).off(this.mouseup,
680
696
  null, this._.uid);
681
697
  },
682
698
 
@@ -685,13 +701,13 @@ export default {
685
701
  if ( ! Arr.has([0, 1], event.which) ) {
686
702
  return;
687
703
  }
688
-
704
+
689
705
  event.stopPropagation();
690
706
 
691
- Dom.find(document).on(this.mousemove,
707
+ Dom.find(document).on(this.mousemove,
692
708
  this.onHbarMousemove, this._.uid);
693
709
 
694
- Dom.find(document).on(this.mouseup,
710
+ Dom.find(document).on(this.mouseup,
695
711
  this.onHbarMouseup, this._.uid);
696
712
 
697
713
  this.scrollLeft = this.$refs.content
@@ -702,24 +718,24 @@ export default {
702
718
 
703
719
  onHbarMousemove(event)
704
720
  {
705
- let top = (this.outerWidth / this.innerWidth) *
721
+ let top = (this.outerWidth / this.innerWidth) *
706
722
  this.scrollLeft * this.widthRatio;
707
723
 
708
724
  let offset = (event.clientX - this.clientX) + top;
709
725
 
710
- let width = (this.outerWidth -
711
- this.barWidth - this.offsetX);
726
+ let width = (this.outerWidth -
727
+ this.barWidth - this.offsetX);
712
728
 
713
- this.$refs.content.scrollLeft = offset / width *
729
+ this.$refs.content.scrollLeft = offset / width *
714
730
  (this.innerWidth - this.outerWidth);
715
731
  },
716
732
 
717
733
  onHbarMouseup(event)
718
734
  {
719
- Dom.find(document).off(this.mousemove,
735
+ Dom.find(document).off(this.mousemove,
720
736
  null, this._.uid);
721
737
 
722
- Dom.find(document).off(this.mouseup,
738
+ Dom.find(document).off(this.mouseup,
723
739
  null, this._.uid);
724
740
  }
725
741
 
@@ -735,6 +751,10 @@ export default {
735
751
  classList.push('n-scrollbar--native');
736
752
  }
737
753
 
754
+ if ( ! this.allowNative ) {
755
+ classList.push('n-scrollbar--forced');
756
+ }
757
+
738
758
  if ( this.touch ) {
739
759
  classList.push('n-scrollbar--touch');
740
760
  }
@@ -38,6 +38,13 @@
38
38
  bottom: -17px;
39
39
  }
40
40
 
41
+ .n-scrollbar.n-scrollbar--forced.n-scrollbar--native > .n-scrollbar-content {
42
+ padding-right: 16px;
43
+ padding-bottom: 16px;
44
+ right: -16px;
45
+ bottom: -16px;
46
+ }
47
+
41
48
  .n-scrollbar:not(.n-overflow-x) > .n-scrollbar-content {
42
49
  bottom: 0;
43
50
  overflow-x: hidden;
@@ -66,15 +73,16 @@
66
73
  width: 10px;
67
74
  }
68
75
 
76
+
69
77
  .n-scrollbar-h {
70
78
  left: 0;
71
79
  bottom: 0;
72
80
  height: 10px;
73
81
  }
74
82
 
75
- .n-scrollbar--native > .n-scrollbar-v,
83
+ .n-scrollbar--native:not(.n-scrollbar--forced) > .n-scrollbar-v,
76
84
  .n-scrollbar:not(.has-vtrack) > .n-scrollbar-v,
77
- .n-scrollbar--native > .n-scrollbar-h,
85
+ .n-scrollbar--native:not(.n-scrollbar--forced) > .n-scrollbar-h,
78
86
  .n-scrollbar:not(.has-htrack) > .n-scrollbar-h {
79
87
  display: none;
80
88
  }