Anuj-Panthri's picture
added repeat for web vibrate and made it consistent for both web and mobile
6f0e7f2
var vibrateInterval;
function vibrate(flutter_value) {
clearInterval(vibrateInterval);
if ("vibrate" in navigator){
// alert("supported");
navigator.vibrate(flutter_value);
}
}
function sum(arr1){
if(arr1.constructor !== Array) return arr1
function add(accumulator, a) {
return accumulator + a;
}
sumvalue = arr1.reduce(add, 0);
return sumvalue;
}
function setIntervalAndExecute(fn, t) {
fn();
return(setInterval(fn, t));
}
function peristentVibrate(pattern) {
// alert("supported");
// vibrateInterval = setInterval(() => {
vibrateInterval = setIntervalAndExecute(() => {
if ("vibrate" in navigator){
navigator.vibrate(pattern);
}
}, sum(pattern));
}