diff --git a/src/auro-backtotop.js b/src/auro-backtotop.js index 1b88211..b6573c0 100644 --- a/src/auro-backtotop.js +++ b/src/auro-backtotop.js @@ -139,6 +139,10 @@ export class AuroBackToTop extends LitElement { this.addEventListener('focusout', () => { this.interactionActive = false; }); + + this.addEventListener('touchend', () => { + this.onTriggerClick(); + }); } // function that renders the HTML and CSS into the scope of the component diff --git a/test/auro-backtotop.test.js b/test/auro-backtotop.test.js index 87f0bc2..04f416e 100644 --- a/test/auro-backtotop.test.js +++ b/test/auro-backtotop.test.js @@ -11,7 +11,7 @@ describe('auro-backtotop', () => { }); it('auro-backtotop custom element is defined', async () => { - const el = await !!customElements.get("auro-backtotop"); + const el = await Boolean(customElements.get("auro-backtotop")); await expect(el).to.be.true; }); @@ -62,6 +62,14 @@ describe('auro-backtotop', () => { expect(el.interactionActive).to.be.false; }); + it('auro-backtotop event triggering event click', async () => { + const el = await fixture(html` + + `); + el.shadowRoot.querySelector('auro-button').click() + el.shadowRoot.querySelector('auro-button').dispatchEvent(new Event('mouseover')); + }); + function simulateScroll(x, y) { const scrollEvent = new CustomEvent('scroll', { detail: { x, y } }); window.scrollX = x;