Skip to content

Commit 4edf912

Browse files
committed
added mirrorContainer option
1 parent 9ed1680 commit 4edf912

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $('.parallax-window').parallax({imageSrc: '/path/to/image.jpg'});
3737

3838
### Notes
3939

40-
What parallax.js will do is create a fixed-position element for each parallax image at the start of the document's body. This mirror element will sit behind the other elements and match the position and dimensions of its target object.
40+
What parallax.js will do is create a fixed-position element for each parallax image at the start of the document's body (or another configurable container). This mirror element will sit behind the other elements and match the position and dimensions of its target object.
4141

4242
Due to the nature of this implementation, you must ensure that these parallax objects and any layers below them are transparent so that you can see the parallax effect underneath. Also, if there is no other content in this element, you will need to ensure that it has some fixed dimensions otherwise you won't see anything.
4343

@@ -172,6 +172,12 @@ Note that when specifying these options as html data-attributes, you should conv
172172
<td>false</td>
173173
<td>(Experimental) If true, will freeze the parallax effect when "over scrolling" in browsers like Safari to prevent unexpected gaps caused by negative scroll positions.</td>
174174
</tr>
175+
<tr>
176+
<td>mirrorContainer</td>
177+
<td>jQuery Selector</td>
178+
<td>body</td>
179+
<td>The parallax mirror will be prepended into this container.</td>
180+
</tr>
175181
</tbody>
176182
</table>
177183

parallax.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
return this;
114114
}
115115

116-
this.$mirror = $('<div />').prependTo('body');
116+
this.$mirror = $('<div />').prependTo(this.mirrorContainer);
117117

118118
var slider = this.$element.find('>.parallax-slider');
119119
var sliderExisted = false;
@@ -167,6 +167,7 @@
167167
androidFix: true,
168168
position: 'center',
169169
overScrollFix: false,
170+
mirrorContainer: 'body',
170171

171172
refresh: function() {
172173
this.boxWidth = this.$element.outerWidth();

0 commit comments

Comments
 (0)