Skip to content

Commit

Permalink
add check if object is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
christian2denker committed Oct 1, 2024
1 parent a5702a7 commit f113b54
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,22 @@
document.addEventListener('touchend', endDrag);

function startDrag(e) {
pollyMessageListener.postMessage('startDrag')
if (pollyMessageListener && typeof pollyMessageListener.postMessage === 'function') {
pollyMessageListener.postMessage('startDrag');
} else {
console.warn('pollyMessageListener is not defined or does not support postMessage');
}
isDragging = true;
e.preventDefault();
document.getElementById('arrows').style.visibility = 'hidden';
}

function onDrag(e) {
pollyMessageListener.postMessage('onDrag')
if (pollyMessageListener && typeof pollyMessageListener.postMessage === 'function') {
pollyMessageListener.postMessage('onDrag');
} else {
console.warn('pollyMessageListener is not defined or does not support postMessage');
}
if (!isDragging) return;

let clientX = e.clientX || e.touches[0].clientX;
Expand All @@ -253,8 +261,11 @@
}

function endDrag() {
pollyMessageListener.postMessage('endDrag')

if (pollyMessageListener && typeof pollyMessageListener.postMessage === 'function') {
pollyMessageListener.postMessage('endDrag');
} else {
console.warn('pollyMessageListener is not defined or does not support postMessage');
}
isDragging = false;
if (userResult === null) return;
if (hasSubmitted) {
Expand Down

0 comments on commit f113b54

Please sign in to comment.