@mangoweb/parallax
Advanced tools
Comparing version 0.0.8 to 0.0.9
import { Component } from '@mangoweb/scripts-base'; | ||
interface ParallaxProps { | ||
export interface ParallaxProps { | ||
customProperty?: string; | ||
@@ -11,3 +11,2 @@ } | ||
} | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,40 +0,21 @@ | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var scripts_base_1 = require("@mangoweb/scripts-base"); | ||
var light_bounds_1 = require("light-bounds"); | ||
var Parallax = /** @class */ (function (_super) { | ||
__extends(Parallax, _super); | ||
function Parallax() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.update = function () { | ||
var offset = _this.getElementYCenter() - (window.scrollY + window.innerHeight / 2); | ||
_this.el.style.setProperty("--" + _this.getPropOrElse('customProperty', 'parallax'), "" + offset); | ||
import { Component } from '@mangoweb/scripts-base'; | ||
import { lightBounds } from 'light-bounds'; | ||
export class Parallax extends Component { | ||
constructor() { | ||
super(...arguments); | ||
this.update = () => { | ||
const offset = this.getElementYCenter() - (window.scrollY + window.innerHeight / 2); | ||
this.el.style.setProperty(`--${this.getPropOrElse('customProperty', 'parallax')}`, `${offset}`); | ||
}; | ||
_this.getElementYCenter = function () { | ||
var rect = light_bounds_1.lightBounds(_this.el); | ||
this.getElementYCenter = () => { | ||
const rect = lightBounds(this.el); | ||
return window.scrollY + rect.top + rect.height / 2; | ||
}; | ||
return _this; | ||
} | ||
Parallax.prototype.init = function () { | ||
light_bounds_1.lightBounds(this.el, { onChange: this.update }); | ||
init() { | ||
lightBounds(this.el, { onChange: this.update }); | ||
this.update(); | ||
}; | ||
Parallax.componentName = 'Parallax'; | ||
return Parallax; | ||
}(scripts_base_1.Component)); | ||
exports.Parallax = Parallax; | ||
} | ||
} | ||
Parallax.componentName = 'Parallax'; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@mangoweb/parallax", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "Watches elements vertical position in viewport.", | ||
@@ -10,2 +10,3 @@ "main": "lib/index.js", | ||
"build": "tsc", | ||
"start": "tsc --watch", | ||
"eslint:lint": "eslint \"src/**/*.{ts,tsx}\" ", | ||
@@ -39,3 +40,3 @@ "eslint:fix": "eslint --fix \"src/**/*.{ts,tsx}\" ", | ||
"peerDependencies": { | ||
"@mangoweb/scripts-base": "0.0.12" | ||
"@mangoweb/scripts-base": "0.0.15" | ||
}, | ||
@@ -42,0 +43,0 @@ "dependencies": { |
@@ -20,3 +20,3 @@ # InView | ||
place: '#targetElement', | ||
data: { | ||
props: { | ||
// Optional | ||
@@ -23,0 +23,0 @@ customProperty: 'position', // Custom property name |
import { Component } from '@mangoweb/scripts-base' | ||
import { lightBounds } from 'light-bounds' | ||
interface ParallaxProps { | ||
export interface ParallaxProps { | ||
customProperty?: string | ||
@@ -6,0 +6,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5047
58