Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added nativeSticky and scrollContainerSelector options #145

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,26 @@ npm install sticky-sidebar
Your website's html structure has to be similar to this in order to work:

````html
<div class="main-content">
<div class="sidebar">
<div class="sidebar__inner">
<!-- Content goes here -->
</div>
</div>
<div class="content">
<!-- Content goes here -->
</div>
<div class="scroll-container">
<div class="main-content">
<div class="sidebar">
<div class="sidebar__inner">
<!-- Content goes here -->
</div>
</div>
<div class="content">
<!-- Content goes here -->
</div>
</div>
</div>
````

Note that inner sidebar wrapper ``.sidebar__innner`` is optional but highly recommended, if you don't write it yourself, the script will create one for you under class name ``inner-wrapper-sticky``. but this may cause many problems.

If your content is inside a container with scroll, this must be specified with the ``scrollContainerSelector`` option.

If you need native CSS sticky, use the ``nativeSticky`` option.

For the above example, you can use the following JavaScript:

````html
Expand All @@ -65,8 +71,10 @@ For the above example, you can use the following JavaScript:
var sidebar = new StickySidebar('.sidebar', {
topSpacing: 20,
bottomSpacing: 20,
scrollContainerSelector: '.scroll-container',
containerSelector: '.main-content',
innerWrapperSelector: '.sidebar__inner'
innerWrapperSelector: '.sidebar__inner',
nativeSticky: true
});
</script>
````
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": "sticky-sidebar",
"description": "A JavaScript plugin for making smart and high performance.",
"version": "3.3.1",
"version": "3.3.5",
"authors": [
"Ahmed Bouhuolia <[email protected]>"
],
Expand Down
Loading