@vnejs/plugins.canvas.filter 0.1.1 → 0.1.2
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/const/const.js +1 -1
- package/const/events.js +2 -2
- package/const/params.js +8 -0
- package/index.js +2 -1
- package/modules/filter.js +4 -4
- package/package.json +1 -1
package/const/const.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const EXEC_ACTIONS = { SET: "set", UNSET: "unset" };
|
package/const/events.js
CHANGED
package/const/params.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const FILTERS = {
|
|
2
|
+
blur: (value = 0) => `blur(${value}px)`,
|
|
3
|
+
sunset: () => `opacity(95%) drop-shadow(0 0 0 #fad6a5) brightness(95%)`,
|
|
4
|
+
night: () => `opacity(90%) drop-shadow(0 0 0 #546bab) brightness(80%)`,
|
|
5
|
+
deepnight: () => `opacity(85%) drop-shadow(0 0 0 #2e4482) brightness(70%)`,
|
|
6
|
+
sunrise: () => `opacity(95%) drop-shadow(0 0 0 #fa7b62) brightness(95%)`,
|
|
7
|
+
grayscale: (value = 0) => `grayscale(${value})`,
|
|
8
|
+
};
|
package/index.js
CHANGED
|
@@ -2,7 +2,8 @@ import { regPlugin } from "@vnejs/shared";
|
|
|
2
2
|
|
|
3
3
|
import * as constants from "./const/const";
|
|
4
4
|
import { SUBSCRIBE_EVENTS } from "./const/events";
|
|
5
|
+
import * as params from "./const/params";
|
|
5
6
|
|
|
6
7
|
import { LayerFilter } from "./modules/filter";
|
|
7
8
|
|
|
8
|
-
regPlugin("LAYER_FILTER", { constants, events: SUBSCRIBE_EVENTS }, [LayerFilter]);
|
|
9
|
+
regPlugin("LAYER_FILTER", { constants, events: SUBSCRIBE_EVENTS, params }, [LayerFilter]);
|
package/modules/filter.js
CHANGED
|
@@ -11,10 +11,10 @@ export class LayerFilter extends Module {
|
|
|
11
11
|
this.on(this.EVENTS.STATE.CLEAR, this.onStateClear);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
onFilterSet = async ({ layer = "", name = "", duration = 0 } = {}) => {
|
|
15
|
-
this.state[layer] = name;
|
|
14
|
+
onFilterSet = async ({ layer = "", name = "", value = "", duration = 0, args = [] } = {}) => {
|
|
15
|
+
this.state[layer] = value || this.PARAMS.LAYER_FILTER.FILTERS[name](...args);
|
|
16
16
|
|
|
17
|
-
return this.emitLayerPropsUpdate(layer,
|
|
17
|
+
return this.emitLayerPropsUpdate(layer, this.state[layer], duration);
|
|
18
18
|
};
|
|
19
19
|
onFilterUnset = async ({ layer = "", duration = 0 } = {}) => {
|
|
20
20
|
delete this.state[layer];
|
|
@@ -24,7 +24,7 @@ export class LayerFilter extends Module {
|
|
|
24
24
|
|
|
25
25
|
onStateSet = async ({ [this.name]: state = {} } = {}) => {
|
|
26
26
|
await Promise.all(Object.keys(this.state).map((layer) => this.emit(this.EVENTS.LAYER_FILTER.UNSET, { layer, duration: 0 })));
|
|
27
|
-
await Promise.all(Object.keys(state).map((layer) => this.emit(this.EVENTS.LAYER_FILTER.SET, { layer,
|
|
27
|
+
await Promise.all(Object.keys(state).map((layer) => this.emit(this.EVENTS.LAYER_FILTER.SET, { layer, value: state[layer], duration: 0 })));
|
|
28
28
|
};
|
|
29
29
|
onStateClear = () => Promise.all(Object.keys(this.state).map((layer) => this.emit(this.EVENTS.LAYER_FILTER.UNSET, { layer, duration: 0 })));
|
|
30
30
|
|