tencent.jquery.pix.component 1.0.66-beta2 → 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)
@@ -177,7 +187,6 @@ Waterfall.prototype.init = function () {
177
187
  // force 强制更新渲染
178
188
  Waterfall.prototype.updateVisibleItems = function (force = false) {
179
189
  const self = this;
180
-
181
190
  const options = this.options;
182
191
  let h = 0;
183
192
  if (options.scrollDom) {
@@ -188,9 +197,8 @@ Waterfall.prototype.updateVisibleItems = function (force = false) {
188
197
 
189
198
  const startTop = self.scrollTop; // 当前滚动位置
190
199
  const endTop = startTop + h;
191
-
192
200
  // console.log('startTop', startTop)
193
- console.log('endTop', endTop)
201
+ // console.log('endTop', endTop)
194
202
 
195
203
  // 进行可见区域的渲染更新
196
204
  this.updateCardsInView({
@@ -395,28 +403,36 @@ Waterfall.prototype.getMinHeight = function () {
395
403
  Waterfall.prototype.getMinHeightColumn = function () {
396
404
  let minHeight = -1;
397
405
  let mimHeightColumn = null;
406
+ let index = -1;
407
+ const startPoints = this.options.startPoints || [];
398
408
  for (let i = 0; i < this.columns; i++) {
399
409
  const column = this.columnItems[i]
400
-
401
- // 获取每组元素列表的最后一个bottom值
402
- if (minHeight > column.bottom) {
410
+ if (minHeight === -1) {
403
411
  minHeight = column.bottom;
404
412
  mimHeightColumn = column;
405
- } else if (minHeight === -1) {
413
+ index = i;
414
+ } else if (minHeight > column.bottom) {
415
+ // 获取每组元素列表的最后一个bottom值
406
416
  minHeight = column.bottom;
407
417
  mimHeightColumn = column;
418
+ index = i;
408
419
  }
409
420
 
410
421
  }
411
422
 
423
+ if (minHeight === 0 && index > -1) {
424
+ if (startPoints.length > index) {
425
+ // 设置一下起始点的初始化
426
+ mimHeightColumn.bottom = startPoints[index];
427
+ }
428
+ }
429
+
412
430
  return mimHeightColumn;
413
431
  }
414
432
 
415
433
  // 创建卡片
416
-
417
434
  Waterfall.prototype.createCards = function ({ end, dataId = -1 }, callback) {
418
435
  const self = this;
419
-
420
436
  const options = this.options;
421
437
 
422
438
  return new Promise((resolve) => {
@@ -479,6 +495,7 @@ Waterfall.prototype.createCards = function ({ end, dataId = -1 }, callback) {
479
495
  'transform': `translate(${row.left}px,${row.top}px)`,
480
496
  }).attr('data-index', nextDataId);
481
497
  this.updateRenderUI($card, data, nextDataId);
498
+
482
499
  } else {
483
500
  $card = this.appendCard(data, nextDataId, position);
484
501
  }
@@ -503,35 +520,35 @@ Waterfall.prototype.createCards = function ({ end, dataId = -1 }, callback) {
503
520
 
504
521
  this.renderedDataIds.add(nextDataId);
505
522
 
506
- setTimeout(() => {
507
- window.requestAnimationFrame(() => {
508
- // 更新列的底部距离
509
- column.bottom = top + $card.height();
510
- console.log('column.bottom', column.bottom, $card.height());
511
- column.children.push(row);
512
- row.bottom = column.bottom;
523
+ // setTimeout(() => {
524
+ //window.requestAnimationFrame(() => {
513
525
 
514
- // 检查是否需要继续创建卡片
515
- const minHeight = this.getMinHeight();
516
- const hasMoreData = this.renderedDataIds.size < this.dataIdMap.size;
526
+ column.bottom = top + $card.height();
517
527
 
518
- if (hasMoreData && (minHeight < end)) {
528
+ column.children.push(row);
529
+ row.bottom = column.bottom;
519
530
 
520
- this.createCards({ end }, () => {
521
- resolve();
522
- if (callback) {
523
- callback();
524
- }
525
- });
526
- } else {
527
- this.setScrollHeight();
528
- resolve();
529
- if (callback) {
530
- callback();
531
- }
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();
532
541
  }
533
542
  });
534
- }, 42);
543
+ } else {
544
+ this.setScrollHeight();
545
+ resolve();
546
+ if (callback) {
547
+ callback();
548
+ }
549
+ }
550
+ //});
551
+ // }, 42);
535
552
  });
536
553
 
537
554
  }
@@ -825,4 +842,5 @@ function getNodePoolPop(nodePool, actives) {
825
842
  }
826
843
  }
827
844
  return null;
828
- }
845
+ }
846
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tencent.jquery.pix.component",
3
- "version": "1.0.66-beta2",
3
+ "version": "1.0.66-beta3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "files": [