presently 0.24.1 → 0.25.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d697262a722f7882d1d7b21809cdd51e1bb6475dd137f085e3e6fcd6a6f19f1
4
- data.tar.gz: f6f9cb865b7ba25161aafb1ec85cc665f88890b0845f8cd2e08f82ef89984cb6
3
+ metadata.gz: 665a4ba800abf1cbeea2acd8073600273160613f32221277f8bc84e616023024
4
+ data.tar.gz: ff0135c2c722ab5f447cc595fc7822320ead87b0ba303e8f08cf40e1ecda5c4c
5
5
  SHA512:
6
- metadata.gz: c1823bec93a21b7d361805c6e0f6f35512d5a91a524ef05a8837c9fbdac36091afacd689c311f2f664efb9f7f5c5dc02a3f27caa2cdfbcce6d5937d9ea0f2206
7
- data.tar.gz: efe1d9bc5bd918a498f7e395e466abdbcae60cc5896c8ac3c75b76fd952ca4b459b0479cb1c3df5618e3f4fc072eaa0c7db5e0376f82675a6951bcf8e2e94fe9
6
+ metadata.gz: 7a07dd02fe9c344ee29678e5d2b5037e91ae355d0f28c5a6eb57fa3121cc5ce90c170d4281de0b728c3526b61f21600182865487a0ddc7b3eac1952dd647020d
7
+ data.tar.gz: 67322e24a739782b01f77396ee54e5940272b739fc31e11acb9ad77f4db2cc3bd1eb1d9b6542384cde3d8581737712a97b22ddb5a49fec4770c5dcc08c05a528
checksums.yaml.gz.sig CHANGED
Binary file
@@ -5,5 +5,5 @@
5
5
 
6
6
  # @namespace
7
7
  module Presently
8
- VERSION = "0.24.1"
8
+ VERSION = "0.25.0"
9
9
  end
@@ -17,9 +17,17 @@ export class SlideRendering {
17
17
  #slides = [];
18
18
  #disposed = false;
19
19
 
20
- constructor(view, {transition = null} = {}) {
20
+ constructor(view, {transition = null, previous = null} = {}) {
21
21
  this.#view = view;
22
22
  this.#transitionName = transition;
23
+
24
+ if (previous) {
25
+ // Cancel stale rendering work immediately, but retain the visible slides
26
+ // until the browser has captured the outgoing transition snapshot.
27
+ this.#slides = previous.#slides;
28
+ previous.#slides = [];
29
+ previous.dispose();
30
+ }
23
31
  }
24
32
 
25
33
  // Initialize the slides already rendered within the view.
@@ -50,6 +58,9 @@ export class SlideRendering {
50
58
  const render = async () => {
51
59
  if (this.#disposed) return;
52
60
 
61
+ // View transitions invoke this callback after capturing the old state.
62
+ // Revert outgoing animations before updating potentially reused DOM nodes.
63
+ this.#disposeSlides();
53
64
  update(this.#view);
54
65
  initialized = await this.initialize();
55
66
  };
@@ -108,6 +119,10 @@ export class SlideRendering {
108
119
  delete document.documentElement.dataset.transition;
109
120
  }
110
121
 
122
+ this.#disposeSlides();
123
+ }
124
+
125
+ #disposeSlides() {
111
126
  this.#slides.forEach(slide => slide.dispose());
112
127
  this.#slides = [];
113
128
  }
@@ -10,10 +10,8 @@ let live = null;
10
10
  let activeRendering = null;
11
11
 
12
12
  function activateRendering(view, {transition = null} = {}) {
13
- const rendering = new SlideRendering(view, {transition});
14
- const previousRendering = activeRendering;
13
+ const rendering = new SlideRendering(view, {transition, previous: activeRendering});
15
14
  activeRendering = rendering;
16
- previousRendering?.dispose();
17
15
 
18
16
  return rendering;
19
17
  }
data/public/playback.js CHANGED
@@ -36,6 +36,10 @@ function stopCurrent() {
36
36
  currentRendering?.dispose();
37
37
  currentRendering = null;
38
38
 
39
+ stopAudio();
40
+ }
41
+
42
+ function stopAudio() {
39
43
  if (currentAudio) {
40
44
  currentAudio.pause();
41
45
  currentAudio.removeEventListener('ended', handleEnded);
@@ -55,6 +59,7 @@ async function activateFrame(index, {transition = true} = {}) {
55
59
 
56
60
  const rendering = new SlideRendering(frame, {
57
61
  transition: transition ? slideTemplate.dataset.transition : null,
62
+ previous: currentRendering,
58
63
  });
59
64
  currentRendering = rendering;
60
65
 
@@ -70,7 +75,7 @@ async function show(index, {transition = true} = {}) {
70
75
  if (transitioning || index < 0 || index >= slideTemplates.length) return false;
71
76
 
72
77
  transitioning = true;
73
- stopCurrent();
78
+ stopAudio();
74
79
 
75
80
  try {
76
81
  return await activateFrame(index, {transition});
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: presently
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.1
4
+ version: 0.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file