Skip to content

Commit

Permalink
🇬🇧 Added origin method to the API and updated README.
Browse files Browse the repository at this point in the history
  • Loading branch information
wagerfield committed Apr 26, 2014
1 parent de44ae4 commit 1f20cd7
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 13 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ In addition to the behaviours described above, there are **two** methods `enable
data-scalar-x="2"
data-scalar-y="8"
data-friction-x="0.2"
data-friction-y="0.8">
data-friction-y="0.8"
data-origin-x="0.0"
data-origin-y="1.0">
<li class="layer" data-depth="0.00"><img src="graphics/layer1.png"></li>
<li class="layer" data-depth="0.20"><img src="graphics/layer2.png"></li>
<li class="layer" data-depth="0.40"><img src="graphics/layer3.png"></li>
Expand All @@ -108,7 +110,9 @@ var parallax = new Parallax(scene, {
scalarX: 2,
scalarY: 8,
frictionX: 0.2,
frictionY: 0.8
frictionY: 0.8,
originX: 0.0,
originY: 1.0
});
```

Expand All @@ -124,6 +128,7 @@ parallax.invert(false, true);
parallax.limit(false, 10);
parallax.scalar(2, 8);
parallax.friction(0.2, 0.8);
parallax.origin(0.0, 1.0);
```

## jQuery
Expand All @@ -148,7 +153,9 @@ $('#scene').parallax({
scalarX: 2,
scalarY: 8,
frictionX: 0.2,
frictionY: 0.8
frictionY: 0.8,
originX: 0.0,
originY: 1.0
});
```
### jQuery: API
Expand All @@ -162,6 +169,7 @@ $scene.parallax('invert', false, true);
$scene.parallax('limit', false, 10);
$scene.parallax('scalar', 2, 8);
$scene.parallax('friction', 0.2, 0.8);
$scene.parallax('origin', 0.0, 1.0);
```

## iOS
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "parallax",
"description": "Parallax Engine that reacts to the orientation of a smart device.",
"version": "2.1.0",
"version": "2.1.1",
"license": "MIT",
"homepage": "http://wagerfield.github.io/parallax/",
"authors": [
Expand Down
12 changes: 10 additions & 2 deletions deploy/jquery.parallax.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@
scalarX: parseFloat(this.$context.data('scalar-x')) || null,
scalarY: parseFloat(this.$context.data('scalar-y')) || null,
frictionX: parseFloat(this.$context.data('friction-x')) || null,
frictionY: parseFloat(this.$context.data('friction-y')) || null
frictionY: parseFloat(this.$context.data('friction-y')) || null,
originX: parseFloat(this.$context.data('origin-x')) || null,
originY: parseFloat(this.$context.data('origin-y')) || null
};

// Delete Null Data Values
Expand Down Expand Up @@ -323,6 +325,11 @@
this.limitY = y === undefined ? this.limitY : y;
};

Plugin.prototype.origin = function(x, y) {
this.originX = x === undefined ? this.originX : x;
this.originY = y === undefined ? this.originY : y;
};

Plugin.prototype.clamp = function(value, min, max) {
value = Math.max(value, min);
value = Math.min(value, max);
Expand Down Expand Up @@ -487,7 +494,8 @@
friction: Plugin.prototype.friction,
invert: Plugin.prototype.invert,
scalar: Plugin.prototype.scalar,
limit: Plugin.prototype.limit
limit: Plugin.prototype.limit,
origin: Plugin.prototype.origin
};

$.fn[NAME] = function (value) {
Expand Down
2 changes: 1 addition & 1 deletion deploy/jquery.parallax.min.js

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion deploy/parallax.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@
scalarX: this.data(this.element, 'scalar-x'),
scalarY: this.data(this.element, 'scalar-y'),
frictionX: this.data(this.element, 'friction-x'),
frictionY: this.data(this.element, 'friction-y')
frictionY: this.data(this.element, 'friction-y'),
originX: this.data(this.element, 'origin-x'),
originY: this.data(this.element, 'origin-y')
};

// Delete Null Data Values
Expand Down Expand Up @@ -351,6 +353,11 @@
this.limitY = y === undefined ? this.limitY : y;
};

Parallax.prototype.origin = function(x, y) {
this.originX = x === undefined ? this.originX : x;
this.originY = y === undefined ? this.originY : y;
};

Parallax.prototype.clamp = function(value, min, max) {
value = Math.max(value, min);
value = Math.min(value, max);
Expand Down
2 changes: 1 addition & 1 deletion deploy/parallax.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "parallax",
"description": "Parallax Engine that reacts to the orientation of a smart device.",
"version": "2.1.0",
"version": "2.1.1",
"license": "MIT",
"homepage": "http://wagerfield.github.io/parallax/",
"author": "Matthew Wagerfield <[email protected]>",
Expand Down
12 changes: 10 additions & 2 deletions source/jquery.parallax.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
scalarX: parseFloat(this.$context.data('scalar-x')) || null,
scalarY: parseFloat(this.$context.data('scalar-y')) || null,
frictionX: parseFloat(this.$context.data('friction-x')) || null,
frictionY: parseFloat(this.$context.data('friction-y')) || null
frictionY: parseFloat(this.$context.data('friction-y')) || null,
originX: parseFloat(this.$context.data('origin-x')) || null,
originY: parseFloat(this.$context.data('origin-y')) || null
};

// Delete Null Data Values
Expand Down Expand Up @@ -292,6 +294,11 @@
this.limitY = y === undefined ? this.limitY : y;
};

Plugin.prototype.origin = function(x, y) {
this.originX = x === undefined ? this.originX : x;
this.originY = y === undefined ? this.originY : y;
};

Plugin.prototype.clamp = function(value, min, max) {
value = Math.max(value, min);
value = Math.min(value, max);
Expand Down Expand Up @@ -456,7 +463,8 @@
friction: Plugin.prototype.friction,
invert: Plugin.prototype.invert,
scalar: Plugin.prototype.scalar,
limit: Plugin.prototype.limit
limit: Plugin.prototype.limit,
origin: Plugin.prototype.origin
};

$.fn[NAME] = function (value) {
Expand Down
9 changes: 8 additions & 1 deletion source/parallax.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
scalarX: this.data(this.element, 'scalar-x'),
scalarY: this.data(this.element, 'scalar-y'),
frictionX: this.data(this.element, 'friction-x'),
frictionY: this.data(this.element, 'friction-y')
frictionY: this.data(this.element, 'friction-y'),
originX: this.data(this.element, 'origin-x'),
originY: this.data(this.element, 'origin-y')
};

// Delete Null Data Values
Expand Down Expand Up @@ -320,6 +322,11 @@
this.limitY = y === undefined ? this.limitY : y;
};

Parallax.prototype.origin = function(x, y) {
this.originX = x === undefined ? this.originX : x;
this.originY = y === undefined ? this.originY : y;
};

Parallax.prototype.clamp = function(value, min, max) {
value = Math.max(value, min);
value = Math.min(value, max);
Expand Down

0 comments on commit 1f20cd7

Please sign in to comment.