svelte-tiny-virtual-list
Advanced tools
Comparing version 1.1.5 to 1.1.6
@@ -315,18 +315,20 @@ (function (global, factory) { | ||
} | ||
function mount_component(component, target, anchor) { | ||
function mount_component(component, target, anchor, customElement) { | ||
const { fragment, on_mount, on_destroy, after_update } = component.$$; | ||
fragment && fragment.m(target, anchor); | ||
// onMount happens before the initial afterUpdate | ||
add_render_callback(() => { | ||
const new_on_destroy = on_mount.map(run).filter(is_function); | ||
if (on_destroy) { | ||
on_destroy.push(...new_on_destroy); | ||
} | ||
else { | ||
// Edge case - component was destroyed immediately, | ||
// most likely as a result of a binding initialising | ||
run_all(new_on_destroy); | ||
} | ||
component.$$.on_mount = []; | ||
}); | ||
if (!customElement) { | ||
// onMount happens before the initial afterUpdate | ||
add_render_callback(() => { | ||
const new_on_destroy = on_mount.map(run).filter(is_function); | ||
if (on_destroy) { | ||
on_destroy.push(...new_on_destroy); | ||
} | ||
else { | ||
// Edge case - component was destroyed immediately, | ||
// most likely as a result of a binding initialising | ||
run_all(new_on_destroy); | ||
} | ||
component.$$.on_mount = []; | ||
}); | ||
} | ||
after_update.forEach(add_render_callback); | ||
@@ -356,3 +358,2 @@ } | ||
set_current_component(component); | ||
const prop_values = options.props || {}; | ||
const $$ = component.$$ = { | ||
@@ -369,5 +370,6 @@ fragment: null, | ||
on_destroy: [], | ||
on_disconnect: [], | ||
before_update: [], | ||
after_update: [], | ||
context: new Map(parent_component ? parent_component.$$.context : []), | ||
context: new Map(parent_component ? parent_component.$$.context : options.context || []), | ||
// everything else | ||
@@ -380,3 +382,3 @@ callbacks: blank_object(), | ||
$$.ctx = instance | ||
? instance(component, prop_values, (i, ret, ...rest) => { | ||
? instance(component, options.props || {}, (i, ret, ...rest) => { | ||
const value = rest.length ? rest[0] : ret; | ||
@@ -410,3 +412,3 @@ if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) { | ||
transition_in(component.$$.fragment); | ||
mount_component(component, options.target, options.anchor); | ||
mount_component(component, options.target, options.anchor, options.customElement); | ||
flush(); | ||
@@ -879,3 +881,3 @@ } | ||
/* src/VirtualList.svelte generated by Svelte v3.31.2 */ | ||
/* src/VirtualList.svelte generated by Svelte v3.37.0 */ | ||
@@ -1132,3 +1134,3 @@ function add_css() { | ||
let state = { | ||
offset: scrollOffset || scrollToIndex != null && getOffsetForIndex(scrollToIndex) || 0, | ||
offset: scrollOffset || scrollToIndex != null && items.length && getOffsetForIndex(scrollToIndex) || 0, | ||
scrollChangeReason: SCROLL_CHANGE_REASON.REQUESTED | ||
@@ -1357,11 +1359,11 @@ }; | ||
if ($$self.$$.dirty[0] & /*scrollToIndex, scrollToAlignment, scrollOffset, itemCount, itemSize, estimatedItemSize*/ 14784) { | ||
propsUpdated(); | ||
propsUpdated(); | ||
} | ||
if ($$self.$$.dirty[0] & /*state*/ 131072) { | ||
stateUpdated(); | ||
stateUpdated(); | ||
} | ||
if ($$self.$$.dirty[0] & /*mounted, height, width, stickyIndices*/ 66096) { | ||
if (mounted) recomputeSizes(height); // call scroll.reset; | ||
if (mounted) recomputeSizes(height); // call scroll.reset; | ||
} | ||
@@ -1368,0 +1370,0 @@ }; |
{ | ||
"name": "svelte-tiny-virtual-list", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "A tiny but mighty list virtualization component for svelte, with zero dependencies 💪", | ||
@@ -5,0 +5,0 @@ "svelte": "src/index.js", |
/// <reference types="svelte" /> | ||
import { SvelteComponentTyped } from 'svelte'; | ||
export enum ALIGNMENT { | ||
AUTO = 'auto', | ||
START = 'start', | ||
CENTER = 'center', | ||
END = 'end', | ||
} | ||
export type Alignment = "auto" | "start" | "center" | "end"; | ||
export enum DIRECTION { | ||
HORIZONTAL = 'horizontal', | ||
VERTICAL = 'vertical', | ||
} | ||
export type Direction = "horizontal" | "vertical"; | ||
@@ -52,3 +44,3 @@ export type ItemSizeGetter = (index: number) => number; | ||
*/ | ||
scrollDirection?: DIRECTION; | ||
scrollDirection?: Direction; | ||
@@ -69,6 +61,6 @@ /** | ||
* Use `'start'` to always align items to the top of the container and `'end'` to align them bottom. | ||
* Use `'center`' to align them in the middle of the container. | ||
* Use `'center'` to align them in the middle of the container. | ||
* `'auto'` scrolls the least amount possible to ensure that the specified `scrollToIndex` item is fully visible. | ||
*/ | ||
scrollToAlignment?: ALIGNMENT; | ||
scrollToAlignment?: Alignment; | ||
@@ -75,0 +67,0 @@ /** |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
118693
3001