Telegram Web K with changes to work inside I2P
https://web.telegram.i2p/
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.
42 lines
1.1 KiB
42 lines
1.1 KiB
/* |
|
* https://github.com/morethanwords/tweb |
|
* Copyright (C) 2019-2021 Eduard Kuzmenko |
|
* https://github.com/morethanwords/tweb/blob/master/LICENSE |
|
*/ |
|
|
|
import rootScope from "../lib/rootScope"; |
|
|
|
const SetTransition = (element: HTMLElement, className: string, forwards: boolean, duration: number, onTransitionEnd?: () => void) => { |
|
const timeout = element.dataset.timeout; |
|
if(timeout !== undefined) { |
|
clearTimeout(+timeout); |
|
} |
|
|
|
if(forwards && className) { |
|
element.classList.add(className); |
|
} |
|
|
|
const afterTimeout = () => { |
|
delete element.dataset.timeout; |
|
if(!forwards && className) { |
|
element.classList.remove('backwards', className); |
|
} |
|
|
|
element.classList.remove('animating'); |
|
|
|
onTransitionEnd && onTransitionEnd(); |
|
}; |
|
|
|
if(!rootScope.settings.animationsEnabled) { |
|
element.classList.remove('animating', 'backwards'); |
|
afterTimeout(); |
|
return; |
|
} |
|
|
|
element.classList.add('animating'); |
|
|
|
element.classList.toggle('backwards', !forwards); |
|
element.dataset.timeout = '' + setTimeout(afterTimeout, duration); |
|
}; |
|
|
|
export default SetTransition;
|
|
|