You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Full guide and demonstrations available at the [official Stellar.js project page](http://markdalgleish.com/projects/stellar.js/).
5
4
6
-
Getting Started
7
-
---------------
5
+
## Getting Started
8
6
9
7
Stellar.js is a jQuery plugin that provides parallax scrolling effects to any scrolling element. The first step is to run `.stellar()` against the element:
10
8
@@ -23,8 +21,7 @@ $.stellar();
23
21
24
22
This will look for any parallax backgrounds or elements within the specified element and reposition them when the element scrolls.
25
23
26
-
Parallax Elements
27
-
-----------------
24
+
## Parallax Elements
28
25
29
26
If you want elements to scroll at a different speed, add the following attribute to any element with a CSS position of absolute, relative or fixed:
30
27
@@ -36,8 +33,7 @@ The ratio is relative to the natural scroll speed, so a ratio of 0.5 would cause
36
33
37
34
If a ratio lower than 1 is causing the element to appear jittery, try setting its CSS position to fixed.
38
35
39
-
Parallax Backgrounds
40
-
--------------------
36
+
## Parallax Backgrounds
41
37
42
38
If you want an element's background image to reposition on scroll, simply add the following attribute:
43
39
@@ -47,8 +43,7 @@ If you want an element's background image to reposition on scroll, simply add th
47
43
48
44
As with parallax elements, the ratio is relative to the natural scroll speed. For ratios lower than 1, to avoid jittery scroll performance, set the element's CSS 'background-attachment' to fixed.
49
45
50
-
Configuring Offsets
51
-
-------------------
46
+
## Configuring Offsets
52
47
53
48
Stellar.js' most powerful feature is the way it aligns elements.
54
49
@@ -73,8 +68,7 @@ You can also modify the offsets on a per-element basis using the following data
73
68
data-stellar-vertical-offset="150">
74
69
```
75
70
76
-
Configuring Offset Parents
77
-
--------------------------
71
+
## Configuring Offset Parents
78
72
79
73
By default, offsets are relative to the element's offset parent. This mirrors the way an absolutely positioned element behaves when nested inside an element with a relative position.
80
74
@@ -102,8 +96,7 @@ Still confused? [See what it looks like with its default offset parents.](http:/
102
96
103
97
By specifying the h2 element as the offset parent, we can ensure that the alignment of all the stars in a heading is based on the h2 and not the div further down the DOM tree.
104
98
105
-
Configuring Scroll Positioning
106
-
------------------------------
99
+
## Configuring Scroll Positioning
107
100
108
101
You can define what it means for an element to 'scroll'. Whether it's the element's scroll position that's changing, its margins or its CSS3 'transform' position, you can define it using the 'scrollProperty' option:
109
102
@@ -127,8 +120,7 @@ Don't have the level of control you need? Write a plugin!
127
120
128
121
Otherwise, you're ready to get started!
129
122
130
-
Configuring Everything
131
-
----------------------
123
+
## Configuring Everything
132
124
133
125
Below you will find a complete list of options and matching default values:
134
126
@@ -168,8 +160,7 @@ $.stellar({
168
160
});
169
161
```
170
162
171
-
Writing a Scroll Property Plugin
172
-
--------------------------------
163
+
## Writing a Scroll Property Plugin
173
164
174
165
Out of the box, Stellar.js supports the following scroll properties:
175
166
'scroll', 'position', 'margin' and 'transform'.
@@ -202,8 +193,7 @@ $.stellar({
202
193
});
203
194
```
204
195
205
-
Writing a Position Property Plugin
206
-
----------------------------------
196
+
## Writing a Position Property Plugin
207
197
208
198
Stellar.js has two methods for positioning elements built in: 'position' for modifying its top and left properties, and 'transform' for using CSS3 transforms.
I'm sure there are heaps more. [Let me know if you'd like me to feature your site here.](http://twitter.com/markdalgleish)
240
229
241
-
How to Build
242
-
------------
230
+
## How to Build
243
231
244
232
Stellar.js uses [Grunt](http://gruntjs.com) and [PhantomJS](http://phantomjs.org/).
245
233
@@ -261,20 +249,17 @@ To continuously validate and test the code while developing:
261
249
262
250
`grunt watch`
263
251
264
-
Contributing to Stellar.js
265
-
--------------------------
252
+
## Contributing to Stellar.js
266
253
267
254
Make sure that all plugin changes are made in `src/jquery.stellar.js` (`/jquery.stellar.js` and `/jquery.stellar.min.js` are generated by Grunt), and that you successfully test and build the project with `grunt` before committing.
268
255
269
256
If you want to contribute in a way that changes the API, please file an issue before submitting a pull request so we can discuss how to appropriately integrate your ideas.
270
257
271
-
Questions?
272
-
----------
258
+
## Questions?
273
259
274
260
Contact me on GitHub or Twitter: [@markdalgleish](http://twitter.com/markdalgleish)
0 commit comments