抖音c端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 regels
1.8 KiB

  1. Component({
  2. externalClasses: ['i-class'],
  3. properties : {
  4. scrollTop : {
  5. type : Number,
  6. observer(val){
  7. this._updateScrollTopChange();
  8. }
  9. }
  10. },
  11. relations : {
  12. '../sticky-item/index' : {
  13. type : 'child',
  14. linked(){
  15. this._updateDataChange();
  16. },
  17. linkChanged () {
  18. this._updateDataChange();
  19. },
  20. unlinked () {
  21. this._updateDataChange();
  22. }
  23. }
  24. },
  25. data : {
  26. timer : null,
  27. itemLength : 0,
  28. },
  29. methods : {
  30. _updateScrollTopChange(){
  31. const stickies = this.getRelationNodes('../sticky-item/index');
  32. console.log(stickies,"stickies");
  33. if(stickies && stickies.length > 0 ){
  34. stickies.forEach((item) => {
  35. if( item ){
  36. item.updateScrollTopChange( this.data.scrollTop );
  37. }
  38. })
  39. }
  40. },
  41. _updateDataChange( ){
  42. const stickies = this.getRelationNodes('../sticky-item/index');
  43. if(stickies && stickies.length > 0 ){
  44. if( this.data.timer ){
  45. clearTimeout( this.data.timer )
  46. this.setData({
  47. timer : null
  48. })
  49. }
  50. this.data.timer = setTimeout(()=>{
  51. stickies.forEach((item,index) => {
  52. if( item ){
  53. item.updateDataChange(index);
  54. }
  55. })
  56. },0)
  57. this.setData({
  58. timer : this.data.timer
  59. })
  60. }
  61. }
  62. }
  63. })