Telegram Group & Telegram Channel
TransitionEvent

Animatsiya bilan bir qatorda transition'lar haqida ham gaplashsak.

Buni qarangki, CSS orqali boshqariladigan transition'larni JS bilan kuzatish imkoni ham bor ekan.
Buni ham yaqinda bilib qoldim. 🤯

Masalan, ":hover" qilganda kengayadigan elementni olaylik:


#box {
width: 50px;
transition: 2s;
transition-dalay: .5s;

&:hover {
width: 100px;
}
}


Aytaylik, keygayib kichrayyotgan paytda, element ichidagi tugmacha yoki linklar "disabled" bo'lishi kerak (JS bilan). Buni qanday qilardingiz?

Misol uchun men "mouseenter", "mouseleave" event'laridan foydalanib, "setTimeout" orqali transition tugashini kuzatardim. Bunda albatta "timeout" vaqti "transition-duration" + "delay" ga teng bo'ladi.
Tepadagi misolga ko'ra 2 + 0.5 = 2.5 sekund.

Bu usul ishlaydi. Lekin ikkovi bir-biriga bog'liq bo'magan parallel operatsiyalar hisoblanadi. Chunki sinxronizatsiyani "qo'lda" qilyapmiz.

TransitionEvent bilan esa buni qilish ancha sodda:


const box = document.getElementById('#box');

box.addEventListener('transitionstart', () => button.disabled = true)
box.addEventListener('transitionend', () => button.disabled = false)


TransitionEvent o'zi 4 ta event'dan iborat:

1. transitionrun - transition'ni boshlovchi even sodir bo'lganda (hover, focus, click, v.h.k.) va "delay" taymeri boshalanganda.

2. transitionstart - aynan transition boshlangada, ya'ni o'zgarish boshlanganda; "delay" taymeri tugagadan keyin.

3. transitionend - transition tugaganda, ya'ni element o'zgarishi tugagach.

4. transitioncancel - transition paytida uni bekor qiladigan event sodir bo'lganda, ya'ni `transitionrun`'dan keyin, `transitionend`'dan oldin.
👍17



tg-me.com/brogrammist/186
Create:
Last Update:

TransitionEvent

Animatsiya bilan bir qatorda transition'lar haqida ham gaplashsak.

Buni qarangki, CSS orqali boshqariladigan transition'larni JS bilan kuzatish imkoni ham bor ekan.
Buni ham yaqinda bilib qoldim. 🤯

Masalan, ":hover" qilganda kengayadigan elementni olaylik:


#box {
width: 50px;
transition: 2s;
transition-dalay: .5s;

&:hover {
width: 100px;
}
}


Aytaylik, keygayib kichrayyotgan paytda, element ichidagi tugmacha yoki linklar "disabled" bo'lishi kerak (JS bilan). Buni qanday qilardingiz?

Misol uchun men "mouseenter", "mouseleave" event'laridan foydalanib, "setTimeout" orqali transition tugashini kuzatardim. Bunda albatta "timeout" vaqti "transition-duration" + "delay" ga teng bo'ladi.
Tepadagi misolga ko'ra 2 + 0.5 = 2.5 sekund.

Bu usul ishlaydi. Lekin ikkovi bir-biriga bog'liq bo'magan parallel operatsiyalar hisoblanadi. Chunki sinxronizatsiyani "qo'lda" qilyapmiz.

TransitionEvent bilan esa buni qilish ancha sodda:


const box = document.getElementById('#box');

box.addEventListener('transitionstart', () => button.disabled = true)
box.addEventListener('transitionend', () => button.disabled = false)


TransitionEvent o'zi 4 ta event'dan iborat:

1. transitionrun - transition'ni boshlovchi even sodir bo'lganda (hover, focus, click, v.h.k.) va "delay" taymeri boshalanganda.

2. transitionstart - aynan transition boshlangada, ya'ni o'zgarish boshlanganda; "delay" taymeri tugagadan keyin.

3. transitionend - transition tugaganda, ya'ni element o'zgarishi tugagach.

4. transitioncancel - transition paytida uni bekor qiladigan event sodir bo'lganda, ya'ni `transitionrun`'dan keyin, `transitionend`'dan oldin.

BY Brogrammist


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/brogrammist/186

View MORE
Open in Telegram


Brogrammist Telegram | DID YOU KNOW?

Date: |

Telegram Gives Up On Crypto Blockchain Project

Durov said on his Telegram channel today that the two and a half year blockchain and crypto project has been put to sleep. Ironically, after leaving Russia because the government wanted his encryption keys to his social media firm, Durov’s cryptocurrency idea lost steam because of a U.S. court. “The technology we created allowed for an open, free, decentralized exchange of value and ideas. TON had the potential to revolutionize how people store and transfer funds and information,” he wrote on his channel. “Unfortunately, a U.S. court stopped TON from happening.”

Telegram auto-delete message, expiring invites, and more

elegram is updating its messaging app with options for auto-deleting messages, expiring invite links, and new unlimited groups, the company shared in a blog post. Much like Signal, Telegram received a burst of new users in the confusion over WhatsApp’s privacy policy and now the company is adopting features that were already part of its competitors’ apps, features which offer more security and privacy. Auto-deleting messages were already possible in Telegram’s encrypted Secret Chats, but this new update for iOS and Android adds the option to make messages disappear in any kind of chat. Auto-delete can be enabled inside of chats, and set to delete either 24 hours or seven days after messages are sent. Auto-delete won’t remove every message though; if a message was sent before the feature was turned on, it’ll stick around. Telegram’s competitors have had similar features: WhatsApp introduced a feature in 2020 and Signal has had disappearing messages since at least 2016.

Brogrammist from cn


Telegram Brogrammist
FROM USA