Skip to content

Commit 1f20cd7

Browse files
committed
🇬🇧 Added origin method to the API and updated README.
1 parent de44ae4 commit 1f20cd7

9 files changed

+51
-13
lines changed

README.md

+11-3
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ In addition to the behaviours described above, there are **two** methods `enable
8484
data-scalar-x="2"
8585
data-scalar-y="8"
8686
data-friction-x="0.2"
87-
data-friction-y="0.8">
87+
data-friction-y="0.8"
88+
data-origin-x="0.0"
89+
data-origin-y="1.0">
8890
<li class="layer" data-depth="0.00"><img src="graphics/layer1.png"></li>
8991
<li class="layer" data-depth="0.20"><img src="graphics/layer2.png"></li>
9092
<li class="layer" data-depth="0.40"><img src="graphics/layer3.png"></li>
@@ -108,7 +110,9 @@ var parallax = new Parallax(scene, {
108110
scalarX: 2,
109111
scalarY: 8,
110112
frictionX: 0.2,
111-
frictionY: 0.8
113+
frictionY: 0.8,
114+
originX: 0.0,
115+
originY: 1.0
112116
});
113117
```
114118

@@ -124,6 +128,7 @@ parallax.invert(false, true);
124128
parallax.limit(false, 10);
125129
parallax.scalar(2, 8);
126130
parallax.friction(0.2, 0.8);
131+
parallax.origin(0.0, 1.0);
127132
```
128133

129134
## jQuery
@@ -148,7 +153,9 @@ $('#scene').parallax({
148153
scalarX: 2,
149154
scalarY: 8,
150155
frictionX: 0.2,
151-
frictionY: 0.8
156+
frictionY: 0.8,
157+
originX: 0.0,
158+
originY: 1.0
152159
});
153160
```
154161
### jQuery: API
@@ -162,6 +169,7 @@ $scene.parallax('invert', false, true);
162169
$scene.parallax('limit', false, 10);
163170
$scene.parallax('scalar', 2, 8);
164171
$scene.parallax('friction', 0.2, 0.8);
172+
$scene.parallax('origin', 0.0, 1.0);
165173
```
166174

167175
## iOS

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "parallax",
33
"description": "Parallax Engine that reacts to the orientation of a smart device.",
4-
"version": "2.1.0",
4+
"version": "2.1.1",
55
"license": "MIT",
66
"homepage": "http://wagerfield.github.io/parallax/",
77
"authors": [

deploy/jquery.parallax.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@
8484
scalarX: parseFloat(this.$context.data('scalar-x')) || null,
8585
scalarY: parseFloat(this.$context.data('scalar-y')) || null,
8686
frictionX: parseFloat(this.$context.data('friction-x')) || null,
87-
frictionY: parseFloat(this.$context.data('friction-y')) || null
87+
frictionY: parseFloat(this.$context.data('friction-y')) || null,
88+
originX: parseFloat(this.$context.data('origin-x')) || null,
89+
originY: parseFloat(this.$context.data('origin-y')) || null
8890
};
8991

9092
// Delete Null Data Values
@@ -323,6 +325,11 @@
323325
this.limitY = y === undefined ? this.limitY : y;
324326
};
325327

328+
Plugin.prototype.origin = function(x, y) {
329+
this.originX = x === undefined ? this.originX : x;
330+
this.originY = y === undefined ? this.originY : y;
331+
};
332+
326333
Plugin.prototype.clamp = function(value, min, max) {
327334
value = Math.max(value, min);
328335
value = Math.min(value, max);
@@ -487,7 +494,8 @@
487494
friction: Plugin.prototype.friction,
488495
invert: Plugin.prototype.invert,
489496
scalar: Plugin.prototype.scalar,
490-
limit: Plugin.prototype.limit
497+
limit: Plugin.prototype.limit,
498+
origin: Plugin.prototype.origin
491499
};
492500

493501
$.fn[NAME] = function (value) {

deploy/jquery.parallax.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deploy/parallax.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@
8181
scalarX: this.data(this.element, 'scalar-x'),
8282
scalarY: this.data(this.element, 'scalar-y'),
8383
frictionX: this.data(this.element, 'friction-x'),
84-
frictionY: this.data(this.element, 'friction-y')
84+
frictionY: this.data(this.element, 'friction-y'),
85+
originX: this.data(this.element, 'origin-x'),
86+
originY: this.data(this.element, 'origin-y')
8587
};
8688

8789
// Delete Null Data Values
@@ -351,6 +353,11 @@
351353
this.limitY = y === undefined ? this.limitY : y;
352354
};
353355

356+
Parallax.prototype.origin = function(x, y) {
357+
this.originX = x === undefined ? this.originX : x;
358+
this.originY = y === undefined ? this.originY : y;
359+
};
360+
354361
Parallax.prototype.clamp = function(value, min, max) {
355362
value = Math.max(value, min);
356363
value = Math.min(value, max);

deploy/parallax.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "parallax",
33
"description": "Parallax Engine that reacts to the orientation of a smart device.",
4-
"version": "2.1.0",
4+
"version": "2.1.1",
55
"license": "MIT",
66
"homepage": "http://wagerfield.github.io/parallax/",
77
"author": "Matthew Wagerfield <[email protected]>",

source/jquery.parallax.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@
5353
scalarX: parseFloat(this.$context.data('scalar-x')) || null,
5454
scalarY: parseFloat(this.$context.data('scalar-y')) || null,
5555
frictionX: parseFloat(this.$context.data('friction-x')) || null,
56-
frictionY: parseFloat(this.$context.data('friction-y')) || null
56+
frictionY: parseFloat(this.$context.data('friction-y')) || null,
57+
originX: parseFloat(this.$context.data('origin-x')) || null,
58+
originY: parseFloat(this.$context.data('origin-y')) || null
5759
};
5860

5961
// Delete Null Data Values
@@ -292,6 +294,11 @@
292294
this.limitY = y === undefined ? this.limitY : y;
293295
};
294296

297+
Plugin.prototype.origin = function(x, y) {
298+
this.originX = x === undefined ? this.originX : x;
299+
this.originY = y === undefined ? this.originY : y;
300+
};
301+
295302
Plugin.prototype.clamp = function(value, min, max) {
296303
value = Math.max(value, min);
297304
value = Math.min(value, max);
@@ -456,7 +463,8 @@
456463
friction: Plugin.prototype.friction,
457464
invert: Plugin.prototype.invert,
458465
scalar: Plugin.prototype.scalar,
459-
limit: Plugin.prototype.limit
466+
limit: Plugin.prototype.limit,
467+
origin: Plugin.prototype.origin
460468
};
461469

462470
$.fn[NAME] = function (value) {

source/parallax.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@
5050
scalarX: this.data(this.element, 'scalar-x'),
5151
scalarY: this.data(this.element, 'scalar-y'),
5252
frictionX: this.data(this.element, 'friction-x'),
53-
frictionY: this.data(this.element, 'friction-y')
53+
frictionY: this.data(this.element, 'friction-y'),
54+
originX: this.data(this.element, 'origin-x'),
55+
originY: this.data(this.element, 'origin-y')
5456
};
5557

5658
// Delete Null Data Values
@@ -320,6 +322,11 @@
320322
this.limitY = y === undefined ? this.limitY : y;
321323
};
322324

325+
Parallax.prototype.origin = function(x, y) {
326+
this.originX = x === undefined ? this.originX : x;
327+
this.originY = y === undefined ? this.originY : y;
328+
};
329+
323330
Parallax.prototype.clamp = function(value, min, max) {
324331
value = Math.max(value, min);
325332
value = Math.min(value, max);

0 commit comments

Comments
 (0)