Merge pull request #108 in YR/star-web-components from add-toaster-click to master
* commit '45c4d740d33d99159bf19639c6e8e417850e416a': 添加横幅通知点击事件
This commit is contained in:
commit
b9d95a1b70
|
@ -34,7 +34,7 @@ export class StarNotificationGroup extends LitElement {
|
|||
let id = (event as any).detail.id
|
||||
;(this.slotElements as StarNotification[]).forEach(
|
||||
(el: StarNotification) => {
|
||||
if (el.noclear != true) {
|
||||
if (!el.noclear) {
|
||||
if (this.getAttribute('show') == 'false') {
|
||||
if (el.id == id) {
|
||||
// 删除某个notification-group
|
||||
|
|
|
@ -248,12 +248,12 @@ export class StarNotification extends LitElement {
|
|||
return nothing
|
||||
}
|
||||
|
||||
if (!this.secondText) {
|
||||
console.error(
|
||||
'【star-notification】【more-notification-first】缺少 secondText 参数'
|
||||
)
|
||||
return nothing
|
||||
}
|
||||
// if (!this.secondText) {
|
||||
// console.error(
|
||||
// '【star-notification】【more-notification-first】缺少 secondText 参数'
|
||||
// )
|
||||
// return nothing
|
||||
// }
|
||||
|
||||
if (!this.radiusType) {
|
||||
console.error(
|
||||
|
@ -319,6 +319,7 @@ export class StarNotification extends LitElement {
|
|||
|
||||
@eventOptions({passive: false})
|
||||
handleEvent(event: TouchEvent) {
|
||||
let self = this
|
||||
if (!this.isToast) {
|
||||
switch (event.type) {
|
||||
case 'touchstart':
|
||||
|
@ -441,7 +442,6 @@ export class StarNotification extends LitElement {
|
|||
break
|
||||
case 'click':
|
||||
event.stopPropagation()
|
||||
let self = this
|
||||
let target = event.target as HTMLElement
|
||||
this.notification.style.transform = ''
|
||||
switch (target.dataset.icon) {
|
||||
|
@ -450,7 +450,7 @@ export class StarNotification extends LitElement {
|
|||
target.addEventListener('transitionend', function tranEnd() {
|
||||
target.removeEventListener('transitionend', tranEnd)
|
||||
target.removeAttribute('clicked')
|
||||
if (self.noclear != true) {
|
||||
if (!self.noclear) {
|
||||
self.dispatchEvent(
|
||||
new CustomEvent('notification-delete', {
|
||||
detail: {
|
||||
|
@ -503,6 +503,29 @@ export class StarNotification extends LitElement {
|
|||
}
|
||||
break
|
||||
}
|
||||
} else {
|
||||
switch (event.type) {
|
||||
case 'click':
|
||||
this.notification.setAttribute('clicked', 'true')
|
||||
this.notification.addEventListener(
|
||||
'transitionend',
|
||||
function tranEnd() {
|
||||
self.notification.removeEventListener('transitionend', tranEnd)
|
||||
self.notification.removeAttribute('clicked')
|
||||
self.dispatchEvent(
|
||||
new CustomEvent('notification-click', {
|
||||
detail: {
|
||||
id: self.id,
|
||||
notification: self,
|
||||
},
|
||||
bubbles: true,
|
||||
composed: true,
|
||||
})
|
||||
)
|
||||
}
|
||||
)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue