tencent.jquery.pix.component 1.0.66-beta1 → 1.0.66-beta3

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.
@@ -13,6 +13,7 @@ import './videocss.scss'
13
13
  * @param {object} options 选项
14
14
  * @param {string} options.container 容器元素的jquery选择器
15
15
  * @param {string} options.vid 腾讯视频id
16
+ * @param {string} [options.videoUrl] 视频地址,非腾讯视频时使用,比如上传到cos的视频
16
17
  * @param {string} [options.previewUrl] 视频预览图
17
18
  * @param {0|1} [options.videoType=1] 视频类型选项,0: 标清,1: 高清
18
19
  * @param {number} [options.autoHideControlsDelayMs=5000] 自动隐藏控制条延迟时间,单位ms
@@ -51,8 +52,14 @@ VideoPlayer.prototype.init = async function() {
51
52
  clickToPause: false,
52
53
  ...this.options
53
54
  }
55
+ //如果vid不存在,则直接获取option.videoUrl
56
+ const videoURL = this.options.vid ? await getVideoURL(this.options.vid, this.options.videoType) : this.options.videoUrl;
57
+ //如果videoUrl不存在,则抛出错误
58
+ if (!videoURL) {
54
59
 
55
- const videoURL = await getVideoURL(this.options.vid, this.options.videoType);
60
+ throw new Error('videoURL is required');
61
+
62
+ }
56
63
  $container.find('.myplayer-video-mask').before(`<video src="${videoURL}"></video>`);
57
64
 
58
65
  this.state = {
@@ -12,6 +12,7 @@ const DEFAULTS = {
12
12
  marginTop: 0, // 距离顶部距离
13
13
  marginBottom: 12, // 最后一行距离底部距离
14
14
  bufferHeight: '2rem', // 缓冲高度,进行可能的预先添加高度
15
+ startPoints: [], // 起始点坐标
15
16
  data: [], // 数据源
16
17
  container: '', // 容器元素
17
18
  renderItem(data, index) { // 元素首次渲染时的回调函数, 如果把updateItem设置为空,那么更新时则会兜底触发renderItem
@@ -87,6 +88,13 @@ export function Waterfall(optionsInput = {}) {
87
88
  options.marginBottom = parseFloat(options.marginBottom);
88
89
  }
89
90
  }
91
+ options.startPoints.forEach((item, index) => {
92
+ if (item.constructor === String) {
93
+ options.startPoints[index] = remToPx(item);
94
+ } else {
95
+ item = parseFloat(item);
96
+ }
97
+ });
90
98
 
91
99
  const allWidth = $container.width();
92
100
  this.allWidth = allWidth;
@@ -130,6 +138,8 @@ Waterfall.prototype.init = function () {
130
138
  const $container = $(options.container);
131
139
  const $scrollDom = options.scrollDom ? $(options.scrollDom) : $container;
132
140
 
141
+ this.$scrollDom = $scrollDom;
142
+
133
143
  this.nodePool = []; // DOM 节点池
134
144
  this.activeNodes = new Map(); // 当前活跃节点(索引 -> DOM)
135
145
  this.allReadyNodes = new Map(); // 所有节点(索引 -> DOM)
@@ -188,7 +198,7 @@ Waterfall.prototype.updateVisibleItems = function (force = false) {
188
198
  const startTop = self.scrollTop; // 当前滚动位置
189
199
  const endTop = startTop + h;
190
200
  // console.log('startTop', startTop)
191
- console.log('endTop', endTop)
201
+ // console.log('endTop', endTop)
192
202
 
193
203
  // 进行可见区域的渲染更新
194
204
  this.updateCardsInView({
@@ -393,20 +403,30 @@ Waterfall.prototype.getMinHeight = function () {
393
403
  Waterfall.prototype.getMinHeightColumn = function () {
394
404
  let minHeight = -1;
395
405
  let mimHeightColumn = null;
406
+ let index = -1;
407
+ const startPoints = this.options.startPoints || [];
396
408
  for (let i = 0; i < this.columns; i++) {
397
409
  const column = this.columnItems[i]
398
-
399
- // 获取每组元素列表的最后一个bottom值
400
- if (minHeight > column.bottom) {
410
+ if (minHeight === -1) {
401
411
  minHeight = column.bottom;
402
412
  mimHeightColumn = column;
403
- } else if (minHeight === -1) {
413
+ index = i;
414
+ } else if (minHeight > column.bottom) {
415
+ // 获取每组元素列表的最后一个bottom值
404
416
  minHeight = column.bottom;
405
417
  mimHeightColumn = column;
418
+ index = i;
406
419
  }
407
420
 
408
421
  }
409
422
 
423
+ if (minHeight === 0 && index > -1) {
424
+ if (startPoints.length > index) {
425
+ // 设置一下起始点的初始化
426
+ mimHeightColumn.bottom = startPoints[index];
427
+ }
428
+ }
429
+
410
430
  return mimHeightColumn;
411
431
  }
412
432
 
@@ -475,6 +495,7 @@ Waterfall.prototype.createCards = function ({ end, dataId = -1 }, callback) {
475
495
  'transform': `translate(${row.left}px,${row.top}px)`,
476
496
  }).attr('data-index', nextDataId);
477
497
  this.updateRenderUI($card, data, nextDataId);
498
+
478
499
  } else {
479
500
  $card = this.appendCard(data, nextDataId, position);
480
501
  }
@@ -499,35 +520,35 @@ Waterfall.prototype.createCards = function ({ end, dataId = -1 }, callback) {
499
520
 
500
521
  this.renderedDataIds.add(nextDataId);
501
522
 
502
- setTimeout(() => {
503
- window.requestAnimationFrame(() => {
504
- // 更新列的底部距离
505
- column.bottom = top + $card.height();
506
- console.log('column.bottom', column.bottom, $card.height());
507
- column.children.push(row);
508
- row.bottom = column.bottom;
523
+ // setTimeout(() => {
524
+ //window.requestAnimationFrame(() => {
509
525
 
510
- // 检查是否需要继续创建卡片
511
- const minHeight = this.getMinHeight();
512
- const hasMoreData = this.renderedDataIds.size < this.dataIdMap.size;
526
+ column.bottom = top + $card.height();
513
527
 
514
- if (hasMoreData && (minHeight < end)) {
528
+ column.children.push(row);
529
+ row.bottom = column.bottom;
515
530
 
516
- this.createCards({ end }, () => {
517
- resolve();
518
- if (callback) {
519
- callback();
520
- }
521
- });
522
- } else {
523
- this.setScrollHeight();
524
- resolve();
525
- if (callback) {
526
- callback();
527
- }
531
+ // 检查是否需要继续创建卡片
532
+ const minHeight = this.getMinHeight();
533
+ const hasMoreData = this.renderedDataIds.size < this.dataIdMap.size;
534
+
535
+ if (hasMoreData && (minHeight < end)) {
536
+
537
+ this.createCards({ end }, () => {
538
+ resolve();
539
+ if (callback) {
540
+ callback();
528
541
  }
529
542
  });
530
- }, 42);
543
+ } else {
544
+ this.setScrollHeight();
545
+ resolve();
546
+ if (callback) {
547
+ callback();
548
+ }
549
+ }
550
+ //});
551
+ // }, 42);
531
552
  });
532
553
 
533
554
  }
@@ -736,7 +757,12 @@ Waterfall.prototype.showLoading = function (callback = null) {
736
757
  if (this.$loadingNode) {
737
758
  let loadingTop = this.getMaxHeight() + options.rowGap
738
759
  this.$loadingNode.css('transform', `translate(0px,${loadingTop}px)`);
739
- $node = this.$loadingNode
760
+ $node = this.$loadingNode;
761
+ window.requestAnimationFrame(() => {
762
+ setTimeout(() => {
763
+ this.$scrollDom.scrollTop(loadingTop + this.$loadingNode.height());
764
+ });
765
+ });
740
766
  }
741
767
 
742
768
  if (callback) callback($node)
@@ -816,4 +842,5 @@ function getNodePoolPop(nodePool, actives) {
816
842
  }
817
843
  }
818
844
  return null;
819
- }
845
+ }
846
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tencent.jquery.pix.component",
3
- "version": "1.0.66-beta1",
3
+ "version": "1.0.66-beta3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "files": [