Skip to content

Commit

Permalink
Set useTransition true as default
Browse files Browse the repository at this point in the history
- Add check if `transition` is supported by browser
- Update readme to accurately reflect defaults
  • Loading branch information
EnzoMartin committed Apr 14, 2016
1 parent 65a536a commit 47646eb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ You can pass in a class or ID into either one. Note that the container will get
| Name | Default | Description |
| ------------- | ------------- | ------------- |
| useTransition | true | Use native CSS3 `transition` property (recommended) |
| animate | false | Use jQuery animate function |
| animTime | 300 | Time it takes for animation to complete in `ms` |
| animate | true | Use jQuery animate function |
| animTime | 200 | Time it takes for animation to complete in `ms` |
| animDelay | 300 | Delay until the animation starts in `ms`, used only if `animate` is `true` |

**Note**: If you set `useTransition` to `true`, `animate` will always be treated as `false`
Expand Down
9 changes: 7 additions & 2 deletions jquery.stickyelement.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
return function(fn){ return raf(fn); };
})();

// Check if the browser supports the transition CSS property
var style = win.document.body.style;
var prop = 'transition';
var supportsTransition = typeof style[prop] == 'string';

var events = {
created:'sticky-created',
update:'sticky-update',
Expand All @@ -31,7 +36,7 @@
this._frozen = false;
this._stopped = true;
this.options = $.extend({
useTransition:false,
useTransition:true,
animate:true,
animTime:200,
animDelay:300
Expand All @@ -42,7 +47,7 @@

Sticky.prototype.init = function(){
var transition = '';
if(this.options.useTransition){
if(this.options.useTransition && supportsTransition){
transition = 'top ' + this.options.animTime + 'ms ease-in-out';
this.options.animate = false;
}
Expand Down
2 changes: 1 addition & 1 deletion jquery.stickyelement.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jquery-sticky-element",
"description": "Simple and lightweight plugin to pin/sticky elements inside a container so they move as the user scrolls",
"version": "1.1.0",
"version": "1.1.1",
"repository": {
"type": "git",
"url": "git@github.com:EnzoMartin/Sticky-Element.git"
Expand Down
2 changes: 1 addition & 1 deletion stickyelement.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"element",
"scroll"
],
"version": "1.1.0",
"version": "1.1.1",
"author": {
"name": "Enzo Martin",
"email": "enzo.r.martin@gmail.com",
Expand Down

0 comments on commit 47646eb

Please sign in to comment.