kopia lustrzana https://github.com/nolanlawson/pinafore
				
				
				
			fix: fix fade animations on slow devices (#1751)
I noticed that, on 6x CPU throttling in Chrome, the status fade-in animations were not consistent when switching columns. This fixes that using rAF.fix-firefox-for-android
							rodzic
							
								
									5f6c5d89d1
								
							
						
					
					
						commit
						0ce47f0379
					
				| 
						 | 
					@ -29,6 +29,8 @@
 | 
				
			||||||
  import { registerResizeListener, unregisterResizeListener } from '../../_utils/resize'
 | 
					  import { registerResizeListener, unregisterResizeListener } from '../../_utils/resize'
 | 
				
			||||||
  import { mark, stop } from '../../_utils/marks'
 | 
					  import { mark, stop } from '../../_utils/marks'
 | 
				
			||||||
  import { requestPostAnimationFrame } from '../../_utils/requestPostAnimationFrame'
 | 
					  import { requestPostAnimationFrame } from '../../_utils/requestPostAnimationFrame'
 | 
				
			||||||
 | 
					  import { observe } from 'svelte-extras'
 | 
				
			||||||
 | 
					  import { doubleRAF } from '../../_utils/doubleRAF'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  export default {
 | 
					  export default {
 | 
				
			||||||
    oncreate () {
 | 
					    oncreate () {
 | 
				
			||||||
| 
						 | 
					@ -46,15 +48,26 @@
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
      this.doRecalculateHeight = this.doRecalculateHeight.bind(this)
 | 
					      this.doRecalculateHeight = this.doRecalculateHeight.bind(this)
 | 
				
			||||||
      registerResizeListener(this.doRecalculateHeight)
 | 
					      registerResizeListener(this.doRecalculateHeight)
 | 
				
			||||||
 | 
					      // this rAF delay is necessary in order to get the fade-in animation
 | 
				
			||||||
 | 
					      // to consistently show
 | 
				
			||||||
 | 
					      this.observe('shownBeforeRaf', shownBeforeRaf => {
 | 
				
			||||||
 | 
					        doubleRAF(() => {
 | 
				
			||||||
 | 
					          this.set({ shown: shownBeforeRaf })
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    ondestroy () {
 | 
					    ondestroy () {
 | 
				
			||||||
      unregisterResizeListener(this.doRecalculateHeight)
 | 
					      unregisterResizeListener(this.doRecalculateHeight)
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    store: () => virtualListStore,
 | 
					    store: () => virtualListStore,
 | 
				
			||||||
 | 
					    data: () => ({
 | 
				
			||||||
 | 
					      shown: false
 | 
				
			||||||
 | 
					    }),
 | 
				
			||||||
    computed: {
 | 
					    computed: {
 | 
				
			||||||
      shown: ({ $itemHeights, key }) => $itemHeights[key] > 0
 | 
					      shownBeforeRaf: ({ $itemHeights, key }) => $itemHeights[key] > 0
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    methods: {
 | 
					    methods: {
 | 
				
			||||||
 | 
					      observe,
 | 
				
			||||||
      doRecalculateHeight () {
 | 
					      doRecalculateHeight () {
 | 
				
			||||||
        // Recalculate immediately because this is done on-demand, e.g.
 | 
					        // Recalculate immediately because this is done on-demand, e.g.
 | 
				
			||||||
        // when clicking the "More" button on a spoiler.
 | 
					        // when clicking the "More" button on a spoiler.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Ładowanie…
	
		Reference in New Issue