使用异步方法和加入回调函数
This commit is contained in:
parent
8ef682e440
commit
989792c95f
28
emoji.js
28
emoji.js
@ -1,5 +1,6 @@
|
||||
export default class Emoji {
|
||||
constructor({ input, callback, onSubmit, onShow, onHide }) {
|
||||
this.event = { onShow, onHide, onSubmit }
|
||||
let emoji = '😀 😃 😄 😁 😆 😅 😂 🤣 🥲 ☺️ 😊 😇 🙂 🙃 😉 😌 😍 🥰 😘 😗 😙 😚 😋 😛 😝 😜 🤪 🤨 🧐 🤓 😎 🥸 🤩 🥳 😏 😒 😞 😔 😟 😕 🙁 ☹️ 😣 😖 😫 😩 🥺 😢 😭 😤 😠 😡 🤬 🤯 😳 🥵 🥶 😱 😨 😰 😥 😓 🤗 🤔 🤭 🤫 🤥 😶 😐 😑 😬 🙄 😯 😦 😧 😮 😲 🥱 😴 🤤 😪 😵 🤐 🥴 🤢 🤮 🤧 😷 🤒 🤕 🤑 🤠 😈 👿 👹 👺 🤡 💩 👻 💀 ☠️ 👽 👾 🤖 🎃 😺 😸 😹 😻 😼 😽 🙀 😿 😾'
|
||||
emoji += ' 👋 🤚 🖐 ✋ 🖖 👌 🤌 🤏 ✌️ 🤞 🤟 🤘 🤙 👈 👉 👆 🖕 👇 ☝️ 👍 👎 ✊ 👊 🤛 🤜 👏 🙌 👐 🤲 🤝 🙏 ✍️ 💅 🤳 💪 🦾 🦵 🦿 🦶 👣 👂 🦻 👃 🫀 🫁 🧠 🦷 🦴 👀 👁 👅 👄 💋 🩸'
|
||||
emoji += ' 👶 👧 🧒 👦 👩 🧑 👨 👩🦱 🧑🦱 👨🦱 👩🦰 🧑🦰 👨🦰 👱♀️ 👱 👱♂️ 👩🦳 🧑🦳 👨🦳 👩🦲 🧑🦲 👨🦲 🧔 👵 🧓 👴 👲 👳♀️ 👳 👳♂️ 🧕 👮♀️ 👮 👮♂️ 👷♀️ 👷 👷♂️ 💂♀️ 💂 💂♂️ 🕵️♀️ 🕵️ 🕵️♂️ 👩⚕️ 🧑⚕️ 👨⚕️ 👩🌾 🧑🌾 👨🌾 👩🍳 🧑🍳 👨🍳 👩🎓 🧑🎓 👨🎓 👩🎤 🧑🎤 👨🎤 👩🏫 🧑🏫 👨🏫 👩🏭 🧑🏭 👨🏭 👩💻 🧑💻 👨💻 👩💼 🧑💼 👨💼 👩🔧 🧑🔧 👨🔧 👩🔬 🧑🔬 👨🔬 👩🎨 🧑🎨 👨🎨 👩🚒 🧑🚒 👨🚒 👩✈️ 🧑✈️ 👨✈️ 👩🚀 🧑🚀 👨🚀 👩⚖️ 🧑⚖️ 👨⚖️ 👰♀️ 👰 👰♂️ 🤵♀️ 🤵 🤵♂️ 👸 🤴 🥷 🦸♀️ 🦸 🦸♂️ 🦹♀️ 🦹 🦹♂️ 🤶 🧑🎄 🎅 🧙♀️ 🧙 🧙♂️ 🧝♀️ 🧝 🧝♂️ 🧛♀️ 🧛 🧛♂️ 🧟♀️ 🧟 🧟♂️ 🧞♀️ 🧞 🧞♂️ 🧜♀️ 🧜 🧜♂️ 🧚♀️ 🧚 🧚♂️ 👼 🤰 🤱 👩🍼 🧑🍼 👨🍼 🙇♀️ 🙇 🙇♂️ 💁♀️ 💁 💁♂️ 🙅♀️ 🙅 🙅♂️ 🙆♀️ 🙆 🙆♂️ 🙋♀️ 🙋 🙋♂️ 🧏♀️ 🧏 🧏♂️ 🤦♀️ 🤦 🤦♂️ 🤷♀️ 🤷 🤷♂️ 🙎♀️ 🙎 🙎♂️ 🙍♀️ 🙍 🙍♂️ 💇♀️ 💇 💇♂️ 💆♀️ 💆 💆♂️ 🧖♀️ 🧖 🧖♂️ 💅 🤳 💃 🕺 👯♀️ 👯 👯♂️ 🕴 👩🦽 🧑🦽 👨🦽 👩🦼 🧑🦼 👨🦼 🚶♀️ 🚶 🚶♂️ 👩🦯 🧑🦯 👨🦯 🧎♀️ 🧎 🧎♂️ 🏃♀️ 🏃 🏃♂️ 🧍♀️ 🧍 🧍♂️ 👭 🧑🤝🧑 👬 👫 👩❤️👩 💑 👨❤️👨 👩❤️👨 👩❤️💋👩 💏 👨❤️💋👨 👩❤️💋👨 👪 👨👩👦 👨👩👧 👨👩👧👦 👨👩👦👦 👨👩👧👧 👨👨👦 👨👨👧 👨👨👧👦 👨👨👦👦 👨👨👧👧 👩👩👦 👩👩👧 👩👩👧👦 👩👩👦👦 👩👩👧👧 👨👦 👨👦👦 👨👧 👨👧👦 👨👧👧 👩👦 👩👦👦 👩👧 👩👧👦 👩👧👧 🗣 👤 👥 🫂'
|
||||
@ -16,15 +17,6 @@ export default class Emoji {
|
||||
this.callback = callback
|
||||
this.element = null
|
||||
this.input = input
|
||||
|
||||
// 窗口被创建时的回调函数
|
||||
// 窗口被关闭时的回调函数
|
||||
// 选中表情时的回调函数
|
||||
// 只在使用组件时才创建组件
|
||||
// 挂载开关按钮
|
||||
// 挂载输入框(挂载输入框可以精确到光标位置)
|
||||
// 动画时移除动画以外的交互规则以提高性能
|
||||
// 加载时渐显过渡 离开时渐隐过渡
|
||||
}
|
||||
|
||||
create_window() {
|
||||
@ -114,27 +106,27 @@ export default class Emoji {
|
||||
}
|
||||
|
||||
// 显示组件(方法)
|
||||
show() {
|
||||
async show() {
|
||||
this.create_window()
|
||||
this.element.style.display = "flex"
|
||||
this.div.offsetWidth
|
||||
this.element.style.background = "rgba(0,0,0,.6)"
|
||||
this.element.focus()
|
||||
this.div.style.bottom = "0px"
|
||||
setTimeout(() => {
|
||||
this.ul.classList.add('ok')
|
||||
}, 800)
|
||||
await new Promise(resolve => setTimeout(resolve, 800))
|
||||
this.ul.calssList.add('ok')
|
||||
this.event.onShow()
|
||||
}
|
||||
|
||||
// 隐藏组件(方法) (是否将聚焦返回给 input 的原本位置?)
|
||||
hide() {
|
||||
async hide() {
|
||||
this.ul.classList.remove('ok')
|
||||
setTimeout(() => {
|
||||
this.element.parentNode.removeChild(this.element)
|
||||
this.element = null
|
||||
}, 450)
|
||||
this.element.style.background = "rgba(0,0,0,0)"
|
||||
this.div.style.bottom = "-90%"
|
||||
await new Promise(resolve => setTimeout(resolve, 450))
|
||||
this.element.parentNode.removeChild(this.element)
|
||||
this.element = null
|
||||
this.event.onHide()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user