|
126 | 126 | </style>
|
127 | 127 |
|
128 | 128 | <script>
|
129 |
| - import '../../../build/scratchcard.min'; |
130 |
| -
|
131 | 129 | export default {
|
132 | 130 | mounted() {
|
133 |
| - const scContainer = document.getElementById('js--sc--container') |
134 |
| - const scInfos = document.querySelector('.sc__infos'); |
135 |
| - const sc = new ScratchCard('#js--sc--container', { |
136 |
| - scratchType: SCRATCH_TYPE.CIRCLE, |
137 |
| - containerWidth: scContainer.offsetWidth, |
138 |
| - containerHeight: 300, |
139 |
| - brushSrc: '', |
140 |
| - imageForwardSrc: '/images/scratchcard.jpg', |
141 |
| - imageBackgroundSrc: '', |
142 |
| - htmlBackground: `<div class="inner_html"><p>Html content</p></div>`, |
143 |
| - clearZoneRadius: 30, |
144 |
| - nPoints: 50, |
145 |
| - pointSize: 4, |
146 |
| - callback: function () { |
147 |
| - alert('Now the window will reload !') |
148 |
| - window.location.reload() |
149 |
| - } |
150 |
| - }) |
151 |
| -
|
152 |
| - // Init |
153 |
| - sc.init().then(() => { |
154 |
| - sc.canvas.addEventListener('scratch.move', () => { |
155 |
| - let percent = sc.getPercent().toFixed(0); |
156 |
| - scInfos.innerHTML = percent + '%'; |
157 |
| - console.log(percent) |
| 131 | + import('../../../build/scratchcard.min').then(() => { |
| 132 | + const scContainer = document.getElementById('js--sc--container') |
| 133 | + const scInfos = document.querySelector('.sc__infos'); |
| 134 | + const sc = new ScratchCard('#js--sc--container', { |
| 135 | + scratchType: SCRATCH_TYPE.CIRCLE, |
| 136 | + containerWidth: scContainer.offsetWidth, |
| 137 | + containerHeight: 300, |
| 138 | + brushSrc: '', |
| 139 | + imageForwardSrc: '/images/scratchcard.jpg', |
| 140 | + imageBackgroundSrc: '', |
| 141 | + htmlBackground: `<div class="inner_html"><p>Html content</p></div>`, |
| 142 | + clearZoneRadius: 30, |
| 143 | + nPoints: 50, |
| 144 | + pointSize: 4, |
| 145 | + callback: function () { |
| 146 | + alert('Now the window will reload !') |
| 147 | + window.location.reload() |
| 148 | + } |
158 | 149 | })
|
159 |
| - }).catch((error) => { |
160 |
| - // image not loaded |
161 |
| - alert(error.message); |
| 150 | +
|
| 151 | + // Init |
| 152 | + sc.init().then(() => { |
| 153 | + sc.canvas.addEventListener('scratch.move', () => { |
| 154 | + let percent = sc.getPercent().toFixed(0); |
| 155 | + scInfos.innerHTML = percent + '%'; |
| 156 | + console.log(percent) |
| 157 | + }) |
| 158 | + }).catch((error) => { |
| 159 | + // image not loaded |
| 160 | + alert(error.message); |
| 161 | + }); |
162 | 162 | });
|
163 | 163 | }
|
164 | 164 | }
|
|
0 commit comments