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.2 to 0.0.3

6

lib/index.js

@@ -17,2 +17,3 @@ "use strict";

var scripts_base_1 = require("@mangoweb/scripts-base");
var light_bounds_1 = require("light-bounds");
var PARALLAX_REACH = 1; // 100vh

@@ -28,8 +29,7 @@ function clamp(min, value, max) {

var reachDistance = window.innerHeight * PARALLAX_REACH;
var offset = clamp(-1, -(_this.getElementYCenter() - (window.scrollY + window.innerHeight / 2)) / reachDistance, 1);
var offset = clamp(-1, (_this.getElementYCenter() - (window.scrollY + window.innerHeight / 2)) / reachDistance, 1);
_this.el.style.setProperty("--" + _this.getPropOrElse('customProperty', 'parallax'), "" + offset);
};
_this.getElementYCenter = function () {
// @TODO: debounce
var rect = _this.el.getBoundingClientRect();
var rect = light_bounds_1.lightBounds(_this.el);
return window.scrollY + rect.top + rect.height / 2;

@@ -36,0 +36,0 @@ };

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

@@ -39,3 +39,6 @@ "main": "lib/index.js",

"@mangoweb/scripts-base": "0.0.12"
},
"dependencies": {
"light-bounds": "0.0.6"
}
}
import { Component } from '@mangoweb/scripts-base'
import { lightBounds } from 'light-bounds'

@@ -23,3 +24,3 @@ interface ParallaxProps {

const reachDistance = window.innerHeight * PARALLAX_REACH
const offset = clamp(-1, -(this.getElementYCenter() - (window.scrollY + window.innerHeight / 2)) / reachDistance, 1)
const offset = clamp(-1, (this.getElementYCenter() - (window.scrollY + window.innerHeight / 2)) / reachDistance, 1)

@@ -30,6 +31,5 @@ this.el.style.setProperty(`--${this.getPropOrElse('customProperty', 'parallax')}`, `${offset}`)

getElementYCenter = () => {
// @TODO: debounce
const rect = this.el.getBoundingClientRect()
const rect = lightBounds(this.el)
return window.scrollY + rect.top + rect.height / 2
}
}

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