@everymatrix/lottery-program-wof 1.22.8 → 1.22.10

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/lottery-program-wof",
3
- "version": "1.22.8",
3
+ "version": "1.22.10",
4
4
  "main": "dist/lottery-program-wof.js",
5
5
  "svelte": "src/index.ts",
6
6
  "scripts": {
@@ -39,5 +39,5 @@
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "3950da5f5790b1e4270c8674a930025443f50ff5"
42
+ "gitHead": "38495c8b7fed86d85f3362fe6419369936e0a28a"
43
43
  }
@@ -10,7 +10,7 @@ import Thankyou3Svg from './images/Thankyou_3.svg'
10
10
  import Thankyou4Svg from './images/Thankyou_4.svg'
11
11
  import type { Lang } from './types'
12
12
  import type { LotteryProgramForPlayer } from './types.business'
13
- import { imageLoaderSvg } from './util'
13
+ import { imageLoaderSvg, isSafari } from './util'
14
14
 
15
15
  export interface Option {
16
16
  image: SVGElement | string,
@@ -69,12 +69,30 @@ export const getOptions = async (bonus: LotteryProgramForPlayer, lang: Lang) =>
69
69
 
70
70
  const { partitions } = bonus.program.wheelOfFortune
71
71
 
72
- const options: Option[] = await Promise.all(
73
- getOptionsFromPartitions(partitions, lang).map(async o => ({
74
- ...o,
75
- ...(await preloadImage(o.image as string))
76
- }))
77
- )
72
+ let options: Option[] = getOptionsFromPartitions(partitions, lang)
73
+
74
+ if(isSafari()){
75
+ options = options.map(option => {
76
+ if(option.image){
77
+ let img = document.createElementNS("http://www.w3.org/2000/svg", "image")
78
+ img.href.baseVal = option.image as string
79
+
80
+ return {
81
+ ...option,
82
+ image: img
83
+ }
84
+ }else{
85
+ return option
86
+ }
87
+ })
88
+ }else{
89
+ options = await Promise.all(
90
+ options.map(async o => ({
91
+ ...o,
92
+ ...(await preloadImage(o.image as string))
93
+ }))
94
+ )
95
+ }
78
96
 
79
97
  return options
80
98
  }
@@ -76,7 +76,7 @@ export class SvgCalc {
76
76
  }
77
77
 
78
78
  return {
79
- ...this.getPropsForPartitionInfo(index, this.getOffsetImage(sizeImage), baseRadius),
79
+ ...this.getPropsForPartitionInfo(index, this.getOffsetImage(sizeImage), baseRadius, ContentDirection.outward),
80
80
  width: sizeImage,
81
81
  height: sizeImage,
82
82
  }
@@ -148,8 +148,11 @@ export class SvgCalc {
148
148
  return RotateDirection.clockwise
149
149
  }
150
150
 
151
- getAngleSelf (index) {
152
- return 360 * index / this.length * this.direction + 90 * ContentDirection[this.contentdirection]
151
+ getAngleSelf (index, contentDirection?: ContentDirection) {
152
+ const baseAngle = 360 * index / this.length * this.direction
153
+ const fixerAngle = 90 * (contentDirection !== undefined ? contentDirection : ContentDirection[this.contentdirection])
154
+ const resultAngle = baseAngle + fixerAngle
155
+ return resultAngle
153
156
  }
154
157
 
155
158
  getPartitionPositions (index, baseRadius, offset) {
@@ -171,7 +174,8 @@ export class SvgCalc {
171
174
  getPropsForPartitionInfo (
172
175
  index: number,
173
176
  offset: any,
174
- baseRadius?: number
177
+ baseRadius?: number,
178
+ contentDirection?: ContentDirection
175
179
  ) {
176
180
 
177
181
  const { point, transformOrigin } = this.getPartitionPositions(index, baseRadius, offset)
@@ -183,7 +187,7 @@ export class SvgCalc {
183
187
  ...point,
184
188
  style: [
185
189
  `font-size: ${13 * this.ratio}px`,
186
- `transform: rotate(${this.getAngleSelf(index)}deg)`,
190
+ `transform: rotate(${this.getAngleSelf(index, contentDirection)}deg)`,
187
191
  `transform-origin: ${getTransformOriginString(transformOrigin)}`,
188
192
  ].join(';')
189
193
  }
@@ -9,7 +9,7 @@
9
9
  import { onMountMessageLifeCycle, _postMessage } from './message';
10
10
  import type { LotteryProgramForPlayer } from './types.business';
11
11
  import { themes } from './themes';
12
- import { setProps } from './util';
12
+ import { isSafari, setProps } from './util';
13
13
  import { Spinner } from './class.spinner';
14
14
  import { SvgCalc } from './class.svgcalc';
15
15
  import { Process } from './class.process';
@@ -187,6 +187,7 @@
187
187
  bind:this={svg}
188
188
  width={size}
189
189
  height={size}
190
+ on:click={() => isSafari() && eventSpin()}
190
191
  style:opacity={messageShown ? '.3': ''}
191
192
  >
192
193
  <foreignObject {...sizeProps} class="Bottom Customable" />
@@ -230,7 +231,7 @@
230
231
  {...calc.getSvgTextPropsAdjustedByImage(index)}
231
232
  >
232
233
  <div class="PartitionTextEntityContainer">
233
- <p class={`PartitionTextEntity${calc.contentdirection === 'clockwise' ? '' : ' Anticlockwise'}`}>{option.name}</p>
234
+ <p class={`PartitionTextEntity${calc.contentdirection === 'clockwise' ? '' : ' Anticlockwise'}`}>{@html option.name}</p>
234
235
  </div>
235
236
  </foreignObject>
236
237
  {/if}
@@ -278,7 +279,7 @@
278
279
  <g
279
280
  class="Center"
280
281
  class:disabled={isSpinning}
281
- on:click={() => eventSpin()}
282
+ on:click={() => isSafari() || eventSpin()}
282
283
  >
283
284
  <foreignObject
284
285
  x={Number(size)/2 - 100/2}
@@ -119,7 +119,7 @@
119
119
  <img src={prizeSrc} alt="" class="GiftImage">
120
120
  </p>
121
121
  {#if modeValue.prizeText}
122
- {modeValue.prizeText}
122
+ {@html modeValue.prizeText}
123
123
  {:else}
124
124
  {@html $_('wof.Congratulation', {values: { prize: modeValue.prize }})}
125
125
  {/if}
@@ -122,7 +122,7 @@
122
122
  <tbody style={outcomesItem.outcomes.length <= 5 ? 'overflow: hidden;' : ''}>
123
123
  {#each outcomesItem.outcomes as outcome}
124
124
  <tr>
125
- <td>{getPrize(outcome, outcomesItem.id)}</td>
125
+ <td>{@html getPrize(outcome, outcomesItem.id)}</td>
126
126
  <td>{outcome.draw.state}</td>
127
127
  <td>{(new Date(outcome.draw.time).toLocaleString(undefined, { timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone }))}</td>
128
128
  </tr>
package/src/types.ts CHANGED
@@ -72,6 +72,7 @@ export enum Tab {
72
72
  export enum ContentDirection {
73
73
  clockwise = 1,
74
74
  anticlockwise = -1,
75
+ outward = 0,
75
76
  }
76
77
 
77
78
 
package/src/util.ts CHANGED
@@ -82,4 +82,9 @@ export const fetchBase = async (input: RequestInfo | URL, init: RequestInit = {}
82
82
  }
83
83
 
84
84
  return res
85
+ }
86
+
87
+ export const isSafari = () => {
88
+ var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
89
+ return isSafari;
85
90
  }