Repeat button in Vue Button component

27 Feb 20235 minutes to read

The Repeat button is a type of Button in that the click event is triggered at regular time interval from the pressed state till the released state.

The following example explains about how to achieve Repeat Button in mouse and touch events.

    <div id='container'>
        <div class='btncontainer'>
            <ejs-button id='button' cssClass='e-small'>Button</ejs-button>
        <div class='event' style='height:auto;'>
            <table title='Event Trace' style='width:100%'>
                <th>Event Trace</th>
                    <div class='eventarea' style='height: 250px;overflow: auto'>
                        <span id='eventlog' style='word-break: normal;'></span>
                    <div class='evtbtn' style='padding:20px 0 0 20px'>
                        <ejs-button id='clear' cssClass='e-small'>Clear</ejs-button>

import Vue from 'vue';
import { ButtonPlugin } from '@syncfusion/ej2-vue-buttons';
import { enableRipple, EventHandler } from '@syncfusion/ej2-base';


export default {
  mounted () {
      var timeout;
    document.getElementById('clear').onclick = function () {
    document.getElementById('eventlog').innerHTML = '';

var button = document.getElementById('button');
button.addEventListener('mousedown', mouseDownHandler);
button.addEventListener('touchstart', mouseDownHandler);
button.addEventListener('mouseup', mouseUpHandler);
button.addEventListener('touchend', mouseUpHandler);
button.addEventListener('click', clickEventHandler);

function mouseUpHandler() {

function mouseDownHandler(event) {
    timeout = setInterval(clickEventHandler, 200);
function clickEventHandler() {
    EventHandler.trigger(button, 'click');
    appendSpanElement('Button click event triggered.<hr>');
function appendSpanElement(text) {
    var span = document.createElement('span');
    span.innerHTML = text;
    var log = document.getElementById('eventlog');
    log.insertBefore(span, log.firstChild);

@import '../node_modules/@syncfusion/ej2-base/styles/material.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/material.css';

.btncontainer {
  float: left;
  width: 40%;

.event {
  float: right;
  width: 60%;
  border-left: 1px solid #D7D7D7;

#eventlog b {
  color: #388e3c;

hr {
   margin: 1px 10px 1px 0px;
   border-top: 1px solid #eee;