fragment-tools 0.2.6 → 0.2.8

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/README.md CHANGED
@@ -87,7 +87,7 @@ export let update = ({ context, width, height }) => {
87
87
  };
88
88
  ```
89
89
 
90
- Learn how to write your own sketch by following the [Getting started](./docs//guide/getting-started.md) guide, reading the [API docs](./docs/api/sketch.md) or the [examples](./examples/).
90
+ Learn how to write your own sketch by following the [Getting started](./docs/introduction/getting-started.md) guide, reading the [API docs](./docs/api/sketch.md) or the [examples](./examples/).
91
91
 
92
92
  ## Contributing
93
93
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fragment-tools",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "A web development environment for creative coding",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -36,10 +36,11 @@ let previews = [];
36
36
  * @param {number} params.pixelRatio
37
37
  * @returns {MountParamsP5GLRenderer}
38
38
  */
39
- export let onMountPreview = ({ id, width, height }) => {
39
+ export let onMountPreview = ({ id, container, width, height }) => {
40
40
  const p = new p5((sketch) => {
41
41
  sketch.setup = () => {
42
- sketch.createCanvas(width, height, 'webgl');
42
+ const canvas = sketch.createCanvas(width, height, 'webgl');
43
+ canvas.parent(container);
43
44
  };
44
45
  });
45
46
 
@@ -2,10 +2,11 @@ import p5 from 'p5';
2
2
 
3
3
  let previews = [];
4
4
 
5
- export let onMountPreview = ({ id, width, height }) => {
5
+ export let onMountPreview = ({ id, container, width, height }) => {
6
6
  const p = new p5((sketch) => {
7
7
  sketch.setup = () => {
8
- sketch.createCanvas(width, height);
8
+ const canvas = sketch.createCanvas(width, height);
9
+ canvas.parent(container);
9
10
  };
10
11
  });
11
12
 
@@ -48,10 +48,7 @@ class Sketch {
48
48
 
49
49
  reset() {
50
50
  Object.keys(this.props).forEach((key) => {
51
- this.updateProp(
52
- key,
53
- $state.snapshot(this.props[key].__initialValue),
54
- );
51
+ this.updateProp(key, this.props[key].__initialValue);
55
52
  });
56
53
 
57
54
  this.propsFolders.forEach((fieldgroup) => {
@@ -543,10 +540,6 @@ class Sketch {
543
540
  ),
544
541
  };
545
542
  }
546
-
547
- get backgroundColor() {
548
- return this.instance.backgroundColor;
549
- }
550
543
  }
551
544
 
552
545
  export default Sketch;
@@ -12,6 +12,8 @@
12
12
 
13
13
  // handlers
14
14
  function handleMouseDown(event) {
15
+ if (disabled) return;
16
+
15
17
  document.body.classList.add('fragment-dragging');
16
18
  document.addEventListener('mousemove', handleMouseMove);
17
19
  document.addEventListener('mouseup', handleMouseUp);
@@ -104,17 +106,22 @@
104
106
  box-shadow: inset 0 0 0 1px var(--color-border-input);
105
107
 
106
108
  background: var(--color-background-input);
107
- cursor: ew-resize;
109
+
108
110
  container-type: size;
109
111
  outline: 0;
110
112
  }
111
113
 
112
- :global(body:not(.fragment-dragging)) .progress:hover {
114
+ .progress:not(.disabled) {
115
+ cursor: ew-resize;
116
+ }
117
+
118
+ :global(body:not(.fragment-dragging)) .progress:not(.disabled):hover {
113
119
  box-shadow: inset 0 0 0 1px var(--color-active);
114
120
  }
115
121
 
116
122
  .progress.dragging,
117
- :global(body:not(.fragment-dragging)) .progress:focus-visible {
123
+ :global(body:not(.fragment-dragging))
124
+ .progress:not(.disabled):focus-visible {
118
125
  box-shadow: 0 0 0 2px var(--color-active);
119
126
  }
120
127