diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/README.md b/README.md index becdc50..22046b5 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,19 @@ Example usage: $('.msg').prepareTransition().toggleClass('hidden'); }); +Example CSS: + + .examplepanel { + opacity: 1; + transition: opacity 1s; + display: block; + } + + .is-shown .examplepanel { + opacity: 0; + display: none; + } + + .examplepanel.is-transitioning { + display: block !important; + } \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..f7d5569 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,10 @@ +var gulp = require('gulp'), + rename = require('gulp-rename'), + uglify = require('gulp-uglify'); + +gulp.task('default', function() { + return gulp.src("./preparetransition.js") + .pipe(uglify()) + .pipe(rename("preparetransition.min.js")) + .pipe(gulp.dest('./')) +}); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..37b99e9 --- /dev/null +++ b/package.json @@ -0,0 +1,29 @@ +{ + "name": "prepare-transition", + "version": "0.1.1", + "description": "The prepareTransition plugin sets display and visibility to override any existing display and visibility properties.", + "main": "gulpfile.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/snookca/prepareTransition.git" + }, + "keywords": [ + "css", + "transition", + "jquery" + ], + "author": "jonathan@snook.ca", + "license": "MIT", + "bugs": { + "url": "https://github.com/snookca/prepareTransition/issues" + }, + "homepage": "https://github.com/snookca/prepareTransition#readme", + "devDependencies": { + "gulp": "^3.9.0", + "gulp-rename": "^1.2.2", + "gulp-uglify": "^1.2.0" + } +} diff --git a/preparetransition.js b/preparetransition.js index e5e6517..eeeedf2 100644 --- a/preparetransition.js +++ b/preparetransition.js @@ -18,13 +18,102 @@ (function($){ -$.fn.prepareTransition = function(){ + // Checks if transitions are supported + function supportsTransitions() { + var b = document.body || document.documentElement, + s = b.style, + p = 'transition'; + + if (typeof s[p] == 'string') { return true; } + + // Tests for vendor specific prop + var v = ['Moz', 'webkit', 'Webkit', 'Khtml', 'O', 'ms']; + p = p.charAt(0).toUpperCase() + p.substr(1); + + for (var i=0; i