ohzi-core 6.3.0 → 6.3.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ohzi-core",
3
- "version": "6.3.0",
3
+ "version": "6.3.3",
4
4
  "description": "OHZI Core Library",
5
5
  "source": "src/index.js",
6
6
  "module": "build/index.module.js",
@@ -6,6 +6,7 @@ export default class ViewComponent
6
6
  {
7
7
  this.name = name;
8
8
  this.container = container;
9
+ this.hidden = true;
9
10
 
10
11
  ViewComponentManager.register_component(this);
11
12
  }
@@ -18,6 +19,8 @@ export default class ViewComponent
18
19
  {
19
20
  this.container.classList.remove('hidden');
20
21
  ViewComponentManager.enable_component(this);
22
+
23
+ this.hidden = false;
21
24
  }
22
25
 
23
26
  update()
@@ -28,10 +31,31 @@ export default class ViewComponent
28
31
  {
29
32
  this.container.classList.add('hidden');
30
33
  ViewComponentManager.disable_component(this);
34
+
35
+ this.hidden = true;
36
+ }
37
+
38
+ set_opacity(current_state_data)
39
+ {
40
+ this.container.style.opacity = current_state_data[`${this.name}_opacity`];
41
+ this.toggle_hidden();
31
42
  }
32
43
 
33
- set_opacity(opacity)
44
+ toggle_hidden()
34
45
  {
35
- this.container.style.opacity = opacity;
46
+ if (this.container.style.opacity > 0.001)
47
+ {
48
+ if (this.hidden)
49
+ {
50
+ this.on_enter();
51
+ }
52
+ }
53
+ else
54
+ {
55
+ if (!this.hidden)
56
+ {
57
+ this.on_exit();
58
+ }
59
+ }
36
60
  }
37
61
  }
@@ -10,6 +10,8 @@ class ViewComponentManager
10
10
 
11
11
  update()
12
12
  {
13
+ this.__set_components_opacities();
14
+
13
15
  for (const component of this.enabled_components)
14
16
  {
15
17
  component.update(ViewManager.transition_handler.current_state_data);
@@ -53,6 +55,14 @@ class ViewComponentManager
53
55
  console.error('[ViewComponentManager.get] no component found for: ', component_name);
54
56
  return undefined;
55
57
  }
58
+
59
+ __set_components_opacities()
60
+ {
61
+ for (let i = 0; i < this.components.length; i++)
62
+ {
63
+ this.components[i].set_opacity(ViewManager.transition_handler.current_state_data);
64
+ }
65
+ }
56
66
  }
57
67
 
58
68
  export default new ViewComponentManager();
@@ -9,6 +9,8 @@ class ViewManager
9
9
 
10
10
  this.transition_table = new TransitionTable();
11
11
  this.transition_handler = new ViewStateTransitionHandler(this.transition_table);
12
+
13
+ this.view_change_subscribers = [];
12
14
  }
13
15
 
14
16
  update()
@@ -27,6 +29,22 @@ class ViewManager
27
29
  {
28
30
  this.__change_browser_url(v.url);
29
31
  }
32
+
33
+ this.notify_view_change(view_name);
34
+ }
35
+
36
+ subscribe_to_view_change(subscriber)
37
+ {
38
+ this.view_change_subscribers.push(subscriber);
39
+ }
40
+
41
+ notify_view_change(view_name)
42
+ {
43
+ for (let i = 0; i < this.view_change_subscribers.length; i++)
44
+ {
45
+ const subscriber = this.view_change_subscribers[i];
46
+ subscriber.on_view_change(view_name);
47
+ }
30
48
  }
31
49
 
32
50
  register_view(view)
@@ -8,11 +8,11 @@ export default class TransitionTable
8
8
  this.initial_state_data = {};
9
9
  }
10
10
 
11
- get(to_state, current_context)
11
+ get(from_state_name, to_state_name, current_context)
12
12
  {
13
13
  for (let i = 0; i < this.transitions.length; i++)
14
14
  {
15
- if (this.transitions[i].to === to_state)
15
+ if (this.transitions[i].from === from_state_name && this.transitions[i].to === to_state_name)
16
16
  {
17
17
  const action_sequencer = new ActionSequencerBuilder(this.initial_state_data).from_animation_sheet(this.transitions[i].data, current_context);
18
18
 
@@ -20,7 +20,17 @@ export default class TransitionTable
20
20
  }
21
21
  }
22
22
 
23
- console.error('TransitionTable.get no data found for: ', to_state);
23
+ for (let i = 0; i < this.transitions.length; i++)
24
+ {
25
+ if (this.transitions[i].to === to_state_name)
26
+ {
27
+ const action_sequencer = new ActionSequencerBuilder(this.initial_state_data).from_animation_sheet(this.transitions[i].data, current_context);
28
+
29
+ return action_sequencer;
30
+ }
31
+ }
32
+
33
+ console.error('TransitionTable.get no data found for: ', from_state_name, to_state_name);
24
34
  return undefined;
25
35
  }
26
36
 
@@ -29,7 +29,7 @@ export default class ViewStateTransitionHandler
29
29
  this.last_state.before_exit();
30
30
  this.current_state.show();
31
31
 
32
- this.action_sequencer = this.transition_table.get(this.current_state.name, this.current_state_data);
32
+ this.action_sequencer = this.transition_table.get(this.last_state.name, this.current_state.name, this.current_state_data);
33
33
  this.current_state.before_enter();
34
34
 
35
35
  this.action_sequencer.play();