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

vscroll-native

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vscroll-native - npm Package Compare versions

Comparing version 1.0.0-beta.3 to 1.0.0-beta.4

dist/esm2015/vscroll.js

40

dist/bundles/vscroll-native.esm5.js
/**
* vscroll-native (https://github.com/dhilt/vscroll-native) FESM5
* Version: 1.0.0-beta.3 (2021-03-20T05:46:01.218Z)
* Version: 1.0.0-beta.4 (2021-04-12T16:04:36.113Z)
* Author: Denis Hilt

@@ -12,3 +12,3 @@ * License: MIT

name: 'vscroll-native',
version: '1.0.0-beta.3'
version: '1.0.0-beta.4'
};

@@ -18,3 +18,3 @@

function WorkflowStorage() {
this.maxId = 0; // increment only!
this.maxId = 0;
this.map = new Map();

@@ -26,3 +26,3 @@ }

};
var workflow = new Workflow({
box.workflow = new Workflow({
consumer: params.consumer,

@@ -39,4 +39,5 @@ element: params.element,

});
box.workflow = workflow;
this.map.set(params.id, box);
this.maxId++;
this.map.set(this.maxId, box);
return this.maxId;
};

@@ -63,9 +64,7 @@ WorkflowStorage.prototype.getBox = function (id) {

function Scroller(element, datasource, template) {
this.id = workflowStorage.maxId++;
this.viewport = element;
this.datasource = datasource;
this.template = template;
this.prepareViewport();
workflowStorage.add({
id: this.id,
this.scrollable = element.querySelector('[data-vscroll]');
this.id = workflowStorage.add({
consumer: consumer,

@@ -80,16 +79,2 @@ element: this.scrollable,

};
Scroller.prototype.prepareViewport = function () {
while (this.viewport.firstChild) {
this.viewport.removeChild(this.viewport.firstChild);
}
this.scrollable = document.createElement('div');
this.scrollable.setAttribute('vscroll', '');
this.viewport.append(this.scrollable);
var bwdPaddingElement = document.createElement('div');
bwdPaddingElement.setAttribute('data-padding-backward', '');
var fwdPaddingElement = document.createElement('div');
fwdPaddingElement.setAttribute('data-padding-forward', '');
this.scrollable.append(bwdPaddingElement);
this.scrollable.append(fwdPaddingElement);
};
Scroller.prototype.updateViewport = function (oldItems, newItems) {

@@ -123,4 +108,6 @@ oldItems

Scroller.prototype.createItemElement = function (item) {
var element = document.createElement('div');
element.setAttribute('data-sid', item.nodeId);
var template = document.createElement('template');
template.innerHTML = this.template(item.get());
var element = template.content.childNodes[0];
element.setAttribute('data-sid', String(item.$index));
if (item.invisible) {

@@ -130,3 +117,2 @@ element.style.position = 'fixed';

}
element.innerHTML = this.template(item.get());
return element;

@@ -133,0 +119,0 @@ };

/**
* vscroll-native (https://github.com/dhilt/vscroll-native) FESM5
* Version: 1.0.0-beta.3 (2021-03-20T05:46:01.459Z)
* Version: 1.0.0-beta.4 (2021-04-12T16:04:36.358Z)
* Author: Denis Hilt

@@ -8,3 +8,3 @@ * License: MIT

import{Workflow as e,makeDatasource as t}from"vscroll";var r={name:"vscroll-native",version:"1.0.0-beta.3"},i=new(function(){function t(){this.maxId=0,this.map=new Map}return t.prototype.add=function(t){var r={items:[]},i=new e({consumer:t.consumer,element:t.element,datasource:t.datasource,run:function(e){(e.length||r.items.length)&&(t.onItemsChanged(r.items,e),r.items=e)}});r.workflow=i,this.map.set(t.id,r)},t.prototype.getBox=function(e){var t=this.map.get(e);if(!t)throw"Can't get the Workflow";return t},t.prototype.get=function(e){return this.getBox(e).workflow},t.prototype.clear=function(e){this.get(e).dispose(),this.map.delete(e)},t}()),n=function(){function e(e,t,n){this.id=i.maxId++,this.viewport=e,this.datasource=t,this.template=n,this.prepareViewport(),i.add({id:this.id,consumer:r,element:this.scrollable,datasource:this.datasource,onItemsChanged:this.updateViewport.bind(this)})}return e.prototype.dispose=function(){i.clear(this.id)},e.prototype.prepareViewport=function(){for(;this.viewport.firstChild;)this.viewport.removeChild(this.viewport.firstChild);this.scrollable=document.createElement("div"),this.scrollable.setAttribute("vscroll",""),this.viewport.append(this.scrollable);var e=document.createElement("div");e.setAttribute("data-padding-backward","");var t=document.createElement("div");t.setAttribute("data-padding-forward",""),this.scrollable.append(e),this.scrollable.append(t)},e.prototype.updateViewport=function(e,t){e.filter((function(e){return!t.includes(e)})).forEach((function(e){return e.element&&e.element.remove()}));var r=this.makeNewElements(e,t),i=r.list,n=r.before;i.forEach((function(e){return n.insertAdjacentElement("beforebegin",e)}))},e.prototype.makeNewElements=function(e,t){for(var r=i.get(this.id).scroller.viewport.paddings.forward.element,n=[],o=t.length-1;o>=0;o--){var s=t[o];if(e.includes(s)){if(n.length)break;r=s.element}else n.unshift(this.createItemElement(s))}return{before:r,list:n}},e.prototype.createItemElement=function(e){var t=document.createElement("div");return t.setAttribute("data-sid",e.nodeId),e.invisible&&(t.style.position="fixed",t.style.left="-99999px"),t.innerHTML=this.template(e.get()),t},e}(),o=t();export{o as Datasource,n as Scroller};
import{Workflow as e,makeDatasource as t}from"vscroll";var n={name:"vscroll-native",version:"1.0.0-beta.4"},r=new(function(){function t(){this.maxId=0,this.map=new Map}return t.prototype.add=function(t){var n={items:[]};return n.workflow=new e({consumer:t.consumer,element:t.element,datasource:t.datasource,run:function(e){(e.length||n.items.length)&&(t.onItemsChanged(n.items,e),n.items=e)}}),this.maxId++,this.map.set(this.maxId,n),this.maxId},t.prototype.getBox=function(e){var t=this.map.get(e);if(!t)throw"Can't get the Workflow";return t},t.prototype.get=function(e){return this.getBox(e).workflow},t.prototype.clear=function(e){this.get(e).dispose(),this.map.delete(e)},t}()),i=function(){function e(e,t,i){this.viewport=e,this.datasource=t,this.template=i,this.scrollable=e.querySelector("[data-vscroll]"),this.id=r.add({consumer:n,element:this.scrollable,datasource:this.datasource,onItemsChanged:this.updateViewport.bind(this)})}return e.prototype.dispose=function(){r.clear(this.id)},e.prototype.updateViewport=function(e,t){e.filter((function(e){return!t.includes(e)})).forEach((function(e){return e.element&&e.element.remove()}));var n=this.makeNewElements(e,t),r=n.list,i=n.before;r.forEach((function(e){return i.insertAdjacentElement("beforebegin",e)}))},e.prototype.makeNewElements=function(e,t){for(var n=r.get(this.id).scroller.viewport.paddings.forward.element,i=[],o=t.length-1;o>=0;o--){var s=t[o];if(e.includes(s)){if(i.length)break;n=s.element}else i.unshift(this.createItemElement(s))}return{before:n,list:i}},e.prototype.createItemElement=function(e){var t=document.createElement("template");t.innerHTML=this.template(e.get());var n=t.content.childNodes[0];return n.setAttribute("data-sid",String(e.$index)),e.invisible&&(n.style.position="fixed",n.style.left="-99999px"),n},e}(),o=t();export{o as Datasource,i as Scroller};
//# sourceMappingURL=vscroll-native.esm5.min.js.map
/**
* vscroll-native (https://github.com/dhilt/vscroll-native) FESM2015
* Version: 1.0.0-beta.3 (2021-03-20T05:46:01.838Z)
* Version: 1.0.0-beta.4 (2021-04-12T16:04:36.782Z)
* Author: Denis Hilt

@@ -12,3 +12,3 @@ * License: MIT

name: 'vscroll-native',
version: '1.0.0-beta.3'
version: '1.0.0-beta.4'
};

@@ -18,3 +18,3 @@

constructor() {
this.maxId = 0; // increment only!
this.maxId = 0;
this.map = new Map();

@@ -26,3 +26,3 @@ }

};
const workflow = new Workflow({
box.workflow = new Workflow({
consumer: params.consumer,

@@ -39,4 +39,5 @@ element: params.element,

});
box.workflow = workflow;
this.map.set(params.id, box);
this.maxId++;
this.map.set(this.maxId, box);
return this.maxId;
}

@@ -62,9 +63,7 @@ getBox(id) {

constructor(element, datasource, template) {
this.id = workflowStorage.maxId++;
this.viewport = element;
this.datasource = datasource;
this.template = template;
this.prepareViewport();
workflowStorage.add({
id: this.id,
this.scrollable = element.querySelector('[data-vscroll]');
this.id = workflowStorage.add({
consumer,

@@ -79,16 +78,2 @@ element: this.scrollable,

}
prepareViewport() {
while (this.viewport.firstChild) {
this.viewport.removeChild(this.viewport.firstChild);
}
this.scrollable = document.createElement('div');
this.scrollable.setAttribute('vscroll', '');
this.viewport.append(this.scrollable);
const bwdPaddingElement = document.createElement('div');
bwdPaddingElement.setAttribute('data-padding-backward', '');
const fwdPaddingElement = document.createElement('div');
fwdPaddingElement.setAttribute('data-padding-forward', '');
this.scrollable.append(bwdPaddingElement);
this.scrollable.append(fwdPaddingElement);
}
updateViewport(oldItems, newItems) {

@@ -120,4 +105,6 @@ oldItems

createItemElement(item) {
const element = document.createElement('div');
element.setAttribute('data-sid', item.nodeId);
const template = document.createElement('template');
template.innerHTML = this.template(item.get());
const element = template.content.childNodes[0];
element.setAttribute('data-sid', String(item.$index));
if (item.invisible) {

@@ -127,3 +114,2 @@ element.style.position = 'fixed';

}
element.innerHTML = this.template(item.get());
return element;

@@ -130,0 +116,0 @@ }

/**
* vscroll-native (https://github.com/dhilt/vscroll-native) FESM2015
* Version: 1.0.0-beta.3 (2021-03-20T05:46:02.065Z)
* Version: 1.0.0-beta.4 (2021-04-12T16:04:37.077Z)
* Author: Denis Hilt

@@ -8,3 +8,3 @@ * License: MIT

import{Workflow as e,makeDatasource as t}from"vscroll";var s={name:"vscroll-native",version:"1.0.0-beta.3"};const i=new class{constructor(){this.maxId=0,this.map=new Map}add(t){const s={items:[]},i=new e({consumer:t.consumer,element:t.element,datasource:t.datasource,run:e=>{(e.length||s.items.length)&&(t.onItemsChanged(s.items,e),s.items=e)}});s.workflow=i,this.map.set(t.id,s)}getBox(e){const t=this.map.get(e);if(!t)throw"Can't get the Workflow";return t}get(e){return this.getBox(e).workflow}clear(e){this.get(e).dispose(),this.map.delete(e)}};class r{constructor(e,t,r){this.id=i.maxId++,this.viewport=e,this.datasource=t,this.template=r,this.prepareViewport(),i.add({id:this.id,consumer:s,element:this.scrollable,datasource:this.datasource,onItemsChanged:this.updateViewport.bind(this)})}dispose(){i.clear(this.id)}prepareViewport(){for(;this.viewport.firstChild;)this.viewport.removeChild(this.viewport.firstChild);this.scrollable=document.createElement("div"),this.scrollable.setAttribute("vscroll",""),this.viewport.append(this.scrollable);const e=document.createElement("div");e.setAttribute("data-padding-backward","");const t=document.createElement("div");t.setAttribute("data-padding-forward",""),this.scrollable.append(e),this.scrollable.append(t)}updateViewport(e,t){e.filter((e=>!t.includes(e))).forEach((e=>e.element&&e.element.remove()));const{list:s,before:i}=this.makeNewElements(e,t);s.forEach((e=>i.insertAdjacentElement("beforebegin",e)))}makeNewElements(e,t){let s=i.get(this.id).scroller.viewport.paddings.forward.element;const r=[];for(let i=t.length-1;i>=0;i--){const o=t[i];if(e.includes(o)){if(r.length)break;s=o.element}else r.unshift(this.createItemElement(o))}return{before:s,list:r}}createItemElement(e){const t=document.createElement("div");return t.setAttribute("data-sid",e.nodeId),e.invisible&&(t.style.position="fixed",t.style.left="-99999px"),t.innerHTML=this.template(e.get()),t}}const o=t();export{o as Datasource,r as Scroller};
import{Workflow as e,makeDatasource as t}from"vscroll";var s={name:"vscroll-native",version:"1.0.0-beta.4"};const i=new class{constructor(){this.maxId=0,this.map=new Map}add(t){const s={items:[]};return s.workflow=new e({consumer:t.consumer,element:t.element,datasource:t.datasource,run:e=>{(e.length||s.items.length)&&(t.onItemsChanged(s.items,e),s.items=e)}}),this.maxId++,this.map.set(this.maxId,s),this.maxId}getBox(e){const t=this.map.get(e);if(!t)throw"Can't get the Workflow";return t}get(e){return this.getBox(e).workflow}clear(e){this.get(e).dispose(),this.map.delete(e)}};class n{constructor(e,t,n){this.viewport=e,this.datasource=t,this.template=n,this.scrollable=e.querySelector("[data-vscroll]"),this.id=i.add({consumer:s,element:this.scrollable,datasource:this.datasource,onItemsChanged:this.updateViewport.bind(this)})}dispose(){i.clear(this.id)}updateViewport(e,t){e.filter((e=>!t.includes(e))).forEach((e=>e.element&&e.element.remove()));const{list:s,before:i}=this.makeNewElements(e,t);s.forEach((e=>i.insertAdjacentElement("beforebegin",e)))}makeNewElements(e,t){let s=i.get(this.id).scroller.viewport.paddings.forward.element;const n=[];for(let i=t.length-1;i>=0;i--){const r=t[i];if(e.includes(r)){if(n.length)break;s=r.element}else n.unshift(this.createItemElement(r))}return{before:s,list:n}}createItemElement(e){const t=document.createElement("template");t.innerHTML=this.template(e.get());const s=t.content.childNodes[0];return s.setAttribute("data-sid",String(e.$index)),e.invisible&&(s.style.position="fixed",s.style.left="-99999px"),s}}const r=t();export{r as Datasource,n as Scroller};
//# sourceMappingURL=vscroll-native.esm6.min.js.map

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

import { makeDatasource, } from 'vscroll';
import { makeDatasource, } from './vscroll';
import { Scroller } from './vscroll-native';

@@ -3,0 +3,0 @@ const Datasource = makeDatasource();

export default {
name: 'vscroll-native',
version: '1.0.0-beta.3'
version: '1.0.0-beta.4'
};
//# sourceMappingURL=version.js.map

@@ -5,9 +5,7 @@ import consumer from './version';

constructor(element, datasource, template) {
this.id = workflowStorage.maxId++;
this.viewport = element;
this.datasource = datasource;
this.template = template;
this.prepareViewport();
workflowStorage.add({
id: this.id,
this.scrollable = element.querySelector('[data-vscroll]');
this.id = workflowStorage.add({
consumer,

@@ -22,16 +20,2 @@ element: this.scrollable,

}
prepareViewport() {
while (this.viewport.firstChild) {
this.viewport.removeChild(this.viewport.firstChild);
}
this.scrollable = document.createElement('div');
this.scrollable.setAttribute('vscroll', '');
this.viewport.append(this.scrollable);
const bwdPaddingElement = document.createElement('div');
bwdPaddingElement.setAttribute('data-padding-backward', '');
const fwdPaddingElement = document.createElement('div');
fwdPaddingElement.setAttribute('data-padding-forward', '');
this.scrollable.append(bwdPaddingElement);
this.scrollable.append(fwdPaddingElement);
}
updateViewport(oldItems, newItems) {

@@ -63,4 +47,6 @@ oldItems

createItemElement(item) {
const element = document.createElement('div');
element.setAttribute('data-sid', item.nodeId);
const template = document.createElement('template');
template.innerHTML = this.template(item.get());
const element = template.content.childNodes[0];
element.setAttribute('data-sid', String(item.$index));
if (item.invisible) {

@@ -70,3 +56,2 @@ element.style.position = 'fixed';

}
element.innerHTML = this.template(item.get());
return element;

@@ -73,0 +58,0 @@ }

@@ -1,5 +0,5 @@

import { Workflow } from 'vscroll';
import { Workflow } from './vscroll';
class WorkflowStorage {
constructor() {
this.maxId = 0; // increment only!
this.maxId = 0;
this.map = new Map();

@@ -11,3 +11,3 @@ }

};
const workflow = new Workflow({
box.workflow = new Workflow({
consumer: params.consumer,

@@ -24,4 +24,5 @@ element: params.element,

});
box.workflow = workflow;
this.map.set(params.id, box);
this.maxId++;
this.map.set(this.maxId, box);
return this.maxId;
}

@@ -28,0 +29,0 @@ getBox(id) {

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

import { makeDatasource, } from 'vscroll';
import { makeDatasource, } from './vscroll';
import { Scroller } from './vscroll-native';

@@ -3,0 +3,0 @@ var Datasource = makeDatasource();

export default {
name: 'vscroll-native',
version: '1.0.0-beta.3'
version: '1.0.0-beta.4'
};
//# sourceMappingURL=version.js.map

@@ -5,9 +5,7 @@ import consumer from './version';

function Scroller(element, datasource, template) {
this.id = workflowStorage.maxId++;
this.viewport = element;
this.datasource = datasource;
this.template = template;
this.prepareViewport();
workflowStorage.add({
id: this.id,
this.scrollable = element.querySelector('[data-vscroll]');
this.id = workflowStorage.add({
consumer: consumer,

@@ -22,16 +20,2 @@ element: this.scrollable,

};
Scroller.prototype.prepareViewport = function () {
while (this.viewport.firstChild) {
this.viewport.removeChild(this.viewport.firstChild);
}
this.scrollable = document.createElement('div');
this.scrollable.setAttribute('vscroll', '');
this.viewport.append(this.scrollable);
var bwdPaddingElement = document.createElement('div');
bwdPaddingElement.setAttribute('data-padding-backward', '');
var fwdPaddingElement = document.createElement('div');
fwdPaddingElement.setAttribute('data-padding-forward', '');
this.scrollable.append(bwdPaddingElement);
this.scrollable.append(fwdPaddingElement);
};
Scroller.prototype.updateViewport = function (oldItems, newItems) {

@@ -65,4 +49,6 @@ oldItems

Scroller.prototype.createItemElement = function (item) {
var element = document.createElement('div');
element.setAttribute('data-sid', item.nodeId);
var template = document.createElement('template');
template.innerHTML = this.template(item.get());
var element = template.content.childNodes[0];
element.setAttribute('data-sid', String(item.$index));
if (item.invisible) {

@@ -72,3 +58,2 @@ element.style.position = 'fixed';

}
element.innerHTML = this.template(item.get());
return element;

@@ -75,0 +60,0 @@ };

@@ -1,5 +0,5 @@

import { Workflow } from 'vscroll';
import { Workflow } from './vscroll';
var WorkflowStorage = /** @class */ (function () {
function WorkflowStorage() {
this.maxId = 0; // increment only!
this.maxId = 0;
this.map = new Map();

@@ -11,3 +11,3 @@ }

};
var workflow = new Workflow({
box.workflow = new Workflow({
consumer: params.consumer,

@@ -24,4 +24,5 @@ element: params.element,

});
box.workflow = workflow;
this.map.set(params.id, box);
this.maxId++;
this.map.set(this.maxId, box);
return this.maxId;
};

@@ -28,0 +29,0 @@ WorkflowStorage.prototype.getBox = function (id) {

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

import { IDatasource, IAdapter } from 'vscroll';
import { IDatasource, IAdapter } from './vscroll';
import { Scroller, Template } from './vscroll-native';

@@ -3,0 +3,0 @@ declare const Datasource: new <Data = unknown>(datasource: IDatasource<Data>) => {

@@ -1,19 +0,18 @@

import { IDatasource, Item, IAdapterItem } from 'vscroll';
import { IDatasource, Item, IAdapterItem } from './vscroll';
import { Id } from './workflow-storage';
export declare type Template<MyItem = unknown> = (item: IAdapterItem<MyItem>) => string;
export declare class Scroller<MyItem = unknown> {
export declare type Template<Data = unknown> = (item: IAdapterItem<Data>) => string;
export declare class Scroller<Data = unknown> {
id: Id;
viewport: HTMLElement;
datasource: IDatasource<MyItem>;
template: Template<MyItem>;
datasource: IDatasource<Data>;
template: Template<Data>;
scrollable: HTMLElement;
constructor(element: HTMLElement, datasource: IDatasource<MyItem>, template: Template<MyItem>);
constructor(element: HTMLElement, datasource: IDatasource<Data>, template: Template<Data>);
dispose(): void;
prepareViewport(): void;
updateViewport(oldItems: Item[], newItems: Item[]): void;
makeNewElements(oldItems: Item<MyItem>[], newItems: Item<MyItem>[]): {
makeNewElements(oldItems: Item<Data>[], newItems: Item<Data>[]): {
list: HTMLElement[];
before: HTMLElement;
};
createItemElement(item: Item<MyItem>): HTMLElement;
createItemElement(item: Item<Data>): HTMLElement;
}

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

import { Workflow, Item } from 'vscroll';
import { Workflow, Item } from './vscroll';
export declare type Id = number;

@@ -9,3 +9,2 @@ interface WorkflowBox {

interface MyWorkflowParams extends Omit<WorkflowParams, 'run'> {
id: Id;
onItemsChanged: (oldItems: Item[], newItems: Item[]) => void;

@@ -16,3 +15,3 @@ }

map: Map<Id, WorkflowBox>;
add(params: MyWorkflowParams): void;
add(params: MyWorkflowParams): Id;
getBox(id: Id): WorkflowBox;

@@ -19,0 +18,0 @@ get<MyItem>(id: Id): Workflow<MyItem>;

{
"name": "vscroll-native",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.4",
"description": "Virtual scroll module for native javascript applications",

@@ -32,6 +32,7 @@ "main": "dist/bundles/vscroll-native.umd.js",

"test": "npm run lint && npm run jest:singlerun",
"prepare": "npm run test && npm run build"
"prepublishOnly": "npm run test",
"prepack": "npm run build"
},
"dependencies": {
"vscroll": "^1.0.0-rc.8"
"vscroll": "^1.0.0"
},

@@ -38,0 +39,0 @@ "devDependencies": {

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 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

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