@everymatrix/casino-game-page 0.0.282 → 0.0.283

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/casino-game-page",
3
- "version": "0.0.282",
3
+ "version": "0.0.283",
4
4
  "main": "dist/casino-game-page.js",
5
5
  "svelte": "src/index.ts",
6
6
  "scripts": {
@@ -36,5 +36,5 @@
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "a00139a8e44a6b9c994c7659a3ebe86b78356396"
39
+ "gitHead": "e19481532307b6ad83a24fda9f9b5ef7cc2a3b4c"
40
40
  }
@@ -48,8 +48,10 @@
48
48
  let playerID:string;
49
49
  let sessionID:string;
50
50
 
51
- let panicLoading = false;
52
- let panicButtonTimeout;
51
+ let panicButton:HTMLElement;
52
+ let panicLoading:boolean = false;
53
+ let timer: number = 0;
54
+ let timerInterval:any;
53
55
 
54
56
  let game:any;
55
57
  let detailsObtained:boolean = false;
@@ -373,14 +375,8 @@
373
375
  }
374
376
  }
375
377
 
376
- const PanicAction = () => {
377
- panicLoading = true;
378
-
379
- panicButtonTimeout = setTimeout(() => {
380
- panicLoading = false;
381
- window.postMessage({ type: 'PanicButtonClicked' }, window.location.href);
382
- }, 3000);
383
- clearTimeout(panicButtonTimeout);
378
+ const panicAction = ():void => {
379
+ window.postMessage({type: 'PanicButtonClicked'}, window.location.href);
384
380
  }
385
381
 
386
382
  const refreshTime = ():void => {
@@ -442,17 +438,52 @@
442
438
  }
443
439
  }
444
440
 
441
+ const startInterval = (e:any):void => {
442
+ timer = 0;
443
+
444
+ timerInterval = setInterval(() => {
445
+ timer += 1;
446
+ panicLoading = true;
447
+
448
+ if (timer >= 3) {
449
+ clearInterval(timerInterval)
450
+ }
451
+ }, 1000);
452
+ }
453
+
454
+ const endInterval = (e:any):void => {
455
+ if (timer < 3) {
456
+ panicLoading = false;
457
+ }
458
+ clearInterval(timerInterval);
459
+ }
460
+
445
461
  onMount(() => {
446
462
  window.addEventListener('resize', resizeHandler, false);
447
463
  window.addEventListener('message', messageHandler, false);
448
464
 
449
465
  isOnNative = !!isNative(userAgent);
450
466
 
451
- return () => {
452
- window.removeEventListener('resize', resizeHandler);
453
- window.removeEventListener('message', messageHandler);
467
+ panicButton?.addEventListener("mousedown", startInterval, false);
468
+ panicButton?.addEventListener('touchstart', startInterval, false)
469
+
470
+ // on mouseup stop interval count
471
+ panicButton?.addEventListener("mouseup", endInterval, false);
472
+ panicButton?.addEventListener("touchend", endInterval, false);
473
+
474
+ return () => {
475
+ window.removeEventListener('resize', resizeHandler);
476
+ window.removeEventListener('message', messageHandler);
477
+
478
+ clearInterval(timeInterval);
479
+
480
+ panicButton?.removeEventListener("mousedown", startInterval);
481
+ panicButton?.removeEventListener('touchstart', startInterval)
482
+
483
+ // on mouseup stop interval count
484
+ panicButton?.removeEventListener("mouseup", endInterval);
485
+ panicButton?.removeEventListener("touchend", endInterval);
454
486
 
455
- clearInterval(timeInterval);
456
487
  }
457
488
  });
458
489
 
@@ -508,7 +539,7 @@
508
539
  <svg class="w-1 h-1" part="w-1 h-1" fill="none" stroke="white" width="34px" height="34px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
509
540
  <p>{$_('gamePage.break')}</p>
510
541
  </div>
511
- <button class="Button" class:PanicButtonAnimation={panicLoading} part="Button" on:click={() => panicAction()}>{$_('gamePage.breakButton')}</button>
542
+ <button class="PanicButton" class:PanicButtonAnimation={panicLoading} part="PanicButton" bind:this={panicButton} on:click={() => panicAction()}>{$_('casinoPage.breakButton')}</button>
512
543
  </div>
513
544
  {/if}
514
545
  <p>{time}</p>