@dosgato/dialog 0.0.37 → 0.0.38

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.
@@ -12,7 +12,7 @@ export let required = false;
12
12
  export let conditional = undefined;
13
13
  export let helptext = undefined;
14
14
  const store = new CropperStore({ width: 0, height: 0, minSelection, targetAspect: selectionAspectRatio });
15
- const { output, selection } = store;
15
+ const { output, outputPct, selection } = store;
16
16
  let setVal;
17
17
  let value;
18
18
  function init(spValue, spSetVal) {
@@ -114,9 +114,9 @@ let focusWithin = false;
114
114
  <div on:focusin={() => { focusWithin = true }} on:focusout={() => { focusWithin = false }}>
115
115
  <div bind:this={container} use:resize on:resize={() => updateRect()} class="crop-image-container" on:mousedown={onMouseDown} on:touchstart={onMouseDown} on:touchmove={onMouseMove} style:cursor={$store.cursor}>
116
116
  <img class="crop-image" src={imageSrc} alt="" />
117
- {#if $selection && $output}
117
+ {#if $selection && $outputPct}
118
118
  <div class='crop-bg'>
119
- <img class='crop-image clipped' src={imageSrc} alt="" style:clip-path="polygon({$output.left}% {$output.top}%, {100 - $output.right}% {$output.top}%, {100 - $output.right}% {100 - $output.bottom}%, {$output.left}% {100 - $output.bottom}%, {$output.left}% {$output.top}%)" />
119
+ <img class='crop-image clipped' src={imageSrc} alt="" style:clip-path="polygon({$outputPct.left}% {$outputPct.top}%, {100 - $outputPct.right}% {$outputPct.top}%, {100 - $outputPct.right}% {100 - $outputPct.bottom}%, {$outputPct.left}% {100 - $outputPct.bottom}%, {$outputPct.left}% {$outputPct.top}%)" />
120
120
  </div>
121
121
  <!-- svelte-ignore a11y-no-noninteractive-tabindex -->
122
122
  <div class='selectionHilite' {id} tabindex="0" on:keydown={onKeyDown('move')}
@@ -40,6 +40,12 @@ export declare class CropperStore extends Store<ICropperStore> {
40
40
  bottom: number;
41
41
  } | undefined, ICropperStore>;
42
42
  output: import("@txstate-mws/svelte-store").DerivedStore<CropOutput | undefined, ICropperStore>;
43
+ outputPct: import("@txstate-mws/svelte-store").DerivedStore<{
44
+ left: number;
45
+ top: number;
46
+ right: number;
47
+ bottom: number;
48
+ } | undefined, ICropperStore>;
43
49
  constructor(initialValue: Omit<ICropperStore, 'cursor'>);
44
50
  setOutput(selection?: CropOutput): void;
45
51
  updateDimensions(width: number, height: number): void;
@@ -8,6 +8,7 @@ export class CropperStore extends Store {
8
8
  return this.convertToPx(v.selection, v.width, v.height);
9
9
  });
10
10
  output = derivedStore(this, 'selection');
11
+ outputPct = derivedStore(this, v => v.selection ? ({ left: v.selection.left * 100, top: v.selection.top * 100, right: v.selection.right * 100, bottom: v.selection.bottom * 100 }) : undefined);
11
12
  constructor(initialValue) {
12
13
  super({ ...initialValue, cursor: 'crosshair' });
13
14
  }
@@ -57,7 +58,7 @@ export class CropperStore extends Store {
57
58
  const ar = v.width / v.height;
58
59
  const s = {};
59
60
  if (ar > v.targetAspect) { // draw area is wider than aspect, fill height
60
- s.left = 100 * (ar - v.targetAspect) / (2 * ar);
61
+ s.left = (ar - v.targetAspect) / (2 * ar);
61
62
  s.right = s.left;
62
63
  s.top = 0;
63
64
  s.bottom = 0;
@@ -65,7 +66,7 @@ export class CropperStore extends Store {
65
66
  else { // draw area is taller than aspect, fill width
66
67
  s.left = 0;
67
68
  s.right = 0;
68
- s.top = 100 * (v.targetAspect - ar) / (2 * v.targetAspect);
69
+ s.top = (v.targetAspect - ar) / (2 * v.targetAspect);
69
70
  s.bottom = s.top;
70
71
  }
71
72
  return { ...v, selection: s };
@@ -75,20 +76,20 @@ export class CropperStore extends Store {
75
76
  if (!sel)
76
77
  return undefined;
77
78
  return {
78
- left: 100.0 * sel.left / width,
79
- right: 100.0 * (width - sel.right) / width,
80
- top: 100.0 * sel.top / height,
81
- bottom: 100.0 * (height - sel.bottom) / height
79
+ left: sel.left / width,
80
+ right: (width - sel.right) / width,
81
+ top: sel.top / height,
82
+ bottom: (height - sel.bottom) / height
82
83
  };
83
84
  }
84
85
  convertToPx(output, width, height) {
85
86
  if (!output)
86
87
  return undefined;
87
88
  return {
88
- left: output.left * width / 100.0,
89
- right: width - output.right * width / 100.0,
90
- top: output.top * height / 100.0,
91
- bottom: height - output.bottom * height / 100.0
89
+ left: output.left * width,
90
+ right: width - output.right * width,
91
+ top: output.top * height,
92
+ bottom: height - output.bottom * height
92
93
  };
93
94
  }
94
95
  determineSelection(startX, startY, x, y, v) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dosgato/dialog",
3
3
  "description": "A component library for building forms that edit a JSON document.",
4
- "version": "0.0.37",
4
+ "version": "0.0.38",
5
5
  "dependencies": {
6
6
  "@txstate-mws/svelte-components": "^1.3.7",
7
7
  "@txstate-mws/svelte-forms": "^1.3.4",