@vue-puzzle-vcode/core 2.0.0 → 2.0.1
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/dist/index.cjs +11 -3
- package/dist/index.js +12 -4
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -117,8 +117,13 @@ function useVcode(props, emits) {
|
|
|
117
117
|
const w = startWidth.value + newX.value - startX.value;
|
|
118
118
|
return w < sliderBaseSize.value ? sliderBaseSize.value : w > props.canvasWidth ? props.canvasWidth : w;
|
|
119
119
|
});
|
|
120
|
+
/**
|
|
121
|
+
* Travel distance of the track (slider end - start). Floored at 1 so the
|
|
122
|
+
* compensation term never divides by zero when canvasWidth ≈ sliderSize.
|
|
123
|
+
*/
|
|
124
|
+
const trackTravel = (0, vue_demi.computed)(() => (0, _vue_puzzle_vcode_shared.computeTrackTravel)(props.canvasWidth, sliderBaseSize.value));
|
|
120
125
|
/** translateX of the floating puzzle piece, synced to the slider. */
|
|
121
|
-
const puzzleTranslateX = (0, vue_demi.computed)(() =>
|
|
126
|
+
const puzzleTranslateX = (0, vue_demi.computed)(() => (0, _vue_puzzle_vcode_shared.computePuzzleTranslateX)(styleWidth.value, sliderBaseSize.value, puzzleBaseSize.value, trackTravel.value));
|
|
122
127
|
const canvases = {
|
|
123
128
|
main: (0, vue_demi.shallowRef)(),
|
|
124
129
|
puzzle: (0, vue_demi.shallowRef)(),
|
|
@@ -179,7 +184,10 @@ function useVcode(props, emits) {
|
|
|
179
184
|
pinY: pinY.value
|
|
180
185
|
});
|
|
181
186
|
} catch {
|
|
182
|
-
return init(true);
|
|
187
|
+
if (!withCanvas) return init(true);
|
|
188
|
+
loading.value = false;
|
|
189
|
+
isCanSlide.value = false;
|
|
190
|
+
return;
|
|
183
191
|
}
|
|
184
192
|
loading.value = false;
|
|
185
193
|
isCanSlide.value = true;
|
|
@@ -204,7 +212,7 @@ function useVcode(props, emits) {
|
|
|
204
212
|
}
|
|
205
213
|
function submit() {
|
|
206
214
|
isSubmting.value = true;
|
|
207
|
-
const x =
|
|
215
|
+
const x = (0, _vue_puzzle_vcode_shared.computeDragDeviation)(pinX.value, styleWidth.value, sliderBaseSize.value, puzzleBaseSize.value, trackTravel.value);
|
|
208
216
|
clearTimer();
|
|
209
217
|
if (x < props.range) {
|
|
210
218
|
infoText.value = props.successText;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { computed, getCurrentScope, h, inject, onScopeDispose, provide, ref, shallowRef, version } from "vue-demi";
|
|
2
|
-
import { computePuzzleBaseSize, computeSliderBaseSize, drawPuzzleFrame, generateRandomImage, loadImage, randomInt } from "@vue-puzzle-vcode/shared";
|
|
2
|
+
import { computeDragDeviation, computePuzzleBaseSize, computePuzzleTranslateX, computeSliderBaseSize, computeTrackTravel, drawPuzzleFrame, generateRandomImage, loadImage, randomInt } from "@vue-puzzle-vcode/shared";
|
|
3
3
|
//#region src/context.ts
|
|
4
4
|
/**
|
|
5
5
|
* Radix-style typed context factory built on provide/inject.
|
|
@@ -116,8 +116,13 @@ function useVcode(props, emits) {
|
|
|
116
116
|
const w = startWidth.value + newX.value - startX.value;
|
|
117
117
|
return w < sliderBaseSize.value ? sliderBaseSize.value : w > props.canvasWidth ? props.canvasWidth : w;
|
|
118
118
|
});
|
|
119
|
+
/**
|
|
120
|
+
* Travel distance of the track (slider end - start). Floored at 1 so the
|
|
121
|
+
* compensation term never divides by zero when canvasWidth ≈ sliderSize.
|
|
122
|
+
*/
|
|
123
|
+
const trackTravel = computed(() => computeTrackTravel(props.canvasWidth, sliderBaseSize.value));
|
|
119
124
|
/** translateX of the floating puzzle piece, synced to the slider. */
|
|
120
|
-
const puzzleTranslateX = computed(() => styleWidth.value
|
|
125
|
+
const puzzleTranslateX = computed(() => computePuzzleTranslateX(styleWidth.value, sliderBaseSize.value, puzzleBaseSize.value, trackTravel.value));
|
|
121
126
|
const canvases = {
|
|
122
127
|
main: shallowRef(),
|
|
123
128
|
puzzle: shallowRef(),
|
|
@@ -178,7 +183,10 @@ function useVcode(props, emits) {
|
|
|
178
183
|
pinY: pinY.value
|
|
179
184
|
});
|
|
180
185
|
} catch {
|
|
181
|
-
return init(true);
|
|
186
|
+
if (!withCanvas) return init(true);
|
|
187
|
+
loading.value = false;
|
|
188
|
+
isCanSlide.value = false;
|
|
189
|
+
return;
|
|
182
190
|
}
|
|
183
191
|
loading.value = false;
|
|
184
192
|
isCanSlide.value = true;
|
|
@@ -203,7 +211,7 @@ function useVcode(props, emits) {
|
|
|
203
211
|
}
|
|
204
212
|
function submit() {
|
|
205
213
|
isSubmting.value = true;
|
|
206
|
-
const x =
|
|
214
|
+
const x = computeDragDeviation(pinX.value, styleWidth.value, sliderBaseSize.value, puzzleBaseSize.value, trackTravel.value);
|
|
207
215
|
clearTimer();
|
|
208
216
|
if (x < props.range) {
|
|
209
217
|
infoText.value = props.successText;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-puzzle-vcode/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Headless core for vue-puzzle-vcode: context factory, v2/v3 render compat, state machine",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/
|
|
8
|
+
"url": "git+https://github.com/daguanren21/vue-puzzle-vcode.git",
|
|
9
9
|
"directory": "packages/core"
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"sideEffects": false,
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"vue-demi": "0.14.10",
|
|
33
|
-
"@vue-puzzle-vcode/shared": "^2.0.
|
|
33
|
+
"@vue-puzzle-vcode/shared": "^2.0.1"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"vue": "^2.7.0 || ^3.0.0"
|