@onsvisual/svelte-components 0.1.5 → 0.1.6

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.
@@ -14,6 +14,8 @@ export default class Scroller extends SvelteComponentTyped<{
14
14
  visible?: boolean;
15
15
  }, {
16
16
  change: CustomEvent<any>;
17
+ enter: CustomEvent<any>;
18
+ exit: CustomEvent<any>;
17
19
  } & {
18
20
  [evt: string]: CustomEvent<any>;
19
21
  }, {
@@ -40,6 +42,8 @@ declare const __propDef: {
40
42
  };
41
43
  events: {
42
44
  change: CustomEvent<any>;
45
+ enter: CustomEvent<any>;
46
+ exit: CustomEvent<any>;
43
47
  } & {
44
48
  [evt: string]: CustomEvent<any>;
45
49
  };
@@ -163,7 +163,6 @@
163
163
  $: widthStyle = fixed ? `width:${width}px;` : "";
164
164
 
165
165
  function initSections(sections) {
166
- console.log("updating scroller", sections.length);
167
166
  if (scroller) manager.remove(scroller);
168
167
 
169
168
  count = sections.length;
@@ -189,7 +188,10 @@
189
188
  const fg = foreground.getBoundingClientRect();
190
189
  const bg = background.getBoundingClientRect();
191
190
 
192
- visible = fg.top < wh && fg.bottom > 0;
191
+ const visible_new = fg.top < wh && fg.bottom > 0;
192
+ const entered = visible_new && !visible;
193
+ const exited = !visible_new && visible;
194
+ visible = visible_new;
193
195
 
194
196
  const foreground_height = fg.bottom - fg.top;
195
197
  const background_height = bg.bottom - bg.top;
@@ -221,7 +223,7 @@
221
223
 
222
224
  offset = (threshold_px - top) / (bottom - top);
223
225
  if (bottom >= threshold_px) {
224
- if (index !== i) {
226
+ if (index !== i || entered) {
225
227
  index = i;
226
228
  sectionId = section.dataset.id ? section.dataset.id : null;
227
229
  dispatch("change", { id, index, sectionId });
@@ -229,6 +231,9 @@
229
231
  break;
230
232
  }
231
233
  }
234
+
235
+ if (entered) dispatch("enter", { id, index, sectionId });
236
+ if (exited) dispatch("exit", { id, index, sectionId });
232
237
  }
233
238
  </script>
234
239
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onsvisual/svelte-components",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://onsvisual.github.io/svelte-components",