Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vscroll

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vscroll - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

3

dist/esm2015/classes/buffer.js

@@ -314,4 +314,3 @@ import { Cache } from './buffer/cache';

getSizeByIndex(index) {
const item = this.cache.get(index);
return item ? item.size : this.defaultSize;
return this.cache.getSizeByIndex(index);
}

@@ -318,0 +317,0 @@ checkDefaultSize() {

@@ -40,5 +40,5 @@ import { DefaultSize } from './defaultSize';

}
getItemSize(index) {
getSizeByIndex(index) {
const item = this.get(index);
return item ? item.size : 0;
return item ? item.size : this.defaultSize.get();
}

@@ -45,0 +45,0 @@ getDefaultSize() {

@@ -34,4 +34,7 @@ export class Item {

}
setSize() {
this.size = this.routines.getSize(this.element);
setSize(preSize = 0) {
this.preSize = preSize;
if (this.element) {
this.size = this.routines.getSize(this.element);
}
}

@@ -38,0 +41,0 @@ hide() {

@@ -12,3 +12,3 @@ import { WorkflowCycleModel } from './state/cycle';

this.cycle = new WorkflowCycleModel(this.settings.instanceIndex, state ? state.cycle : void 0);
this.fetch = new FetchModel();
this.fetch = new FetchModel(settings.directionPriority);
this.clip = new ClipModel();

@@ -15,0 +15,0 @@ this.render = new RenderModel();

@@ -30,4 +30,14 @@ import { Direction } from '../../inputs/index';

}
class FirstVisible {
constructor() {
this.reset();
}
reset() {
this.index = NaN;
this.delta = 0;
}
}
export class FetchModel {
constructor() {
constructor(directionPriority) {
this.directionPriority = directionPriority;
this.callCount = 0;

@@ -37,2 +47,3 @@ this.positions = new Positions();

this.last = new Last();
this.firstVisible = new FirstVisible();
this.reset();

@@ -46,5 +57,4 @@ }

this.last.reset();
this.firstVisible.reset();
this.hasAnotherPack = false;
this.firstVisibleIndex = NaN;
this.firstVisibleItemDelta = NaN;
this.negativeSize = 0;

@@ -79,2 +89,9 @@ this.direction = null;

}
shouldCheckPreSizeExpectation(lastBufferedIndex) {
if (this.directionPriority === Direction.backward) {
return false;
}
const lastFetched = this.items[this.items.length - 1];
return lastFetched && lastFetched.$index < lastBufferedIndex;
}
startSimulate(items) {

@@ -119,4 +136,4 @@ this.simulate = true;

this.startSimulate(items);
this.firstVisibleIndex = index;
this.firstVisibleItemDelta = delta;
this.firstVisible.index = index;
this.firstVisible.delta = delta;
this.doRemove = itemsToRemove.length > 0;

@@ -123,0 +140,0 @@ }

import { VALIDATORS } from './validation';
import { SizeStrategy } from './common';
import { SizeStrategy, Direction } from './common';
const { NUMBER, INTEGER, INTEGER_UNLIMITED, MORE_OR_EQUAL, BOOLEAN, ELEMENT, FUNC, OR, ENUM } = VALIDATORS;

@@ -32,4 +32,4 @@ var Settings;

DevSettings["cacheOnReload"] = "cacheOnReload";
DevSettings["changeOverflow"] = "changeOverflow";
DevSettings["dismissOverflowAnchor"] = "dismissOverflowAnchor";
DevSettings["directionPriority"] = "directionPriority";
})(DevSettings || (DevSettings = {}));

@@ -139,6 +139,2 @@ export const MIN = {

},
[DevSettings.changeOverflow]: {
validators: [BOOLEAN],
defaultValue: false
},
[DevSettings.dismissOverflowAnchor]: {

@@ -148,3 +144,7 @@ validators: [BOOLEAN],

},
[DevSettings.directionPriority]: {
validators: [ENUM(Direction)],
defaultValue: Direction.backward
},
};
//# sourceMappingURL=settings.js.map

@@ -20,5 +20,5 @@ import { BaseAdapterProcessFactory, AdapterProcess, ProcessStatus } from '../misc/index';

const { index: firstIndex, diff } = viewport.getEdgeVisibleItem(buffer.items, Direction.backward);
fetch.firstVisibleIndex = firstIndex;
fetch.firstVisible.index = firstIndex;
if (!isNaN(firstIndex)) {
fetch.firstVisibleItemDelta = -buffer.getSizeByIndex(firstIndex) + diff;
fetch.firstVisible.delta = -buffer.getSizeByIndex(firstIndex) + diff;
}

@@ -25,0 +25,0 @@ fetch.check(buffer.items.filter(item => item.$index >= min && item.$index <= max));

@@ -17,3 +17,3 @@ import { BaseAdapterProcessFactory, AdapterProcess, ProcessStatus } from '../misc/index';

const { fetch } = scroller.state;
fetch.firstVisibleIndex = NaN;
fetch.firstVisible.index = NaN;
const bufferRemoveList = Remove.removeBufferedItems(scroller, params);

@@ -28,3 +28,3 @@ if (params.indexes && params.indexes.length) { // to avoid duplicate buffer-virtual removals

}
if (!isNaN(fetch.firstVisibleIndex)) {
if (!isNaN(fetch.firstVisible.index)) {
fetch.remove();

@@ -45,3 +45,3 @@ }

static runPredicateOverBuffer(scroller, predicate, increase) {
const { viewport, buffer, buffer: { items }, state: { fetch } } = scroller;
const { viewport, buffer, buffer: { items }, state: { fetch: { firstVisible } } } = scroller;
// get items to remove

@@ -67,16 +67,18 @@ const clipList = [];

if (firstIndex < firstClipIndex || firstIndex > lastClipIndex) {
fetch.firstVisibleIndex = firstIndex;
fetch.firstVisibleItemDelta = -buffer.getSizeByIndex(firstIndex) + diff;
firstVisible.index = firstIndex;
if (!isNaN(firstIndex)) {
firstVisible.delta = -buffer.getSizeByIndex(firstIndex) + diff;
}
}
// 2) next after the last removed item
if (isNaN(fetch.firstVisibleIndex) && lastClipIndex < buffer.finiteAbsMaxIndex) {
fetch.firstVisibleIndex = lastClipIndex + 1;
if (isNaN(firstVisible.index) && lastClipIndex < buffer.finiteAbsMaxIndex) {
firstVisible.index = lastClipIndex + 1;
}
// 3) prev before the first removed item
if (isNaN(fetch.firstVisibleIndex) && firstClipIndex > buffer.finiteAbsMinIndex) {
fetch.firstVisibleIndex = firstClipIndex - 1;
if (isNaN(firstVisible.index) && firstClipIndex > buffer.finiteAbsMinIndex) {
firstVisible.index = firstClipIndex - 1;
}
// 4) prev before the first removed item
if (isNaN(fetch.firstVisibleIndex)) {
fetch.firstVisibleIndex = buffer.finiteAbsMinIndex;
if (isNaN(firstVisible.index)) {
firstVisible.index = buffer.finiteAbsMinIndex;
}

@@ -124,7 +126,7 @@ // logical removal

// what should be shown after remove; Buffer removal has priority
if (isNaN(fetch.firstVisibleIndex)) {
if (isNaN(fetch.firstVisible.index)) {
const { index, diff } = viewport.getEdgeVisibleItem(buffer.items, Direction.backward);
fetch.firstVisible.index = index;
if (!isNaN(index)) {
fetch.firstVisibleIndex = index;
fetch.firstVisibleItemDelta = -buffer.getSizeByIndex(index) + diff;
fetch.firstVisible.delta = -buffer.getSizeByIndex(index) + diff;
}

@@ -139,10 +141,11 @@ }

}
static shiftFirstVisibleIndex({ state: { fetch } }, listToRemove, increase) {
if (isNaN(fetch.firstVisibleIndex)) {
static shiftFirstVisibleIndex(scroller, listToRemove, increase) {
const { firstVisible } = scroller.state.fetch;
if (isNaN(firstVisible.index)) {
return;
}
const shift = listToRemove.reduce((acc, index) => acc + (((increase && index > fetch.firstVisibleIndex) || (!increase && index < fetch.firstVisibleIndex)) ? 1 : 0), 0);
fetch.firstVisibleIndex = fetch.firstVisibleIndex + (increase ? shift : -shift);
const shift = listToRemove.reduce((acc, index) => acc + (((increase && index > firstVisible.index) || (!increase && index < firstVisible.index)) ? 1 : 0), 0);
firstVisible.index = firstVisible.index + (increase ? shift : -shift);
}
}
//# sourceMappingURL=remove.js.map

@@ -26,3 +26,3 @@ import { BaseProcessFactory, CommonProcess, ProcessStatus } from './misc/index';

else {
first = !isNaN(fetch.firstVisibleIndex) ? fetch.firstVisibleIndex : buffer.startIndex;
first = !isNaN(fetch.firstVisible.index) ? fetch.firstVisible.index : buffer.startIndex;
last = first - 1;

@@ -56,15 +56,26 @@ }

static calculatePosition(scroller) {
const { viewport, buffer, state } = scroller;
const { fetch, render, scrollState } = state;
const { viewport, buffer, state: { fetch, render, scrollState } } = scroller;
let position = viewport.paddings.backward.size;
// backward outlet increase
if (!isNaN(fetch.firstVisibleIndex) && !isNaN(buffer.firstIndex)) {
for (let i = buffer.firstIndex; i < fetch.firstVisibleIndex; i++) {
position += buffer.getSizeByIndex(i);
}
if (fetch.firstVisibleItemDelta) {
position -= fetch.firstVisibleItemDelta;
}
// increase the position to meet the expectation of the first visible item
if (!isNaN(fetch.firstVisible.index) && !isNaN(buffer.firstIndex)) {
scroller.logger.log(`first index = ${fetch.firstVisible.index}, delta = ${fetch.firstVisible.delta}`);
const shouldCheckPreSizeExpectation = fetch.shouldCheckPreSizeExpectation(buffer.lastIndex);
buffer.items.forEach(item => {
// 1) shift of the buffered items before the first visible item
if (item.$index < fetch.firstVisible.index) {
position += item.size;
return;
}
// 2) delta of the first visible item
if (item.$index === fetch.firstVisible.index && fetch.firstVisible.delta) {
position -= fetch.firstVisible.delta;
}
// 3) difference between expected and real sizes of fetched items after the first visible
if (shouldCheckPreSizeExpectation && item.preSize && fetch.items.includes(item)) {
position += item.size - item.preSize;
}
});
}
else {
// todo: switch prepend to fetch.firstVisible and get rid of fetch.negativeSize
if (fetch.isPrepend && fetch.negativeSize) {

@@ -74,3 +85,3 @@ position += fetch.negativeSize;

}
// change per slow fetch/render
// slow fetch/render case
if (scrollState.positionBeforeAsync !== null) {

@@ -83,3 +94,3 @@ const diff = render.positionBefore - scrollState.positionBeforeAsync;

}
// offset increase
// increase the position due to viewport's offset
if (viewport.offset > 0 && (position || fetch.positions.before)) {

@@ -86,0 +97,0 @@ position += viewport.offset;

@@ -106,3 +106,3 @@ import { BaseProcessFactory, CommonProcess, AdapterProcess, ProcessStatus } from './misc/index';

const { state: { fetch, cycle }, buffer, settings } = scroller;
const { positions: { relative, end }, first, last } = fetch;
const { firstVisible, positions: { relative, end }, first, last } = fetch;
let lastIndex;

@@ -122,6 +122,6 @@ if (!buffer.defaultSize) {

position += size;
if (isNaN(fetch.firstVisibleIndex) && position > relative) {
fetch.firstVisibleIndex = index;
if (isNaN(firstVisible.index) && position > relative) {
firstVisible.index = index;
if (!cycle.innerLoop.isInitial) {
fetch.firstVisibleItemDelta = position - size - relative;
firstVisible.delta = position - size - relative;
}

@@ -128,0 +128,0 @@ }

@@ -53,3 +53,3 @@ import { BaseProcessFactory, CommonProcess, ProcessStatus } from './misc/index';

item.invisible = false;
item.setSize();
item.setSize(buffer.getSizeByIndex(item.$index));
buffer.cacheItem(item);

@@ -56,0 +56,0 @@ if (item.$index < fetch.minIndex) {

export default {
name: 'vscroll',
version: '1.2.1'
version: '1.3.0'
};
//# sourceMappingURL=version.js.map

@@ -375,4 +375,3 @@ import { __read, __spreadArray } from "tslib";

Buffer.prototype.getSizeByIndex = function (index) {
var item = this.cache.get(index);
return item ? item.size : this.defaultSize;
return this.cache.getSizeByIndex(index);
};

@@ -379,0 +378,0 @@ Buffer.prototype.checkDefaultSize = function () {

@@ -47,5 +47,5 @@ import { DefaultSize } from './defaultSize';

};
Cache.prototype.getItemSize = function (index) {
Cache.prototype.getSizeByIndex = function (index) {
var item = this.get(index);
return item ? item.size : 0;
return item ? item.size : this.defaultSize.get();
};

@@ -52,0 +52,0 @@ Cache.prototype.getDefaultSize = function () {

@@ -46,4 +46,8 @@ var Item = /** @class */ (function () {

};
Item.prototype.setSize = function () {
this.size = this.routines.getSize(this.element);
Item.prototype.setSize = function (preSize) {
if (preSize === void 0) { preSize = 0; }
this.preSize = preSize;
if (this.element) {
this.size = this.routines.getSize(this.element);
}
};

@@ -50,0 +54,0 @@ Item.prototype.hide = function () {

@@ -13,3 +13,3 @@ import { __assign } from "tslib";

this.cycle = new WorkflowCycleModel(this.settings.instanceIndex, state ? state.cycle : void 0);
this.fetch = new FetchModel();
this.fetch = new FetchModel(settings.directionPriority);
this.clip = new ClipModel();

@@ -16,0 +16,0 @@ this.render = new RenderModel();

@@ -33,4 +33,15 @@ import { Direction } from '../../inputs/index';

}());
var FirstVisible = /** @class */ (function () {
function FirstVisible() {
this.reset();
}
FirstVisible.prototype.reset = function () {
this.index = NaN;
this.delta = 0;
};
return FirstVisible;
}());
var FetchModel = /** @class */ (function () {
function FetchModel() {
function FetchModel(directionPriority) {
this.directionPriority = directionPriority;
this.callCount = 0;

@@ -40,2 +51,3 @@ this.positions = new Positions();

this.last = new Last();
this.firstVisible = new FirstVisible();
this.reset();

@@ -49,5 +61,4 @@ }

this.last.reset();
this.firstVisible.reset();
this.hasAnotherPack = false;
this.firstVisibleIndex = NaN;
this.firstVisibleItemDelta = NaN;
this.negativeSize = 0;

@@ -102,2 +113,9 @@ this.direction = null;

});
FetchModel.prototype.shouldCheckPreSizeExpectation = function (lastBufferedIndex) {
if (this.directionPriority === Direction.backward) {
return false;
}
var lastFetched = this.items[this.items.length - 1];
return lastFetched && lastFetched.$index < lastBufferedIndex;
};
FetchModel.prototype.startSimulate = function (items) {

@@ -142,4 +160,4 @@ this.simulate = true;

this.startSimulate(items);
this.firstVisibleIndex = index;
this.firstVisibleItemDelta = delta;
this.firstVisible.index = index;
this.firstVisible.delta = delta;
this.doRemove = itemsToRemove.length > 0;

@@ -146,0 +164,0 @@ };

var _a, _b, _c;
import { VALIDATORS } from './validation';
import { SizeStrategy } from './common';
import { SizeStrategy, Direction } from './common';
var NUMBER = VALIDATORS.NUMBER, INTEGER = VALIDATORS.INTEGER, INTEGER_UNLIMITED = VALIDATORS.INTEGER_UNLIMITED, MORE_OR_EQUAL = VALIDATORS.MORE_OR_EQUAL, BOOLEAN = VALIDATORS.BOOLEAN, ELEMENT = VALIDATORS.ELEMENT, FUNC = VALIDATORS.FUNC, OR = VALIDATORS.OR, ENUM = VALIDATORS.ENUM;

@@ -33,4 +33,4 @@ var Settings;

DevSettings["cacheOnReload"] = "cacheOnReload";
DevSettings["changeOverflow"] = "changeOverflow";
DevSettings["dismissOverflowAnchor"] = "dismissOverflowAnchor";
DevSettings["directionPriority"] = "directionPriority";
})(DevSettings || (DevSettings = {}));

@@ -140,6 +140,2 @@ export var MIN = (_a = {},

},
_c[DevSettings.changeOverflow] = {
validators: [BOOLEAN],
defaultValue: false
},
_c[DevSettings.dismissOverflowAnchor] = {

@@ -149,3 +145,7 @@ validators: [BOOLEAN],

},
_c[DevSettings.directionPriority] = {
validators: [ENUM(Direction)],
defaultValue: Direction.backward
},
_c);
//# sourceMappingURL=settings.js.map

@@ -25,5 +25,5 @@ import { __extends } from "tslib";

var _a = viewport.getEdgeVisibleItem(buffer.items, Direction.backward), firstIndex = _a.index, diff = _a.diff;
fetch.firstVisibleIndex = firstIndex;
fetch.firstVisible.index = firstIndex;
if (!isNaN(firstIndex)) {
fetch.firstVisibleItemDelta = -buffer.getSizeByIndex(firstIndex) + diff;
fetch.firstVisible.delta = -buffer.getSizeByIndex(firstIndex) + diff;
}

@@ -30,0 +30,0 @@ fetch.check(buffer.items.filter(function (item) { return item.$index >= min && item.$index <= max; }));

@@ -23,3 +23,3 @@ import { __extends } from "tslib";

var fetch = scroller.state.fetch;
fetch.firstVisibleIndex = NaN;
fetch.firstVisible.index = NaN;
var bufferRemoveList = Remove.removeBufferedItems(scroller, params);

@@ -34,3 +34,3 @@ if (params.indexes && params.indexes.length) { // to avoid duplicate buffer-virtual removals

}
if (!isNaN(fetch.firstVisibleIndex)) {
if (!isNaN(fetch.firstVisible.index)) {
fetch.remove();

@@ -53,3 +53,3 @@ }

Remove.runPredicateOverBuffer = function (scroller, predicate, increase) {
var viewport = scroller.viewport, buffer = scroller.buffer, items = scroller.buffer.items, fetch = scroller.state.fetch;
var viewport = scroller.viewport, buffer = scroller.buffer, items = scroller.buffer.items, firstVisible = scroller.state.fetch.firstVisible;
// get items to remove

@@ -75,16 +75,18 @@ var clipList = [];

if (firstIndex < firstClipIndex || firstIndex > lastClipIndex) {
fetch.firstVisibleIndex = firstIndex;
fetch.firstVisibleItemDelta = -buffer.getSizeByIndex(firstIndex) + diff;
firstVisible.index = firstIndex;
if (!isNaN(firstIndex)) {
firstVisible.delta = -buffer.getSizeByIndex(firstIndex) + diff;
}
}
// 2) next after the last removed item
if (isNaN(fetch.firstVisibleIndex) && lastClipIndex < buffer.finiteAbsMaxIndex) {
fetch.firstVisibleIndex = lastClipIndex + 1;
if (isNaN(firstVisible.index) && lastClipIndex < buffer.finiteAbsMaxIndex) {
firstVisible.index = lastClipIndex + 1;
}
// 3) prev before the first removed item
if (isNaN(fetch.firstVisibleIndex) && firstClipIndex > buffer.finiteAbsMinIndex) {
fetch.firstVisibleIndex = firstClipIndex - 1;
if (isNaN(firstVisible.index) && firstClipIndex > buffer.finiteAbsMinIndex) {
firstVisible.index = firstClipIndex - 1;
}
// 4) prev before the first removed item
if (isNaN(fetch.firstVisibleIndex)) {
fetch.firstVisibleIndex = buffer.finiteAbsMinIndex;
if (isNaN(firstVisible.index)) {
firstVisible.index = buffer.finiteAbsMinIndex;
}

@@ -134,7 +136,7 @@ // logical removal

// what should be shown after remove; Buffer removal has priority
if (isNaN(fetch.firstVisibleIndex)) {
if (isNaN(fetch.firstVisible.index)) {
var _a = viewport.getEdgeVisibleItem(buffer.items, Direction.backward), index = _a.index, diff = _a.diff;
fetch.firstVisible.index = index;
if (!isNaN(index)) {
fetch.firstVisibleIndex = index;
fetch.firstVisibleItemDelta = -buffer.getSizeByIndex(index) + diff;
fetch.firstVisible.delta = -buffer.getSizeByIndex(index) + diff;
}

@@ -149,9 +151,9 @@ }

};
Remove.shiftFirstVisibleIndex = function (_a, listToRemove, increase) {
var fetch = _a.state.fetch;
if (isNaN(fetch.firstVisibleIndex)) {
Remove.shiftFirstVisibleIndex = function (scroller, listToRemove, increase) {
var firstVisible = scroller.state.fetch.firstVisible;
if (isNaN(firstVisible.index)) {
return;
}
var shift = listToRemove.reduce(function (acc, index) { return acc + (((increase && index > fetch.firstVisibleIndex) || (!increase && index < fetch.firstVisibleIndex)) ? 1 : 0); }, 0);
fetch.firstVisibleIndex = fetch.firstVisibleIndex + (increase ? shift : -shift);
var shift = listToRemove.reduce(function (acc, index) { return acc + (((increase && index > firstVisible.index) || (!increase && index < firstVisible.index)) ? 1 : 0); }, 0);
firstVisible.index = firstVisible.index + (increase ? shift : -shift);
};

@@ -158,0 +160,0 @@ return Remove;

@@ -33,3 +33,3 @@ import { __extends } from "tslib";

else {
first = !isNaN(fetch.firstVisibleIndex) ? fetch.firstVisibleIndex : buffer.startIndex;
first = !isNaN(fetch.firstVisible.index) ? fetch.firstVisible.index : buffer.startIndex;
last = first - 1;

@@ -65,15 +65,26 @@ }

Adjust.calculatePosition = function (scroller) {
var viewport = scroller.viewport, buffer = scroller.buffer, state = scroller.state;
var fetch = state.fetch, render = state.render, scrollState = state.scrollState;
var viewport = scroller.viewport, buffer = scroller.buffer, _a = scroller.state, fetch = _a.fetch, render = _a.render, scrollState = _a.scrollState;
var position = viewport.paddings.backward.size;
// backward outlet increase
if (!isNaN(fetch.firstVisibleIndex) && !isNaN(buffer.firstIndex)) {
for (var i = buffer.firstIndex; i < fetch.firstVisibleIndex; i++) {
position += buffer.getSizeByIndex(i);
}
if (fetch.firstVisibleItemDelta) {
position -= fetch.firstVisibleItemDelta;
}
// increase the position to meet the expectation of the first visible item
if (!isNaN(fetch.firstVisible.index) && !isNaN(buffer.firstIndex)) {
scroller.logger.log("first index = " + fetch.firstVisible.index + ", delta = " + fetch.firstVisible.delta);
var shouldCheckPreSizeExpectation_1 = fetch.shouldCheckPreSizeExpectation(buffer.lastIndex);
buffer.items.forEach(function (item) {
// 1) shift of the buffered items before the first visible item
if (item.$index < fetch.firstVisible.index) {
position += item.size;
return;
}
// 2) delta of the first visible item
if (item.$index === fetch.firstVisible.index && fetch.firstVisible.delta) {
position -= fetch.firstVisible.delta;
}
// 3) difference between expected and real sizes of fetched items after the first visible
if (shouldCheckPreSizeExpectation_1 && item.preSize && fetch.items.includes(item)) {
position += item.size - item.preSize;
}
});
}
else {
// todo: switch prepend to fetch.firstVisible and get rid of fetch.negativeSize
if (fetch.isPrepend && fetch.negativeSize) {

@@ -83,3 +94,3 @@ position += fetch.negativeSize;

}
// change per slow fetch/render
// slow fetch/render case
if (scrollState.positionBeforeAsync !== null) {

@@ -92,3 +103,3 @@ var diff = render.positionBefore - scrollState.positionBeforeAsync;

}
// offset increase
// increase the position due to viewport's offset
if (viewport.offset > 0 && (position || fetch.positions.before)) {

@@ -95,0 +106,0 @@ position += viewport.offset;

@@ -111,3 +111,3 @@ import { __extends, __read, __spreadArray } from "tslib";

var _a = scroller.state, fetch = _a.fetch, cycle = _a.cycle, buffer = scroller.buffer, settings = scroller.settings;
var _b = fetch.positions, relative = _b.relative, end = _b.end, first = fetch.first, last = fetch.last;
var firstVisible = fetch.firstVisible, _b = fetch.positions, relative = _b.relative, end = _b.end, first = fetch.first, last = fetch.last;
var lastIndex;

@@ -127,6 +127,6 @@ if (!buffer.defaultSize) {

position += size;
if (isNaN(fetch.firstVisibleIndex) && position > relative) {
fetch.firstVisibleIndex = index;
if (isNaN(firstVisible.index) && position > relative) {
firstVisible.index = index;
if (!cycle.innerLoop.isInitial) {
fetch.firstVisibleItemDelta = position - size - relative;
firstVisible.delta = position - size - relative;
}

@@ -133,0 +133,0 @@ }

@@ -60,3 +60,3 @@ import { __extends } from "tslib";

item.invisible = false;
item.setSize();
item.setSize(buffer.getSizeByIndex(item.$index));
buffer.cacheItem(item);

@@ -63,0 +63,0 @@ if (item.$index < fetch.minIndex) {

export default {
name: 'vscroll',
version: '1.2.1'
version: '1.3.0'
};
//# sourceMappingURL=version.js.map

@@ -28,3 +28,3 @@ import { Item } from '../item';

get(index: number): ItemCache<Data> | undefined;
getItemSize(index: number): number;
getSizeByIndex(index: number): number;
getDefaultSize(): number;

@@ -31,0 +31,0 @@ recalculateDefaultSize(): boolean;

@@ -7,2 +7,3 @@ import { Routines } from './domRoutines';

routines: Routines;
preSize: number;
size: number;

@@ -22,3 +23,3 @@ invisible: boolean;

dispose(): void;
setSize(): void;
setSize(preSize?: number): void;
hide(): void;

@@ -25,0 +26,0 @@ scrollTo(argument?: boolean | ScrollIntoViewOptions): void;

@@ -1,2 +0,2 @@

import { SizeStrategy } from '../inputs/index';
import { SizeStrategy, Direction } from '../inputs/index';
import { Settings as ISettings, DevSettings as IDevSettings, ICommonProps, ItemsProcessor } from '../interfaces/index';

@@ -18,15 +18,98 @@ export declare class Settings<Data = unknown> implements ISettings, IDevSettings {

sizeStrategy: SizeStrategy;
/**
* Development setting.
* If true, logging is enabled.
* Default value: false.
* @type {boolean}
*/
debug: boolean;
/**
* Development setting.
* If false, in-memory logging is enabled, Adapter.showLog() method should be called to print the log.
* Default value: true.
* @type {boolean}
*/
immediateLog: boolean;
/**
* Development setting.
* If true, time differences will be logged.
* Default value: false.
* @type {boolean}
*/
logTime: boolean;
/**
* Development setting.
* If true, process fire/run info will be logged.
* Default value: false.
* @type {boolean}
*/
logProcessRun: boolean;
/**
* Development setting.
* If set, scroll event handling is throttled (ms).
* Default value: 40. Minimal value: 0.
* @type {number} ms
*/
throttle: number;
/**
* Development setting.
* If set, the Workflow initialization will be postponed (ms).
* Default value: 1. Minimal value: 0.
* @type {number} ms
*/
initDelay: number;
/**
* Development setting.
* If set and the entire window is scrollable, the Workflow initialization will be postponed (ms).
* Default value: 40. Minimal value: 0.
* @type {number} ms
*/
initWindowDelay: number;
/**
* Development setting.
* If true, item's data will be cached along with item's size and index.
* Default value: false.
* @type {boolean}
*/
cacheData: boolean;
/**
* Development setting.
* If true, cache will not be flushed on reload.
* Default value: false.
* @type {boolean}
*/
cacheOnReload: boolean;
changeOverflow: boolean;
/**
* Development setting.
* If true, the viewport will receive "overflowAnchor: none" css property.
* Default value: false.
* @type {boolean}
*/
dismissOverflowAnchor: boolean;
/**
* Development setting.
* Determines the strategy of fixing the difference between estimated and real (rendered) sizes
* on scroll position adjustments. If set to 'backward', the difference is always resolved in favour of the
* backward direction: top/left content is fixed and appears in accordance with pre-render expectations.
* If set to 'forward', both directions could be used, and there is a case when bottom/right content is fixed:
* new items are to the left of the previously rendered
* and at least one previously rendered item remains.
* Default value: 'backward'. Allowed values: 'backward', 'forward'.
* @type {string}
*/
directionPriority: Direction;
/**
* Internal setting. Stores the index of the Scroller instance.
* @type {number}
*/
instanceIndex: number;
/**
* Internal setting. Stores the Workflow initialization delay based on initDelay and initWindowDelay settings.
* @type {number}
*/
initializeDelay: number;
/**
* Internal setting. Stores the viewport based on viewportElement setting (which can be element or function).
* @type {HTMLElement|null}
*/
viewport: HTMLElement | null;

@@ -33,0 +116,0 @@ constructor(settings: ISettings<Data> | undefined, devSettings: IDevSettings | undefined, instanceIndex: number);

@@ -25,3 +25,10 @@ import { Item } from '../item';

}
declare class FirstVisible {
index: number;
delta: number;
constructor();
reset(): void;
}
export declare class FetchModel {
private readonly directionPriority;
private _newItemsData;

@@ -35,4 +42,3 @@ items: Item[];

minIndex: number;
firstVisibleIndex: number;
firstVisibleItemDelta: number;
firstVisible: FirstVisible;
negativeSize: number;

@@ -45,3 +51,3 @@ direction: Direction | null;

doRemove: boolean;
constructor();
constructor(directionPriority: Direction);
reset(): void;

@@ -54,2 +60,3 @@ get newItemsData(): unknown[] | null;

get count(): number;
shouldCheckPreSizeExpectation(lastBufferedIndex: number): boolean;
startSimulate(items: Item[]): void;

@@ -56,0 +63,0 @@ stopSimulate(): void;

@@ -28,4 +28,4 @@ import { ICommonProps } from '../interfaces/index';

cacheOnReload = "cacheOnReload",
changeOverflow = "changeOverflow",
dismissOverflowAnchor = "dismissOverflowAnchor"
dismissOverflowAnchor = "dismissOverflowAnchor",
directionPriority = "directionPriority"
}

@@ -32,0 +32,0 @@ export declare const MIN: {

@@ -29,4 +29,4 @@ import { ItemsProcessor } from './adapter';

cacheOnReload?: boolean;
changeOverflow?: boolean;
dismissOverflowAnchor?: boolean;
directionPriority?: 'backward' | 'forward';
}

@@ -10,4 +10,4 @@ import { Scroller } from '../../scroller';

static removeVirtualItems(scroller: Scroller, params: AdapterRemoveOptions, sequenceOnly: boolean): boolean;
static shiftFirstVisibleIndex({ state: { fetch } }: Scroller, listToRemove: number[], increase: boolean): void;
static shiftFirstVisibleIndex(scroller: Scroller, listToRemove: number[], increase: boolean): void;
}
export {};
{
"name": "vscroll",
"version": "1.2.1",
"version": "1.3.0",
"description": "Virtual scroll engine",

@@ -5,0 +5,0 @@ "main": "dist/bundles/vscroll.umd.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc