mirror of
				https://github.com/unanmed/HumanBreak.git
				synced 2025-11-04 07:02:58 +08:00 
			
		
		
		
	fix: 优化滚动组件的性能
This commit is contained in:
		
							parent
							
								
									e9b9e4b069
								
							
						
					
					
						commit
						8cd675a332
					
				@ -92,22 +92,30 @@ async function calHeight(first: boolean = false) {
 | 
				
			|||||||
    if (!first) {
 | 
					    if (!first) {
 | 
				
			||||||
        await sleep(20);
 | 
					        await sleep(20);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const canvas = ctx.canvas;
 | 
					    const canvas = ctx.canvas;
 | 
				
			||||||
    const style2 = getComputedStyle(canvas);
 | 
					    const style2 = getComputedStyle(canvas);
 | 
				
			||||||
 | 
					    if (!props.type || props.type === 'vertical') {
 | 
				
			||||||
 | 
					        if (props.noScroll) {
 | 
				
			||||||
 | 
					            canvas.style.width = `0px`;
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
            canvas.style.width = `${width}px`;
 | 
					            canvas.style.width = `${width}px`;
 | 
				
			||||||
            canvas.width = width * scale;
 | 
					            canvas.width = width * scale;
 | 
				
			||||||
            canvas.height = parseFloat(style2.height) * scale;
 | 
					            canvas.height = parseFloat(style2.height) * scale;
 | 
				
			||||||
    if (props.noScroll) canvas.style.width = `0px`;
 | 
					        }
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
    if (props.type === 'horizontal') {
 | 
					 | 
				
			||||||
        main.style.flexDirection = 'column';
 | 
					        main.style.flexDirection = 'column';
 | 
				
			||||||
 | 
					        if (props.noScroll) {
 | 
				
			||||||
 | 
					            canvas.style.height = `0px`;
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
            canvas.style.height = `${width}px`;
 | 
					            canvas.style.height = `${width}px`;
 | 
				
			||||||
            canvas.style.width = '98%';
 | 
					            canvas.style.width = '98%';
 | 
				
			||||||
            canvas.style.margin = '0 1% 0 1%';
 | 
					            canvas.style.margin = '0 1% 0 1%';
 | 
				
			||||||
            canvas.width = parseFloat(style2.width) * scale;
 | 
					            canvas.width = parseFloat(style2.width) * scale;
 | 
				
			||||||
            canvas.height = width * scale;
 | 
					            canvas.height = width * scale;
 | 
				
			||||||
        if (props.noScroll) canvas.style.height = `0px`;
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    await new Promise<void>(res => {
 | 
					    await new Promise<void>(res => {
 | 
				
			||||||
        requestAnimationFrame(() => {
 | 
					        requestAnimationFrame(() => {
 | 
				
			||||||
            total =
 | 
					            total =
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user