Skip to content

Commit bf146ee

Browse files
author
Josiah Nunemaker
committedAug 3, 2018
Simplify module exports
1 parent 52a1f7f commit bf146ee

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed
 

‎README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Rotates your elements in 3D space based on your mouse position.
44

5+
### [Demo on Codepen](https://codepen.io/FracturedLoop/full/VBXpbj/)
6+
57
## Installing
68

79
Clone the repo
@@ -30,7 +32,7 @@ npm run dev
3032
3133
// Optionally, if your environment supports ES modules, you can include Parabox.js as a module
3234
<script type="module">
33-
import * as parabox from 'https://cdn.jsdelivr.net/npm/parabox.js/dist/parabox.es.js';
35+
import parabox from 'https://cdn.jsdelivr.net/npm/parabox.js/dist/parabox.es.js';
3436
</script>
3537
3638
// Using the built files

‎gulpfile.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ gulp.task('dev', () => {
88

99
gulp.task('build:umd', async () => {
1010
const bundle = await rollup.rollup({
11-
input: './src/index.js',
11+
input: './src/parabox.js',
1212
plugins: [
1313
babel({
1414
exclude: 'node_modules/**',
@@ -26,7 +26,7 @@ gulp.task('build:umd', async () => {
2626

2727
gulp.task('build:es', async () => {
2828
const bundle = await rollup.rollup({
29-
input: './src/index.js',
29+
input: './src/parabox.js',
3030
});
3131

3232
bundle.write({

‎src/index.js

-1
This file was deleted.

‎src/parabox.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { init as initParaboxShift, shiftChildren } from './parabox-shift.js';
22

33
let paraboxes = [];
44

5-
function getTransformMagnitude(el) {
6-
const magnitude =
7-
el.dataset.paraboxMagnitude ||
8-
getComputedStyle(el).getPropertyValue('--parabox-magnitude') ||
5+
function getTransformMultiplier(el) {
6+
const multiplier =
7+
el.dataset.paraboxMultiplier ||
8+
getComputedStyle(el).getPropertyValue('--parabox-multiplier') ||
99
1;
10-
return magnitude;
10+
return multiplier;
1111
}
1212

1313
function tiltBox(e, el) {
@@ -16,8 +16,8 @@ function tiltBox(e, el) {
1616
const horToBoxCenter = e.clientX - rect.left - rect.width / 2;
1717
const verToBoxCenter = e.clientY - rect.top - rect.height / 2;
1818

19-
const transformX = horToBoxCenter * getTransformMagnitude(el);
20-
const transformY = verToBoxCenter * getTransformMagnitude(el);
19+
const transformX = horToBoxCenter * getTransformMultiplier(el);
20+
const transformY = verToBoxCenter * getTransformMultiplier(el);
2121

2222
el.style.boxShadow = `${((transformX * -1) / rect.width) *
2323
4}px ${((transformY * -1) / rect.height) * 4}px 4px rgba(0, 0, 0, 0.25)`;

0 commit comments

Comments
 (0)
Please sign in to comment.