@basith374/parallax-background
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -10,3 +10,3 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var STEP = 0.2; | ||
var Parallax = function Parallax(_ref) { | ||
function Parallax(_ref) { | ||
var images = _ref.images; | ||
@@ -34,5 +34,5 @@ var refs = React.useRef({}); | ||
for (var i in refs.current) { | ||
for (var i = 0; i < Object.keys(refs.current).length; i++) { | ||
var el = refs.current[i]; | ||
var ratio = 1 - STEP * i; | ||
var ratio = STEP * 10 * (i + 1) / 10; | ||
el.style.left = ratio * (left - MARGIN) + 'px'; | ||
@@ -56,5 +56,5 @@ el.style.top = ratio * (top - MARGIN) + 'px'; | ||
})); | ||
}; | ||
} | ||
exports.Parallax = Parallax; | ||
module.exports = Parallax; | ||
//# sourceMappingURL=index.js.map |
@@ -7,3 +7,3 @@ import React, { useRef, useEffect } from 'react'; | ||
var STEP = 0.2; | ||
var Parallax = function Parallax(_ref) { | ||
function Parallax(_ref) { | ||
var images = _ref.images; | ||
@@ -31,5 +31,5 @@ var refs = useRef({}); | ||
for (var i in refs.current) { | ||
for (var i = 0; i < Object.keys(refs.current).length; i++) { | ||
var el = refs.current[i]; | ||
var ratio = 1 - STEP * i; | ||
var ratio = STEP * 10 * (i + 1) / 10; | ||
el.style.left = ratio * (left - MARGIN) + 'px'; | ||
@@ -53,5 +53,5 @@ el.style.top = ratio * (top - MARGIN) + 'px'; | ||
})); | ||
}; | ||
} | ||
export { Parallax }; | ||
export default Parallax; | ||
//# sourceMappingURL=index.modern.js.map |
{ | ||
"name": "@basith374/parallax-background", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "An interactive parallax image component", | ||
@@ -5,0 +5,0 @@ "keywords": ["react", "component", "image"], |
@@ -5,2 +5,6 @@ # parallax-background | ||
 | ||
Here's a [working demo](http://parallax-background.basithkunimal.com) | ||
[](https://www.npmjs.com/package/parallax-background) [](https://standardjs.com) [](https://github.com/basith374/parallax-background/actions/workflows/main.yml) | ||
@@ -22,5 +26,9 @@ | ||
import bg0 from './assets/bg1.png'; | ||
import bg1 from './assets/bg2.png'; | ||
import bg2 from './assets/bg3.png'; | ||
class Example extends Component { | ||
render() { | ||
return <Parallax /> | ||
return <Parallax images={[bg0, bg1, bg2]} /> | ||
} | ||
@@ -30,4 +38,6 @@ } | ||
> NOTE: Make sure the parent container has some height since the root container uses `height:100%` | ||
## License | ||
MIT © [basith374](https://github.com/basith374) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
13959
41