Browse Source
Fix dead streaming & downloading through SW Possible fix for stuck sticker viewermaster
25 changed files with 266 additions and 175 deletions
@ -1,54 +0,0 @@ |
|||||||
/* |
|
||||||
* https://github.com/morethanwords/tweb
|
|
||||||
* Copyright (C) 2019-2021 Eduard Kuzmenko |
|
||||||
* https://github.com/morethanwords/tweb/blob/master/LICENSE
|
|
||||||
*/ |
|
||||||
|
|
||||||
import sequentialDom from '../sequentialDom'; |
|
||||||
import renderImageFromUrl from './renderImageFromUrl'; |
|
||||||
|
|
||||||
export default function renderImageWithFadeIn( |
|
||||||
container: HTMLElement, |
|
||||||
image: HTMLImageElement, |
|
||||||
url: string, |
|
||||||
needFadeIn: boolean, |
|
||||||
aspecter = container, |
|
||||||
thumbImage?: HTMLElement |
|
||||||
) { |
|
||||||
if(needFadeIn) { |
|
||||||
image.classList.add('fade-in'); |
|
||||||
} |
|
||||||
|
|
||||||
const promise = new Promise<void>((resolve) => { |
|
||||||
/* if(photo._ === 'document') { |
|
||||||
console.error('wrapPhoto: will render document', photo, size, cacheContext); |
|
||||||
return resolve(); |
|
||||||
} */ |
|
||||||
|
|
||||||
renderImageFromUrl(image, url, () => { |
|
||||||
sequentialDom.mutateElement(container, () => { |
|
||||||
aspecter.append(image); |
|
||||||
|
|
||||||
resolve(); |
|
||||||
/* fastRaf(() => { |
|
||||||
resolve(); |
|
||||||
}); */ |
|
||||||
|
|
||||||
if(needFadeIn) { |
|
||||||
image.addEventListener('animationend', () => { |
|
||||||
sequentialDom.mutate(() => { |
|
||||||
image.classList.remove('fade-in'); |
|
||||||
thumbImage?.remove(); |
|
||||||
}); |
|
||||||
}, {once: true}); |
|
||||||
} else { |
|
||||||
thumbImage?.remove(); |
|
||||||
} |
|
||||||
}); |
|
||||||
}); |
|
||||||
}); |
|
||||||
|
|
||||||
// recordPromise(promise, 'renderImageWithFadeIn');
|
|
||||||
|
|
||||||
return promise; |
|
||||||
} |
|
@ -0,0 +1,42 @@ |
|||||||
|
/* |
||||||
|
* https://github.com/morethanwords/tweb
|
||||||
|
* Copyright (C) 2019-2021 Eduard Kuzmenko |
||||||
|
* https://github.com/morethanwords/tweb/blob/master/LICENSE
|
||||||
|
*/ |
||||||
|
|
||||||
|
import sequentialDom from '../sequentialDom'; |
||||||
|
import {renderImageFromUrlPromise} from './renderImageFromUrl'; |
||||||
|
|
||||||
|
export default function renderMediaWithFadeIn( |
||||||
|
container: HTMLElement, |
||||||
|
media: Parameters<typeof renderImageFromUrlPromise>[0], |
||||||
|
url: string, |
||||||
|
needFadeIn: boolean, |
||||||
|
aspecter = container, |
||||||
|
thumbImage?: HTMLElement |
||||||
|
) { |
||||||
|
if(needFadeIn) { |
||||||
|
media.classList.add('fade-in'); |
||||||
|
} |
||||||
|
|
||||||
|
const promise = renderImageFromUrlPromise(media, url).then(() => { |
||||||
|
return sequentialDom.mutateElement(container, () => { |
||||||
|
aspecter.append(media); |
||||||
|
|
||||||
|
if(needFadeIn) { |
||||||
|
media.addEventListener('animationend', () => { |
||||||
|
sequentialDom.mutate(() => { |
||||||
|
media.classList.remove('fade-in'); |
||||||
|
thumbImage?.remove(); |
||||||
|
}); |
||||||
|
}, {once: true}); |
||||||
|
} else { |
||||||
|
thumbImage?.remove(); |
||||||
|
} |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
// recordPromise(promise, 'renderImageWithFadeIn');
|
||||||
|
|
||||||
|
return promise; |
||||||
|
} |
Loading…
Reference in new issue