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

@mangoweb/parallax

Package Overview
Dependencies
Maintainers
6
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mangoweb/parallax - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

5

lib/index.d.ts
import { Component } from '@mangoweb/scripts-base';
export interface ParallaxProps {
customProperty?: string;
offsetPropertyName?: string;
heightPropertyName?: string;
windowHeightPropertyName?: string;
}

@@ -10,3 +12,4 @@ export declare class Parallax extends Component<ParallaxProps> {

getElementYCenter: () => number;
getElementHeight: () => number;
}
//# sourceMappingURL=index.d.ts.map

11

lib/index.js

@@ -7,4 +7,8 @@ import { Component } from '@mangoweb/scripts-base';

this.update = () => {
const offset = this.getElementYCenter() - (window.scrollY + window.innerHeight / 2);
this.el.style.setProperty(`--${this.getPropOrElse('customProperty', 'parallax')}`, `${offset}`);
const windowHeight = window.innerHeight;
const height = this.getElementHeight();
const offset = this.getElementYCenter() - (window.scrollY + windowHeight / 2);
this.el.style.setProperty(`--${this.getPropOrElse('offsetPropertyName', 'offset')}`, `${offset}`);
this.el.style.setProperty(`--${this.getPropOrElse('heightPropertyName', 'height')}`, `${height}`);
this.el.style.setProperty(`--${this.getPropOrElse('windowHeightPropertyName', 'windowHeight')}`, `${windowHeight}`);
};

@@ -15,2 +19,5 @@ this.getElementYCenter = () => {

};
this.getElementHeight = () => {
return lightBounds(this.el).height;
};
}

@@ -17,0 +24,0 @@ init() {

{
"name": "@mangoweb/parallax",
"version": "0.0.9",
"version": "0.0.10",
"description": "Watches elements vertical position in viewport.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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

# InView
# Parallax
The manGoweb Parallax component. Watches elements vertical position in viewport.
Demo: [codesandbox.io/s/mangowebparallax-demo-hz24v](https://codesandbox.io/s/mangowebparallax-demo-hz24v?file=/index.html)
## Installation

@@ -22,3 +24,5 @@

// Optional
customProperty: 'position', // Custom property name
offsetPropertyName: 'offset', // distance between element y center and window y center
heightPropertyName: 'height', // element height
windowHeightPropertyName: 'windowHeight',
},

@@ -33,4 +37,4 @@ })

#targetElement {
transform: translateY(calc(var(--position, 0) * 20vh)); // Translates by 0 pixels when javascript is disabled
transform: translateY(calc(var(--offset, 0) * 20vh)); // Translates by 0 pixels when javascript is disabled
}
```

@@ -5,3 +5,5 @@ import { Component } from '@mangoweb/scripts-base'

export interface ParallaxProps {
customProperty?: string
offsetPropertyName?: string
heightPropertyName?: string
windowHeightPropertyName?: string
}

@@ -18,5 +20,9 @@

update = () => {
const offset = this.getElementYCenter() - (window.scrollY + window.innerHeight / 2)
const windowHeight = window.innerHeight
const height = this.getElementHeight()
const offset = this.getElementYCenter() - (window.scrollY + windowHeight / 2)
this.el.style.setProperty(`--${this.getPropOrElse('customProperty', 'parallax')}`, `${offset}`)
this.el.style.setProperty(`--${this.getPropOrElse('offsetPropertyName', 'offset')}`, `${offset}`)
this.el.style.setProperty(`--${this.getPropOrElse('heightPropertyName', 'height')}`, `${height}`)
this.el.style.setProperty(`--${this.getPropOrElse('windowHeightPropertyName', 'windowHeight')}`, `${windowHeight}`)
}

@@ -28,2 +34,6 @@

}
getElementHeight = () => {
return lightBounds(this.el).height
}
}

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