Spaces:
Runtime error
Runtime error
File size: 785 Bytes
6f0e7f2 6d1f94e 6f0e7f2 6d1f94e 6f0e7f2 6d1f94e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
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));
} |