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.4.0-beta to 1.4.0-beta.1

5

dist/esm2015/classes/buffer.js

@@ -151,2 +151,5 @@ import { Cache } from './buffer/cache';

}
getIndexToInsert(predicate, before, after) {
return this.checkCall.insertInBuffer(predicate, before, after);
}
shiftExtremum(amount, fixRight) {

@@ -184,3 +187,3 @@ if (!fixRight) {

insertVirtually(items, index, direction, fixRight) {
if (!this.checkCall.insert(items, index, direction)) {
if (!this.checkCall.insertVirtual(items, index, direction)) {
return false;

@@ -187,0 +190,0 @@ }

12

dist/esm2015/classes/buffer/checkCall.js

@@ -7,3 +7,13 @@ import { Direction } from '../../inputs/index';

}
insert(items, index, direction) {
insertInBuffer(predicate, before, after) {
const index = Number.isInteger(before) ? before : (Number.isInteger(after) ? after : NaN);
const found = this.context.items.find(item => (predicate && predicate(item.get())) ||
(Number.isInteger(index) && index === item.$index));
if (!found) {
this.logger.log('no item to insert in buffer');
return NaN;
}
return found.$index;
}
insertVirtual(items, index, direction) {
if (!items.length) {

@@ -10,0 +20,0 @@ this.logger.log('no items to insert virtually; empty list');

import { Item } from '../../classes/item';
import Update from './update';
import { BaseAdapterProcessFactory, AdapterProcess, ProcessStatus } from '../misc/index';
import { Direction } from '../../inputs/index';
export default class Append extends BaseAdapterProcessFactory(AdapterProcess.append) {

@@ -10,40 +11,47 @@ static run(scroller, { process, options }) {

}
const shouldAppend = Append.doAppend(scroller, params, process !== AdapterProcess.append);
scroller.workflow.call({
process: Append.process,
status: shouldAppend ? ProcessStatus.next : ProcessStatus.done
});
}
static doAppend(scroller, params, prepend) {
const { buffer } = scroller;
const { items, bof, eof, increase, decrease } = params;
const prepend = process !== AdapterProcess.append;
const fixRight = (prepend && !increase) || (!prepend && !!decrease);
let next = false;
let result = false;
if ((prepend && bof && !buffer.bof.get()) || (!prepend && eof && !buffer.eof.get())) {
Append.doVirtual(scroller, items, prepend, fixRight);
result = Append.doVirtual(scroller, items, prepend, fixRight);
}
else {
if (!buffer.size) {
next = Append.doEmpty(scroller, items, prepend, fixRight);
result = Append.doEmpty(scroller, items, prepend, fixRight);
}
else {
next = Append.doRegular(scroller, items, prepend, fixRight);
result = Append.doRegular(scroller, items, prepend, fixRight);
}
}
scroller.workflow.call({
process: Append.process,
status: next ? ProcessStatus.next : ProcessStatus.done
});
return result;
}
static doVirtual(scroller, items, prepend, fixRight) {
const { buffer, viewport: { paddings } } = scroller;
const { buffer, logger, viewport, state: { fetch } } = scroller;
const absIndexToken = fixRight ? 'absMinIndex' : 'absMaxIndex';
if (isFinite(buffer[absIndexToken])) {
const size = items.length * buffer.defaultSize;
const padding = prepend ? paddings.backward : paddings.forward;
padding.size += size;
if (prepend) {
buffer.prependVirtually(items.length, fixRight);
scroller.viewport.scrollPosition += size;
}
else {
buffer.appendVirtually(items.length, fixRight);
}
scroller.logger.log(() => `buffer.${[absIndexToken]} value is set to ${buffer[absIndexToken]}`);
scroller.logger.stat(`after virtual ${prepend ? 'prepend' : 'append'}`);
if (!isFinite(buffer[absIndexToken])) {
return false;
}
if (prepend) {
buffer.prependVirtually(items.length, fixRight);
}
else {
buffer.appendVirtually(items.length, fixRight);
}
const { index, diff } = viewport.getEdgeVisibleItem(buffer.items, Direction.backward);
fetch.firstVisible.index = index;
if (!isNaN(index)) {
fetch.simulate = true;
fetch.firstVisible.delta = -buffer.getSizeByIndex(index) + diff;
}
logger.log(() => `buffer.${[absIndexToken]} value is set to ${buffer[absIndexToken]}`);
logger.stat(`after virtual ${prepend ? 'prepend' : 'append'}`);
return true;
}

@@ -56,3 +64,3 @@ static doEmpty(scroller, items, prepend, fixRight) {

const newItems = [];
const startIndex = scroller.buffer[prepend ? 'minIndex' : 'maxIndex'];
const startIndex = buffer[prepend ? 'minIndex' : 'maxIndex'];
let index = startIndex;

@@ -59,0 +67,0 @@ items.forEach(item => {

@@ -26,11 +26,7 @@ import Update from './update';

const { before, after, beforeIndex, afterIndex, items, decrease } = params;
const index = Number.isInteger(beforeIndex) ? beforeIndex : (Number.isInteger(afterIndex) ? afterIndex : NaN);
const isBackward = Number.isInteger(beforeIndex) || before;
const method = before || after;
const found = scroller.buffer.items.find(item => (method && method(item.get())) || (Number.isInteger(index) && index === item.$index));
if (!found) {
scroller.logger.log('no item to insert in buffer');
const indexToInsert = scroller.buffer.getIndexToInsert(before || after, beforeIndex, afterIndex);
if (isNaN(indexToInsert)) {
return false;
}
const indexToInsert = found.$index;
const isBackward = Number.isInteger(beforeIndex) || before;
const updateOptions = {

@@ -51,23 +47,11 @@ predicate: ({ $index, data }) => {

const direction = Number.isInteger(beforeIndex) ? Direction.backward : Direction.forward;
const index = (direction === Direction.backward ? beforeIndex : afterIndex);
if (isNaN(fetch.firstVisible.index)) { // if in-buffer insertion did not set firstVisible
const { index, diff } = viewport.getEdgeVisibleItem(buffer.items, Direction.backward);
fetch.firstVisible.index = index;
if (!isNaN(index)) {
fetch.firstVisible.delta = -buffer.getSizeByIndex(index) + diff;
}
}
if (!buffer.insertVirtually(items, index, direction, !!decrease)) {
const indexToInsert = (direction === Direction.backward ? beforeIndex : afterIndex);
if (!buffer.insertVirtually(items, indexToInsert, direction, !!decrease)) {
return false;
}
const { firstVisible } = scroller.state.fetch;
if (!isNaN(firstVisible.index)) {
let shift = 0;
if (index < firstVisible.index && !decrease) {
shift = items.length;
}
else if (index > firstVisible.index && decrease) {
shift = -items.length;
}
firstVisible.index += shift;
const { index, diff } = viewport.getEdgeVisibleItem(buffer.items, Direction.backward);
fetch.firstVisible.index = index;
if (!isNaN(index)) {
fetch.simulate = true;
fetch.firstVisible.delta = -buffer.getSizeByIndex(index) + diff;
}

@@ -74,0 +58,0 @@ return true;

export default {
name: 'vscroll',
version: '1.4.0-beta'
version: '1.4.0-beta.1'
};
//# sourceMappingURL=version.js.map

@@ -116,9 +116,3 @@ import { CommonProcess, AdapterProcess, ProcessStatus as Status, Init, Scroll, Reset, Reload, Append, Check, Remove, UserClip, Insert, Replace, Update, Fix, Start, PreFetch, Fetch, PostFetch, Render, PreClip, Clip, Adjust, End, } from './processes/index';

case AdapterProcess.append:
case AdapterProcess.check:
case AdapterProcess.insert:
run(Render)();
break;
case AdapterProcess.remove:
run(Adjust)();
break;
case AdapterProcess.replace:

@@ -133,2 +127,8 @@ case AdapterProcess.update:

break;
case AdapterProcess.check:
run(Render)();
break;
case AdapterProcess.remove:
run(Adjust)();
break;
default:

@@ -135,0 +135,0 @@ run(PreFetch)();

@@ -203,2 +203,5 @@ import { __read, __spreadArray } from "tslib";

};
Buffer.prototype.getIndexToInsert = function (predicate, before, after) {
return this.checkCall.insertInBuffer(predicate, before, after);
};
Buffer.prototype.shiftExtremum = function (amount, fixRight) {

@@ -236,3 +239,3 @@ if (!fixRight) {

Buffer.prototype.insertVirtually = function (items, index, direction, fixRight) {
if (!this.checkCall.insert(items, index, direction)) {
if (!this.checkCall.insertVirtual(items, index, direction)) {
return false;

@@ -239,0 +242,0 @@ }

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

}
CheckBufferCall.prototype.insert = function (items, index, direction) {
CheckBufferCall.prototype.insertInBuffer = function (predicate, before, after) {
var index = Number.isInteger(before) ? before : (Number.isInteger(after) ? after : NaN);
var found = this.context.items.find(function (item) {
return (predicate && predicate(item.get())) ||
(Number.isInteger(index) && index === item.$index);
});
if (!found) {
this.logger.log('no item to insert in buffer');
return NaN;
}
return found.$index;
};
CheckBufferCall.prototype.insertVirtual = function (items, index, direction) {
if (!items.length) {

@@ -10,0 +22,0 @@ this.logger.log('no items to insert virtually; empty list');

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

import { BaseAdapterProcessFactory, AdapterProcess, ProcessStatus } from '../misc/index';
import { Direction } from '../../inputs/index';
var Append = /** @class */ (function (_super) {

@@ -17,40 +18,47 @@ __extends(Append, _super);

}
var shouldAppend = Append.doAppend(scroller, params, process !== AdapterProcess.append);
scroller.workflow.call({
process: Append.process,
status: shouldAppend ? ProcessStatus.next : ProcessStatus.done
});
};
Append.doAppend = function (scroller, params, prepend) {
var buffer = scroller.buffer;
var items = params.items, bof = params.bof, eof = params.eof, increase = params.increase, decrease = params.decrease;
var prepend = process !== AdapterProcess.append;
var fixRight = (prepend && !increase) || (!prepend && !!decrease);
var next = false;
var result = false;
if ((prepend && bof && !buffer.bof.get()) || (!prepend && eof && !buffer.eof.get())) {
Append.doVirtual(scroller, items, prepend, fixRight);
result = Append.doVirtual(scroller, items, prepend, fixRight);
}
else {
if (!buffer.size) {
next = Append.doEmpty(scroller, items, prepend, fixRight);
result = Append.doEmpty(scroller, items, prepend, fixRight);
}
else {
next = Append.doRegular(scroller, items, prepend, fixRight);
result = Append.doRegular(scroller, items, prepend, fixRight);
}
}
scroller.workflow.call({
process: Append.process,
status: next ? ProcessStatus.next : ProcessStatus.done
});
return result;
};
Append.doVirtual = function (scroller, items, prepend, fixRight) {
var buffer = scroller.buffer, paddings = scroller.viewport.paddings;
var buffer = scroller.buffer, logger = scroller.logger, viewport = scroller.viewport, fetch = scroller.state.fetch;
var absIndexToken = fixRight ? 'absMinIndex' : 'absMaxIndex';
if (isFinite(buffer[absIndexToken])) {
var size = items.length * buffer.defaultSize;
var padding = prepend ? paddings.backward : paddings.forward;
padding.size += size;
if (prepend) {
buffer.prependVirtually(items.length, fixRight);
scroller.viewport.scrollPosition += size;
}
else {
buffer.appendVirtually(items.length, fixRight);
}
scroller.logger.log(function () { return "buffer." + [absIndexToken] + " value is set to " + buffer[absIndexToken]; });
scroller.logger.stat("after virtual " + (prepend ? 'prepend' : 'append'));
if (!isFinite(buffer[absIndexToken])) {
return false;
}
if (prepend) {
buffer.prependVirtually(items.length, fixRight);
}
else {
buffer.appendVirtually(items.length, fixRight);
}
var _a = viewport.getEdgeVisibleItem(buffer.items, Direction.backward), index = _a.index, diff = _a.diff;
fetch.firstVisible.index = index;
if (!isNaN(index)) {
fetch.simulate = true;
fetch.firstVisible.delta = -buffer.getSizeByIndex(index) + diff;
}
logger.log(function () { return "buffer." + [absIndexToken] + " value is set to " + buffer[absIndexToken]; });
logger.stat("after virtual " + (prepend ? 'prepend' : 'append'));
return true;
};

@@ -63,3 +71,3 @@ Append.doEmpty = function (scroller, items, prepend, fixRight) {

var newItems = [];
var startIndex = scroller.buffer[prepend ? 'minIndex' : 'maxIndex'];
var startIndex = buffer[prepend ? 'minIndex' : 'maxIndex'];
var index = startIndex;

@@ -66,0 +74,0 @@ items.forEach(function (item) {

@@ -31,13 +31,7 @@ import { __extends, __read, __spreadArray } from "tslib";

var before = params.before, after = params.after, beforeIndex = params.beforeIndex, afterIndex = params.afterIndex, items = params.items, decrease = params.decrease;
var index = Number.isInteger(beforeIndex) ? beforeIndex : (Number.isInteger(afterIndex) ? afterIndex : NaN);
var isBackward = Number.isInteger(beforeIndex) || before;
var method = before || after;
var found = scroller.buffer.items.find(function (item) {
return (method && method(item.get())) || (Number.isInteger(index) && index === item.$index);
});
if (!found) {
scroller.logger.log('no item to insert in buffer');
var indexToInsert = scroller.buffer.getIndexToInsert(before || after, beforeIndex, afterIndex);
if (isNaN(indexToInsert)) {
return false;
}
var indexToInsert = found.$index;
var isBackward = Number.isInteger(beforeIndex) || before;
var updateOptions = {

@@ -59,23 +53,11 @@ predicate: function (_a) {

var direction = Number.isInteger(beforeIndex) ? Direction.backward : Direction.forward;
var index = (direction === Direction.backward ? beforeIndex : afterIndex);
if (isNaN(fetch.firstVisible.index)) { // if in-buffer insertion did not set firstVisible
var _a = viewport.getEdgeVisibleItem(buffer.items, Direction.backward), index_1 = _a.index, diff = _a.diff;
fetch.firstVisible.index = index_1;
if (!isNaN(index_1)) {
fetch.firstVisible.delta = -buffer.getSizeByIndex(index_1) + diff;
}
}
if (!buffer.insertVirtually(items, index, direction, !!decrease)) {
var indexToInsert = (direction === Direction.backward ? beforeIndex : afterIndex);
if (!buffer.insertVirtually(items, indexToInsert, direction, !!decrease)) {
return false;
}
var firstVisible = scroller.state.fetch.firstVisible;
if (!isNaN(firstVisible.index)) {
var shift = 0;
if (index < firstVisible.index && !decrease) {
shift = items.length;
}
else if (index > firstVisible.index && decrease) {
shift = -items.length;
}
firstVisible.index += shift;
var _a = viewport.getEdgeVisibleItem(buffer.items, Direction.backward), index = _a.index, diff = _a.diff;
fetch.firstVisible.index = index;
if (!isNaN(index)) {
fetch.simulate = true;
fetch.firstVisible.delta = -buffer.getSizeByIndex(index) + diff;
}

@@ -82,0 +64,0 @@ return true;

export default {
name: 'vscroll',
version: '1.4.0-beta'
version: '1.4.0-beta.1'
};
//# sourceMappingURL=version.js.map

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

case AdapterProcess.append:
case AdapterProcess.check:
case AdapterProcess.insert:
run(Render)();
break;
case AdapterProcess.remove:
run(Adjust)();
break;
case AdapterProcess.replace:

@@ -135,2 +129,8 @@ case AdapterProcess.update:

break;
case AdapterProcess.check:
run(Render)();
break;
case AdapterProcess.remove:
run(Adjust)();
break;
default:

@@ -137,0 +137,0 @@ run(PreFetch)();

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

import { Direction } from '../inputs/index';
import { OnDataChanged, BufferUpdater } from '../interfaces/index';
import { OnDataChanged, BufferUpdater, ItemsPredicate } from '../interfaces/index';
export declare class Buffer<Data> {

@@ -47,2 +47,3 @@ private _items;

clip(): void;
getIndexToInsert(predicate?: ItemsPredicate, before?: number, after?: number): number;
private shiftExtremum;

@@ -49,0 +50,0 @@ appendVirtually(count: number, fixRight: boolean): void;

import { Buffer } from '../buffer';
import { Logger } from '../logger';
import { Direction } from '../../inputs/index';
import { ItemsPredicate } from '../../interfaces/index';
export declare class CheckBufferCall<Data> {

@@ -8,3 +9,4 @@ private context;

constructor(context: Buffer<Data>, logger: Logger);
insert(items: Data[], index: number, direction: Direction): boolean;
insertInBuffer(predicate?: ItemsPredicate, before?: number, after?: number): number;
insertVirtual(items: Data[], index: number, direction: Direction): boolean;
}

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

static run(scroller: Scroller, { process, options }: AppendRunOptions): void;
static doVirtual(scroller: Scroller, items: unknown[], prepend: boolean, fixRight: boolean): void;
static doAppend(scroller: Scroller, params: AdapterAppendPrependOptions, prepend: boolean): boolean;
static doVirtual(scroller: Scroller, items: unknown[], prepend: boolean, fixRight: boolean): boolean;
static doEmpty(scroller: Scroller, items: unknown[], prepend: boolean, fixRight: boolean): boolean;

@@ -15,0 +16,0 @@ static doRegular(scroller: Scroller, items: unknown[], prepend: boolean, fixRight: boolean): boolean;

{
"name": "vscroll",
"version": "1.4.0-beta",
"version": "1.4.0-beta.1",
"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

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