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.5 to 0.0.6

7

lib/index.d.ts
import { Component } from '@mangoweb/scripts-base';
declare const easings: {
linear: (x: number) => number;
easeIn: (x: number) => number;
easeOut: (x: number) => number;
easeInOut: (x: number) => number;
};
interface ParallaxProps {
customProperty?: string;
easing?: keyof typeof easings;
}

@@ -12,0 +5,0 @@ export declare class Parallax extends Component<ParallaxProps> {

9

lib/index.js

@@ -18,8 +18,2 @@ "use strict";

var light_bounds_1 = require("light-bounds");
var easings = {
linear: function (x) { return x; },
easeIn: function (x) { return x * x; },
easeOut: function (x) { return x * (2 - x); },
easeInOut: function (x) { return (x < 0.5 ? 2 * x * x : -1 + (4 - 2 * x) * x); },
};
var PARALLAX_REACH = 1; // 100vh

@@ -35,4 +29,3 @@ function clamp(min, value, max) {

var reachDistance = window.innerHeight * PARALLAX_REACH;
var easing = easings[_this.getPropOrElse('easing', 'linear')];
var offset = easing(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);

@@ -39,0 +32,0 @@ };

2

package.json
{
"name": "@mangoweb/parallax",
"version": "0.0.5",
"version": "0.0.6",
"description": "Watches elements vertical position in viewport.",

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

import { Component } from '@mangoweb/scripts-base'
import { lightBounds } from 'light-bounds'
const easings = {
linear: (x: number) => x,
easeIn: (x: number) => x * x,
easeOut: (x: number) => x * (2 - x),
easeInOut: (x: number) => (x < 0.5 ? 2 * x * x : -1 + (4 - 2 * x) * x),
}
interface ParallaxProps {
customProperty?: string
easing?: keyof typeof easings
}

@@ -32,6 +24,3 @@

const reachDistance = window.innerHeight * PARALLAX_REACH
const easing = easings[this.getPropOrElse('easing', 'linear')]
const offset = easing(
clamp(-1, (this.getElementYCenter() - (window.scrollY + window.innerHeight / 2)) / reachDistance, 1)
)
const offset = clamp(-1, (this.getElementYCenter() - (window.scrollY + window.innerHeight / 2)) / reachDistance, 1)

@@ -38,0 +27,0 @@ this.el.style.setProperty(`--${this.getPropOrElse('customProperty', 'parallax')}`, `${offset}`)

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