移除button, 使用回调事件
This commit is contained in:
parent
988fb70838
commit
8ef682e440
9
emoji.js
9
emoji.js
@ -1,5 +1,5 @@
|
||||
export default class Emoji {
|
||||
constructor({ input, button, callback }) {
|
||||
constructor({ input, callback, onSubmit, onShow, onHide }) {
|
||||
let emoji = '😀 😃 😄 😁 😆 😅 😂 🤣 🥲 ☺️ 😊 😇 🙂 🙃 😉 😌 😍 🥰 😘 😗 😙 😚 😋 😛 😝 😜 🤪 🤨 🧐 🤓 😎 🥸 🤩 🥳 😏 😒 😞 😔 😟 😕 🙁 ☹️ 😣 😖 😫 😩 🥺 😢 😭 😤 😠 😡 🤬 🤯 😳 🥵 🥶 😱 😨 😰 😥 😓 🤗 🤔 🤭 🤫 🤥 😶 😐 😑 😬 🙄 😯 😦 😧 😮 😲 🥱 😴 🤤 😪 😵 🤐 🥴 🤢 🤮 🤧 😷 🤒 🤕 🤑 🤠 😈 👿 👹 👺 🤡 💩 👻 💀 ☠️ 👽 👾 🤖 🎃 😺 😸 😹 😻 😼 😽 🙀 😿 😾'
|
||||
emoji += ' 👋 🤚 🖐 ✋ 🖖 👌 🤌 🤏 ✌️ 🤞 🤟 🤘 🤙 👈 👉 👆 🖕 👇 ☝️ 👍 👎 ✊ 👊 🤛 🤜 👏 🙌 👐 🤲 🤝 🙏 ✍️ 💅 🤳 💪 🦾 🦵 🦿 🦶 👣 👂 🦻 👃 🫀 🫁 🧠 🦷 🦴 👀 👁 👅 👄 💋 🩸'
|
||||
emoji += ' 👶 👧 🧒 👦 👩 🧑 👨 👩🦱 🧑🦱 👨🦱 👩🦰 🧑🦰 👨🦰 👱♀️ 👱 👱♂️ 👩🦳 🧑🦳 👨🦳 👩🦲 🧑🦲 👨🦲 🧔 👵 🧓 👴 👲 👳♀️ 👳 👳♂️ 🧕 👮♀️ 👮 👮♂️ 👷♀️ 👷 👷♂️ 💂♀️ 💂 💂♂️ 🕵️♀️ 🕵️ 🕵️♂️ 👩⚕️ 🧑⚕️ 👨⚕️ 👩🌾 🧑🌾 👨🌾 👩🍳 🧑🍳 👨🍳 👩🎓 🧑🎓 👨🎓 👩🎤 🧑🎤 👨🎤 👩🏫 🧑🏫 👨🏫 👩🏭 🧑🏭 👨🏭 👩💻 🧑💻 👨💻 👩💼 🧑💼 👨💼 👩🔧 🧑🔧 👨🔧 👩🔬 🧑🔬 👨🔬 👩🎨 🧑🎨 👨🎨 👩🚒 🧑🚒 👨🚒 👩✈️ 🧑✈️ 👨✈️ 👩🚀 🧑🚀 👨🚀 👩⚖️ 🧑⚖️ 👨⚖️ 👰♀️ 👰 👰♂️ 🤵♀️ 🤵 🤵♂️ 👸 🤴 🥷 🦸♀️ 🦸 🦸♂️ 🦹♀️ 🦹 🦹♂️ 🤶 🧑🎄 🎅 🧙♀️ 🧙 🧙♂️ 🧝♀️ 🧝 🧝♂️ 🧛♀️ 🧛 🧛♂️ 🧟♀️ 🧟 🧟♂️ 🧞♀️ 🧞 🧞♂️ 🧜♀️ 🧜 🧜♂️ 🧚♀️ 🧚 🧚♂️ 👼 🤰 🤱 👩🍼 🧑🍼 👨🍼 🙇♀️ 🙇 🙇♂️ 💁♀️ 💁 💁♂️ 🙅♀️ 🙅 🙅♂️ 🙆♀️ 🙆 🙆♂️ 🙋♀️ 🙋 🙋♂️ 🧏♀️ 🧏 🧏♂️ 🤦♀️ 🤦 🤦♂️ 🤷♀️ 🤷 🤷♂️ 🙎♀️ 🙎 🙎♂️ 🙍♀️ 🙍 🙍♂️ 💇♀️ 💇 💇♂️ 💆♀️ 💆 💆♂️ 🧖♀️ 🧖 🧖♂️ 💅 🤳 💃 🕺 👯♀️ 👯 👯♂️ 🕴 👩🦽 🧑🦽 👨🦽 👩🦼 🧑🦼 👨🦼 🚶♀️ 🚶 🚶♂️ 👩🦯 🧑🦯 👨🦯 🧎♀️ 🧎 🧎♂️ 🏃♀️ 🏃 🏃♂️ 🧍♀️ 🧍 🧍♂️ 👭 🧑🤝🧑 👬 👫 👩❤️👩 💑 👨❤️👨 👩❤️👨 👩❤️💋👩 💏 👨❤️💋👨 👩❤️💋👨 👪 👨👩👦 👨👩👧 👨👩👧👦 👨👩👦👦 👨👩👧👧 👨👨👦 👨👨👧 👨👨👧👦 👨👨👦👦 👨👨👧👧 👩👩👦 👩👩👧 👩👩👧👦 👩👩👦👦 👩👩👧👧 👨👦 👨👦👦 👨👧 👨👧👦 👨👧👧 👩👦 👩👦👦 👩👧 👩👧👦 👩👧👧 🗣 👤 👥 🫂'
|
||||
@ -15,12 +15,8 @@ export default class Emoji {
|
||||
this.list = emoji.split(/\s+/)
|
||||
this.callback = callback
|
||||
this.element = null
|
||||
this.button = button
|
||||
this.input = input
|
||||
|
||||
// 绑定按钮事件
|
||||
if (button) this.button.onclick = () => this.show()
|
||||
|
||||
// 窗口被创建时的回调函数
|
||||
// 窗口被关闭时的回调函数
|
||||
// 选中表情时的回调函数
|
||||
@ -45,7 +41,7 @@ export default class Emoji {
|
||||
// 表情窗口
|
||||
this.div = document.createElement("div")
|
||||
this.div.style = "color:#555; position: relative; left: 0; bottom:-90%; display:flex; flex-direction:column; padding:32px 15px 20px; text-align:center; background:#ffffff; height:90%; width:100%; max-width:640px; margin:0 auto; border-radius:20px 20px 0 0; transition: all .75s cubic-bezier(.645, .045, 0, 1);"
|
||||
this.div.innerHTML = "<h3 style='font-size:20px;'>(。・`ω´・) Emoji</h3>" // <p style='margin-top:0;'>welcome to text world :)</p>
|
||||
this.div.innerHTML = "<h3 style='font-size:20px;'>(。・`ω´・) Emoji</h3>"
|
||||
this.div.onclick = (e) => { e.stopPropagation() }
|
||||
this.element.appendChild(this.div)
|
||||
|
||||
@ -134,7 +130,6 @@ export default class Emoji {
|
||||
hide() {
|
||||
this.ul.classList.remove('ok')
|
||||
setTimeout(() => {
|
||||
//this.element.style.display = "none"
|
||||
this.element.parentNode.removeChild(this.element)
|
||||
this.element = null
|
||||
}, 450)
|
||||
|
7
main.js
7
main.js
@ -21,14 +21,13 @@ document.querySelector('#app').innerHTML = `
|
||||
|
||||
const emoji = new Emoji({
|
||||
input: document.querySelector('#textaret'),
|
||||
button: document.querySelector('#counter'),
|
||||
callback: (data) => {
|
||||
console.log(data)
|
||||
}
|
||||
})
|
||||
|
||||
//document.querySelector('#counter').addEventListener('click', () => {
|
||||
// emoji.show()
|
||||
//})
|
||||
document.querySelector('#counter').addEventListener('click', () => {
|
||||
emoji.show()
|
||||
})
|
||||
|
||||
//emoji.show()
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "satori-emoji",
|
||||
"version": "1.0.4",
|
||||
"version": "2.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
Loading…
Reference in New Issue
Block a user