New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nativescript-parallax

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nativescript-parallax - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

215

nativescript-parallax.common.js

@@ -60,4 +60,2 @@ "use strict";

var invalidSetup = false;
this.addRow(row);
this.addColumn(column);
this.verticalAlignment = 'top';

@@ -67,113 +65,98 @@ scrollView.verticalAlignment = 'top';

this._includesAnchored = false;
this._topOpacity = 1;
this._loaded = false;
this.on(_gridLayout.GridLayout.loadedEvent, function (data) {
_this.addChild(scrollView);
_this.addChild(anchoredRow);
_gridLayout.GridLayout.setRow(scrollView, 1);
_gridLayout.GridLayout.setRow(anchoredRow, 0);
_gridLayout.GridLayout.setColumn(scrollView, 1);
_gridLayout.GridLayout.setColumn(anchoredRow, 0);
var wrapperStackLayout = new _stackLayout.StackLayout();
scrollView.content = wrapperStackLayout;
_this._childLayouts.forEach(function (element) {
if (element instanceof Header) {
wrapperStackLayout.addChild(element);
headerView = element;
if (!_this._loaded) {
_this._loaded = true;
_this.addRow(row);
_this.addColumn(column);
_this.addChild(scrollView);
_this.addChild(anchoredRow);
_gridLayout.GridLayout.setRow(scrollView, 1);
_gridLayout.GridLayout.setRow(anchoredRow, 0);
_gridLayout.GridLayout.setColumn(scrollView, 1);
_gridLayout.GridLayout.setColumn(anchoredRow, 0);
var wrapperStackLayout_1 = new _stackLayout.StackLayout();
scrollView.content = wrapperStackLayout_1;
_this._childLayouts.forEach(function (element) {
if (element instanceof Header) {
wrapperStackLayout_1.addChild(element);
headerView = element;
}
});
_this._childLayouts.forEach(function (element) {
if (element instanceof Content) {
wrapperStackLayout_1.addChild(element);
contentView = element;
}
});
_this._childLayouts.forEach(function (element) {
if (element instanceof Anchored) {
anchoredRow.addChild(element);
anchoredRow.height = element.height;
_this._includesAnchored = true;
}
});
if (headerView == null || contentView == null) {
var warningText = new _label.Label();
warningText.text = "Parallax ScrollView Setup Invalid. You must have Header and Content tags";
warningText.color = new _color.Color('red');
warningText.textWrap = true;
warningText.marginTop = 50;
_this.addChild(warningText);
if (headerView != null) {
headerView.visibility = 'collapse';
}
if (contentView != null) {
contentView.visibility = 'collapse';
return;
}
}
});
_this._childLayouts.forEach(function (element) {
if (element instanceof Content) {
wrapperStackLayout.addChild(element);
contentView = element;
maxTopViewHeight = headerView.height;
if (_this._includesAnchored) {
anchoredRow.marginTop = maxTopViewHeight;
if (app.android) {
anchoredRow.marginTop = anchoredRow.marginTop - 5;
}
contentView.marginTop = anchoredRow.height;
}
});
_this._childLayouts.forEach(function (element) {
if (element instanceof Anchored) {
anchoredRow.addChild(element);
anchoredRow.height = element.height;
_this._includesAnchored = true;
viewsToFade = [];
if (controlsToFade == null && _this.controlsToFade == null) {
controlsToFade = [];
}
});
if (headerView == null || contentView == null) {
var warningText = new _label.Label();
warningText.text = "Parallax ScrollView Setup Invalid. You must have Header and Content tags";
warningText.color = new _color.Color('red');
warningText.textWrap = true;
warningText.marginTop = 50;
_this.addChild(warningText);
if (headerView != null) {
headerView.visibility = 'collapse';
else {
controlsToFade = _this.controlsToFade.split(',');
}
if (contentView != null) {
contentView.visibility = 'collapse';
maxTopViewHeight = headerView.height;
controlsToFade.forEach(function (id) {
var newView = headerView.getViewById(id);
if (newView != null) {
viewsToFade.push(newView);
}
});
if (headerView == null) {
return;
}
}
maxTopViewHeight = headerView.height;
if (_this._includesAnchored) {
anchoredRow.marginTop = maxTopViewHeight;
if (app.android) {
anchoredRow.marginTop = anchoredRow.marginTop - 5;
}
contentView.marginTop = anchoredRow.height;
}
viewsToFade = [];
if (controlsToFade == null && _this.controlsToFade == null) {
controlsToFade = [];
}
else {
controlsToFade = _this.controlsToFade.split(',');
}
maxTopViewHeight = headerView.height;
controlsToFade.forEach(function (id) {
var newView = headerView.getViewById(id);
if (newView != null) {
viewsToFade.push(newView);
}
});
if (headerView == null) {
return;
}
headerView.height = maxTopViewHeight;
scrollView.on(_scrollViewModule.ScrollView.loadedEvent, function (data) {
});
var prevOffset = -10;
var topOpacity = 1;
scrollView.on(_scrollViewModule.ScrollView.scrollEvent, function (args) {
if (prevOffset <= scrollView.verticalOffset) {
if (headerView.height >= 0) {
headerView.height = _this.getTopViewHeight(maxTopViewHeight, scrollView.verticalOffset);
}
}
else {
if (headerView.height <= maxTopViewHeight) {
headerView.height = _this.getTopViewHeight(maxTopViewHeight, scrollView.verticalOffset);
}
}
if (_this._includesAnchored) {
if (scrollView.verticalOffset <= maxTopViewHeight) {
anchoredRow.marginTop = maxTopViewHeight - (scrollView.verticalOffset * 2);
if (anchoredRow.marginTop > maxTopViewHeight) {
anchoredRow.marginTop = maxTopViewHeight;
headerView.height = maxTopViewHeight;
scrollView.on(_scrollViewModule.ScrollView.loadedEvent, function (data) {
});
var prevOffset_1 = -10;
scrollView.on(_scrollViewModule.ScrollView.scrollEvent, function (args) {
if (prevOffset_1 <= scrollView.verticalOffset) {
if (headerView.height >= 0) {
headerView.height = _this.getTopViewHeight(maxTopViewHeight, scrollView.verticalOffset);
}
if (app.android) {
anchoredRow.marginTop = anchoredRow.marginTop - 5;
}
}
else {
anchoredRow.marginTop = 0;
if (headerView.height <= maxTopViewHeight) {
headerView.height = _this.getTopViewHeight(maxTopViewHeight, scrollView.verticalOffset);
}
}
if (anchoredRow.marginTop < 0) {
anchoredRow.marginTop = 0;
if (_this._includesAnchored) {
anchoredRow.marginTop = _this.getAnchoredTopHeight(maxTopViewHeight, scrollView.verticalOffset);
}
}
if (scrollView.verticalOffset < maxTopViewHeight) {
topOpacity = parseFloat((1 - (scrollView.verticalOffset * 0.01)).toString());
if (topOpacity > 0 && topOpacity <= 1) {
viewsToFade.forEach(function (view) {
view.opacity = topOpacity;
});
}
}
prevOffset = scrollView.verticalOffset;
});
_this.fadeViews(maxTopViewHeight, scrollView.verticalOffset, viewsToFade);
prevOffset_1 = scrollView.verticalOffset;
});
}
});

@@ -205,2 +188,32 @@ }

});
ParallaxViewCommon.prototype.fadeViews = function (topHeight, verticalOffset, viewsToFade) {
var _this = this;
if (verticalOffset < topHeight) {
this._topOpacity = parseFloat((1 - (verticalOffset * 0.01)).toString());
if (this._topOpacity > 0 && this._topOpacity <= 1) {
viewsToFade.forEach(function (view) {
view.opacity = _this._topOpacity;
});
}
}
};
ParallaxViewCommon.prototype.getAnchoredTopHeight = function (topHeight, verticalOffset) {
var marginTop;
if (verticalOffset <= topHeight) {
marginTop = topHeight - (verticalOffset * 2);
if (marginTop > topHeight) {
marginTop = topHeight;
}
if (app.android) {
marginTop = marginTop - 5;
}
}
else {
marginTop = 0;
}
if (marginTop < 0) {
marginTop = 0;
}
return marginTop;
};
ParallaxViewCommon.prototype.getTopViewHeight = function (topHeight, verticalOffset) {

@@ -207,0 +220,0 @@ if ((topHeight - verticalOffset) >= 0) {

@@ -27,2 +27,5 @@ import * as app from 'application';

private _includesAnchored: boolean;
private _topOpacity: number;
private _loaded: boolean;
get controlsToFade(): string {

@@ -50,4 +53,4 @@ return this._controlsToFade;

this.addRow(row);
this.addColumn(column);
//must set the vertical alignmnet or else there is issues with margin-top of 0 being the middle of the screen.

@@ -58,134 +61,123 @@ this.verticalAlignment = 'top';

this._includesAnchored = false;
this._topOpacity = 1;
this._loaded = false;
this.on(_gridLayout.GridLayout.loadedEvent, (data: any) => {
this.addChild(scrollView);
this.addChild(anchoredRow);
_gridLayout.GridLayout.setRow(scrollView, 1);
_gridLayout.GridLayout.setRow(anchoredRow, 0);
_gridLayout.GridLayout.setColumn(scrollView, 1);
_gridLayout.GridLayout.setColumn(anchoredRow, 0);
if (!this._loaded) {
this._loaded = true;
//creates a new stack layout to wrap the content inside of the plugin.
let wrapperStackLayout = new _stackLayout.StackLayout();
scrollView.content = wrapperStackLayout;
this.addRow(row);
this.addColumn(column);
this.addChild(scrollView);
this.addChild(anchoredRow);
this._childLayouts.forEach(element => {
if (element instanceof Header) {
wrapperStackLayout.addChild(element);
headerView = element;
}
});
this._childLayouts.forEach(element => {
if (element instanceof Content) {
wrapperStackLayout.addChild(element);
contentView = element;
}
});
this._childLayouts.forEach(element => {
if (element instanceof Anchored) {
anchoredRow.addChild(element);
anchoredRow.height = element.height;
this._includesAnchored = true;
}
});
if (headerView == null || contentView == null) {
let warningText = new _label.Label();
warningText.text = "Parallax ScrollView Setup Invalid. You must have Header and Content tags";
warningText.color = new _color.Color('red');
warningText.textWrap = true;
warningText.marginTop = 50;
this.addChild(warningText);
_gridLayout.GridLayout.setRow(scrollView, 1);
_gridLayout.GridLayout.setRow(anchoredRow, 0);
_gridLayout.GridLayout.setColumn(scrollView, 1);
_gridLayout.GridLayout.setColumn(anchoredRow, 0);
if (headerView != null) {
headerView.visibility = 'collapse';
//creates a new stack layout to wrap the content inside of the plugin.
let wrapperStackLayout = new _stackLayout.StackLayout();
scrollView.content = wrapperStackLayout;
this._childLayouts.forEach(element => {
if (element instanceof Header) {
wrapperStackLayout.addChild(element);
headerView = element;
}
});
this._childLayouts.forEach(element => {
if (element instanceof Content) {
wrapperStackLayout.addChild(element);
contentView = element;
}
});
this._childLayouts.forEach(element => {
if (element instanceof Anchored) {
anchoredRow.addChild(element);
anchoredRow.height = element.height;
this._includesAnchored = true;
}
});
if (headerView == null || contentView == null) {
let warningText = new _label.Label();
warningText.text = "Parallax ScrollView Setup Invalid. You must have Header and Content tags";
warningText.color = new _color.Color('red');
warningText.textWrap = true;
warningText.marginTop = 50;
this.addChild(warningText);
if (headerView != null) {
headerView.visibility = 'collapse';
}
if (contentView != null) {
contentView.visibility = 'collapse';
return;
}
}
if (contentView != null) {
contentView.visibility = 'collapse';
maxTopViewHeight = headerView.height;
return;
if (this._includesAnchored) {
anchoredRow.marginTop = maxTopViewHeight;
if (app.android) { //helps prevent background leaking int on scroll;
anchoredRow.marginTop = anchoredRow.marginTop - 5; // get rid of white line that happens on android
}
//pushes content down a to compensate for anchor.
contentView.marginTop = anchoredRow.height;
}
}
maxTopViewHeight = headerView.height;
if (this._includesAnchored) {
anchoredRow.marginTop = maxTopViewHeight;
if (app.android) { //helps prevent background leaking int on scroll;
anchoredRow.marginTop = anchoredRow.marginTop - 5; // get rid of white line that happens on android
viewsToFade = [];
//scrollView = <_scrollViewModule.ScrollView>this;
if (controlsToFade == null && this.controlsToFade == null) {
controlsToFade = [];
} else {
controlsToFade = this.controlsToFade.split(',');
}
//pushes content down a to compensate for anchor.
contentView.marginTop = anchoredRow.height;
}
viewsToFade = [];
maxTopViewHeight = headerView.height;
//scrollView = <_scrollViewModule.ScrollView>this;
if (controlsToFade == null && this.controlsToFade == null) {
controlsToFade = [];
} else {
controlsToFade = this.controlsToFade.split(',');
}
controlsToFade.forEach((id: string): void => {
let newView: _view.View = headerView.getViewById(id);
if (newView != null) {
viewsToFade.push(newView);
}
});
maxTopViewHeight = headerView.height;
controlsToFade.forEach((id: string): void => {
let newView: _view.View = headerView.getViewById(id);
if (newView != null) {
viewsToFade.push(newView);
if (headerView == null) {
return;
}
});
if (headerView == null) {
return;
}
headerView.height = maxTopViewHeight;
headerView.height = maxTopViewHeight;
scrollView.on(_scrollViewModule.ScrollView.loadedEvent, (data: _scrollViewModule.ScrollEventData) => {
//sets up controls to fade in and out.
scrollView.on(_scrollViewModule.ScrollView.loadedEvent, (data: _scrollViewModule.ScrollEventData) => {
//sets up controls to fade in and out.
});
let prevOffset = -10;
});
let prevOffset = -10;
let topOpacity = 1;
scrollView.on(_scrollViewModule.ScrollView.scrollEvent, (args: _scrollViewModule.ScrollEventData) => {
if (prevOffset <= scrollView.verticalOffset) {
//when scrolling down
if (headerView.height >= 0) {
headerView.height = this.getTopViewHeight(maxTopViewHeight, scrollView.verticalOffset);
}
} else {
//scrolling up, as long as the view's hieght is not taller than it's initial height;
if (headerView.height <= maxTopViewHeight) {
headerView.height = this.getTopViewHeight(maxTopViewHeight, scrollView.verticalOffset);
}
}
if (this._includesAnchored) {
if (scrollView.verticalOffset <= maxTopViewHeight) {
anchoredRow.marginTop = maxTopViewHeight - (scrollView.verticalOffset * 2);
if (anchoredRow.marginTop > maxTopViewHeight) {
anchoredRow.marginTop = maxTopViewHeight;
scrollView.on(_scrollViewModule.ScrollView.scrollEvent, (args: _scrollViewModule.ScrollEventData) => {
if (prevOffset <= scrollView.verticalOffset) {
//when scrolling down
if (headerView.height >= 0) {
headerView.height = this.getTopViewHeight(maxTopViewHeight, scrollView.verticalOffset);
}
if (app.android) {
anchoredRow.marginTop = anchoredRow.marginTop - 5; // get rid of white line that happens on android
} else {
//scrolling up, as long as the view's hieght is not taller than it's initial height;
if (headerView.height <= maxTopViewHeight) {
headerView.height = this.getTopViewHeight(maxTopViewHeight, scrollView.verticalOffset);
}
} else {
anchoredRow.marginTop = 0;
}
if (anchoredRow.marginTop < 0) {
anchoredRow.marginTop = 0;
if (this._includesAnchored) {
anchoredRow.marginTop = this.getAnchoredTopHeight(maxTopViewHeight, scrollView.verticalOffset);
}
}
//fades in and out label in topView
if (scrollView.verticalOffset < maxTopViewHeight) {
topOpacity = parseFloat((1 - (scrollView.verticalOffset * 0.01)).toString());
if (topOpacity > 0 && topOpacity <= 1) {
//fade each control
viewsToFade.forEach((view: _view.View): void => {
view.opacity = topOpacity;
});
}
}
prevOffset = scrollView.verticalOffset;
});
//fades in and out label in topView
this.fadeViews(maxTopViewHeight, scrollView.verticalOffset, viewsToFade);
prevOffset = scrollView.verticalOffset;
});
}
});

@@ -202,2 +194,32 @@

}
fadeViews(topHeight: number, verticalOffset: number, viewsToFade: _view.View[]): void {
if (verticalOffset < topHeight) {
this._topOpacity = parseFloat((1 - (verticalOffset * 0.01)).toString());
if (this._topOpacity > 0 && this._topOpacity <= 1) {
//fade each control
viewsToFade.forEach((view: _view.View): void => {
view.opacity = this._topOpacity;
});
}
}
}
getAnchoredTopHeight(topHeight: number, verticalOffset: number): number {
let marginTop: number;
if (verticalOffset <= topHeight) {
marginTop = topHeight - (verticalOffset * 2);
if (marginTop > topHeight) {
marginTop = topHeight;
}
if (app.android) {
marginTop = marginTop - 5; // get rid of white line that happens on android
}
} else {
marginTop = 0;
}
if (marginTop < 0) {
marginTop = 0;
}
return marginTop;
}
//calcutes the top views height using the scrollview's verticalOffset

@@ -216,4 +238,2 @@ getTopViewHeight(topHeight: number, verticalOffset: number): number {

};
}
}
{
"name": "nativescript-parallax",
"version": "1.0.0",
"version": "1.0.1",
"description": "NativeScript Parallax View Plugin.",

@@ -5,0 +5,0 @@ "main": "nativescript-parallax.js",

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