diff --git a/.gitignore b/.gitignore index 15f1175..438d6ec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,2 @@ -/site/_output -/site/source.html -/site/jquery.transit.js -/site/jquery.transit.min.js -/site/.sass-cache +node_modules +site diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..fc5fe26 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,128 @@ +# Contributing to Transit + +Want to get involved? Thanks! There are plenty of ways to help! + +## Reporting issues + +A bug is a _demonstrable problem_ that is caused by the code in the +repository. + +Please read the following guidelines before you [report an issue][issues]: + +1. **Use the GitHub issue search** — check if the issue has already been + reported. If it has been, please comment on the existing issue. + +2. **Check if the issue has been fixed** — the latest `master` or + development branch may already contain a fix. + +3. **Isolate the demonstrable problem** — make sure that the code in the + project's repository is _definitely_ responsible for the issue. Create a + [reduced test case](http://css-tricks.com/6263-reduced-test-cases/) - an + extremely simple and immediately viewable example of the issue. + +4. **Include a live example** — provide a link to your reduced test case + when appropriate (e.g. if the issue is related to (front-end technologies). + Please use [jsFiddle](http://jsfiddle.net) to host examples. + +Please try to be as detailed as possible in your report too. What is your +environment? What steps will reproduce the issue? What browser(s) and OS +experience the problem? What would you expect to be the outcome? All these +details will help people to assess and fix any potential bugs. + +### Example of a good bug report: + +> Short and descriptive title +> +> A summary of the issue and the browser/OS environment in which it occurs. If +> suitable, include the steps required to reproduce the bug. +> +> 1. This is the first step +> 2. This is the second step +> 3. Further steps, etc. +> +> `` (a link to the reduced test case) +> +> Any other information you want to share that is relevant to the issue being +> reported. This might include the lines of code that you have identified as +> causing the bug, and potential solutions (and your opinions on their +> merits). + +A good bug report shouldn't leave people needing to chase you up to get further +information that is required to assess or fix the bug. + +**[File a bug report][issues]** + +## Responding to issues + +Feel free to respond to other people's issues! Some people may be reporting +issues that can easily be solved even without modification to the project's +code. + +You can also help by verifying issues reported. + +**[View issues][issues]** + +## The 'help wanted' tag + +Some [issues] are tagged with the 'help wanted' tag. These issues often: + + - are missing an actual implementation, or + - need people's help in verifying and replicating the issue, or + - need test cases. + +If you would like to contribute code and don't have any specific issue you want +to fix, this would be a good place to start looking at! + +**[View issues][issues]** + +## Pull requests + +Good pull requests — patches, improvements, new features — are a fantastic +help. They should remain focused in scope and avoid containing unrelated +commits. + +If your contribution involves a significant amount of work or substantial +changes to any part of the project, please open an issue to discuss it first. + +Please follow this process; it's the best way to get your work included in the +project: + +1. [Fork](http://help.github.com/fork-a-repo/) the project. + +2. Clone your fork (`git clone + https://github.com//html5-boilerplate.git`). + +3. Add an `upstream` remote (`git remote add upstream + https://github.com/rstacruz/jquery.transit.git`). + +4. Get the latest changes from upstream (e.g. `git pull upstream + `). + +5. Create a new topic branch to contain your feature, change, or fix (`git + checkout -b `). + +6. Make sure that your changes adhere to the current coding conventions used + throughout the project - indentation, accurate comments, etc. Please update + any documentation that is relevant to the change you are making. + +7. Commit your changes in logical chunks; use git's [interactive + rebase](https://help.github.com/articles/interactive-rebase) feature to tidy + up your commits before making them public. Please adhere to these [git commit + message + guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) + or your pull request is unlikely be merged into the main project. + +8. Locally merge (or rebase) the upstream branch into your topic branch. + +9. Push your topic branch up to your fork (`git push origin + `). + +10. [Open a Pull Request](http://help.github.com/send-pull-requests/) with a + clear title and description. Please mention which browsers you tested in. + +## Acknowledgements + +This contributing guide has been adapted from [HTML5 boilerplate's guide][g]. + +[g]: https://github.com/h5bp/html5-boilerplate/blob/master/CONTRIBUTING.md +[issues]: https://github.com/rstacruz/jquery.transit/issues/ diff --git a/HISTORY.md b/HISTORY.md index 11a06b4..c1abd48 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,15 +1,58 @@ -v0.1.3 - Feb 14, 2012 ---------------------- +## v0.9.12 - July 17, 2014 + + * Fix browserify builds by using the correct jQuery. ([@dminkovsky], [#201]) + * Fix properties resetting after a transition. ([#204], [#205]) + +## v0.9.11 - June 23, 2014 + + * Add support for `scaleX` and `scaleY`. ([@YousefED], [#192]) + * Add support for npm. + * Add support for RequireJS and CommonJS. + * Fix transitionend support for IE10, Chrome, and many others. ([@wambotron], [#103]) + +Also: + + * Fix `.transition({...}, {queue: false})` not being honored. ([@YousefED], [#192]) + * Remove some redundant code. ([@Bongo], [#165]) + * Docs: Update to support the new docco. ([@francismakes], [#175]) + * Add `easeInCubic` easing. ([@emagnier], [@willblackmore], [#161], [#142]) + * Add test cases for jQuery 2.0+. ([@hankhero], [#155]) + +The version `0.9.10` was not officially released as it was published prematurely +to npm. + +## v0.9.9 - Dec 14, 2012 + +Many, many thanks to the many [contributors] who made this release happen! This +is a pre-release of 1.0. + +### Fixes and additions: + + * Fix support for jQuery 1.8, IE 10, Firefox 16, Android Jellybean. + ([#48], [#62], [#63], [#69], [#70], [#71], [#72], [#76], [#77], [#80], [#81], [#82], [#85], [#86], [#90], [#92], [#93]) + * Compatibility with Twitter Bootstrap has been fixed. ([#67]) + * Unprefixed CSS properties are now used if your browser supports them. + * Account for prefix-free transition end for Mozilla. ([#97]) + * Callbacks should now be called even if duration is `0`. ([#37]) + * Doing `.css('transition', 'transform 1s')` should now properly vendor-prefix 'transform'. ([#84]) + * Added Penner easing splines. ([#44]) + +### Internal fixes: + + * New test suite. + * In building the website, use `fl-rocco` instead of `docco`. This removes the dependency. ([#50]) + +## v0.1.3 - Feb 14, 2012 ### Fixed: - * Fix JS error with undefined `next` function. (#21) - * Using `delay: 0` now works. Closes (#20) - * More robust checking of 3D transition support. (#19) + * Fix JS error with undefined `next` function. ([#21]) + * Using `delay: 0` now works. Closes ([#20]) + * More robust checking of 3D transition support. ([#19]) * Stop rotateX/rotateY/etc from stopping other transitions when it's not - supported. (#15) + supported. ([#15]) ### Added: - * Support Firefox 10 3D transitions. (#19) + * Support Firefox 10 3D transitions. ([#19]) ### Changed: * Allow disabling using the transitionEnd property. @@ -17,31 +60,94 @@ v0.1.3 - Feb 14, 2012 * Use the more reliable timers by default. (`useTransitionEnd` now defaults to `false`) -v0.1.2 - Jan 24, 2012 ---------------------- +## v0.1.2 - Jan 24, 2012 -Thanks to code contributors @ppcano, @jeduan, @steckel, @weotch, and everyone +Thanks to code contributors [@ppcano], [@jeduan], [@steckel], [@weotch], and everyone who reported issues. ### Fixed: - * IE8 error about .indexOf. (#12, #8) - * Fix z-layer scaling in Safari. (#9, #10) - * Fix scale elements being unclickable in WebKits. (#9, #10) - * Fix support for `queue: false`. (#13) - * Clean up transitions when done. (#14) - * Fix disappearing scaled elements in Chrome. (#11) + * IE8 error about .indexOf. ([#12], [#8]) + * Fix z-layer scaling in Safari. ([#9], [#10]) + * Fix scale elements being unclickable in WebKits. ([#9], [#10]) + * Fix support for `queue: false`. ([#13]) + * Clean up transitions when done. ([#14]) + * Fix disappearing scaled elements in Chrome. ([#11]) * Fix a bug where the default duration and easing can sometimes not be used. ### Changed: - * Make code compatible with jsHint. (#6) + * Make code compatible with jsHint. ([#6]) -v0.1.1 - Nov 18, 2011 ---------------------- +## v0.1.1 - Nov 18, 2011 ### Fixed: * Only animate what is needed (ie, don't use 'transition-property: all'). -v0.1.0 - Nov 14, 2011 ---------------------- +## v0.1.0 - Nov 14, 2011 Initial official release. + +[contributors]: https://github.com/rstacruz/jquery.transit/contributors + +[#201]: https://github.com/rstarcuz/jquery.transit/issues/201 +[@dminkovsky]: https://github.com/dminkovsky + +[#204]: https://github.com/rstacruz/jquery.transit/issues/204 +[#205]: https://github.com/rstacruz/jquery.transit/issues/205 +[#192]: https://github.com/rstacruz/jquery.transit/issues/192 +[#103]: https://github.com/rstacruz/jquery.transit/issues/103 +[#192]: https://github.com/rstacruz/jquery.transit/issues/192 +[#165]: https://github.com/rstacruz/jquery.transit/issues/165 +[#175]: https://github.com/rstacruz/jquery.transit/issues/175 +[#161]: https://github.com/rstacruz/jquery.transit/issues/161 +[#142]: https://github.com/rstacruz/jquery.transit/issues/142 +[#155]: https://github.com/rstacruz/jquery.transit/issues/155 +[#48]: https://github.com/rstacruz/jquery.transit/issues/48 +[#62]: https://github.com/rstacruz/jquery.transit/issues/62 +[#63]: https://github.com/rstacruz/jquery.transit/issues/63 +[#69]: https://github.com/rstacruz/jquery.transit/issues/69 +[#70]: https://github.com/rstacruz/jquery.transit/issues/70 +[#71]: https://github.com/rstacruz/jquery.transit/issues/71 +[#72]: https://github.com/rstacruz/jquery.transit/issues/72 +[#76]: https://github.com/rstacruz/jquery.transit/issues/76 +[#77]: https://github.com/rstacruz/jquery.transit/issues/77 +[#80]: https://github.com/rstacruz/jquery.transit/issues/80 +[#81]: https://github.com/rstacruz/jquery.transit/issues/81 +[#82]: https://github.com/rstacruz/jquery.transit/issues/82 +[#85]: https://github.com/rstacruz/jquery.transit/issues/85 +[#86]: https://github.com/rstacruz/jquery.transit/issues/86 +[#90]: https://github.com/rstacruz/jquery.transit/issues/90 +[#92]: https://github.com/rstacruz/jquery.transit/issues/92 +[#93]: https://github.com/rstacruz/jquery.transit/issues/93 +[#67]: https://github.com/rstacruz/jquery.transit/issues/67 +[#97]: https://github.com/rstacruz/jquery.transit/issues/97 +[#37]: https://github.com/rstacruz/jquery.transit/issues/37 +[#84]: https://github.com/rstacruz/jquery.transit/issues/84 +[#44]: https://github.com/rstacruz/jquery.transit/issues/44 +[#50]: https://github.com/rstacruz/jquery.transit/issues/50 +[#21]: https://github.com/rstacruz/jquery.transit/issues/21 +[#20]: https://github.com/rstacruz/jquery.transit/issues/20 +[#19]: https://github.com/rstacruz/jquery.transit/issues/19 +[#15]: https://github.com/rstacruz/jquery.transit/issues/15 +[#19]: https://github.com/rstacruz/jquery.transit/issues/19 +[#12]: https://github.com/rstacruz/jquery.transit/issues/12 +[#8]: https://github.com/rstacruz/jquery.transit/issues/8 +[#9]: https://github.com/rstacruz/jquery.transit/issues/9 +[#10]: https://github.com/rstacruz/jquery.transit/issues/10 +[#9]: https://github.com/rstacruz/jquery.transit/issues/9 +[#10]: https://github.com/rstacruz/jquery.transit/issues/10 +[#13]: https://github.com/rstacruz/jquery.transit/issues/13 +[#14]: https://github.com/rstacruz/jquery.transit/issues/14 +[#11]: https://github.com/rstacruz/jquery.transit/issues/11 +[#6]: https://github.com/rstacruz/jquery.transit/issues/6 +[@YousefED]: https://github.com/YousefED +[@wambotron]: https://github.com/wambotron +[@YousefED]: https://github.com/YousefED +[@Bongo]: https://github.com/Bongo +[@francismakes]: https://github.com/francismakes +[@emagnier]: https://github.com/emagnier +[@willblackmore]: https://github.com/willblackmore +[@hankhero]: https://github.com/hankhero +[@ppcano]: https://github.com/ppcano +[@jeduan]: https://github.com/jeduan +[@steckel]: https://github.com/steckel +[@weotch]: https://github.com/weotch diff --git a/NOTES.md b/NOTES.md new file mode 100644 index 0000000..afd8ab9 --- /dev/null +++ b/NOTES.md @@ -0,0 +1,36 @@ +Developer notes +=============== + +Testing: + + open test/index.html + +Making a new release: + + vim HISTORY.md # update changelog + bump *.json *.js # update version number + npm publish # release to npm + git release v1.0.0 # release to github/bower + cd site && make # update the site + +Managing the site +----------------- + +Make `site/`: + + git clone git@github.com:rstacruz/jquery.transit.git -b gh-pages ./site + +Update: + + cd site + make update # update from files + make # update the site + make dist # make dist/ files (uh, should be deprecated) + +v1.0.0 to do +------------ + + * .transitionStop() + * use transitionend by default (#184) + * Update bootstrap compatibility (#143, #67) + * Redesign the site diff --git a/README.md b/README.md index 4a99b1a..519d661 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,22 @@ examples. Usage ----- -Just include this script after jQuery. Requires jQuery 1.4+. +Just include [jquery.transit.js] after jQuery. Requires jQuery 1.4+. ``` html ``` +It is also available via [bower] and [npm]. + + $ bower install --save jquery.transit + $ npm install --save jquery.transit + +[bower]: http://bower.io/search/?q=jquery.transit +[npm]: http://npmjs.org/package/jquery.transit +[jquery.transit.js]: https://github.com/rstacruz/jquery.transit/blob/master/jquery.transit.js + Transformations --------------- @@ -98,17 +107,18 @@ $("#box").transition({ Tests ----- -Since you can't easily programatically test transitions, you'll need to build -the site, open the test suite in your browser, and visually inspect if all -transitions work as they should. - -Build the site using `rake build`, then open `site/_output/test.html`. This -builds the minified JS and tests it. +Transit has a unique test suite. Open `test/index.html` to see it. When +contibuting fixes, be sure to test this out with different jQuery versions and +different browsers. Alternatives ------------ -__[Move.js](https://github.com/visionmedia/move.js)__ (recommended!) +__[Velocity.js](https://velocityjs.org)__ (recommended!) + + * Pros: optimized for situations with hundreds of simultaneous transitions. Lots of extra features. + +__[Move.js](https://github.com/visionmedia/move.js)__ * Pros: no jQuery dependency, great syntax. * Cons (at time of writing): no iOS support (doesn't use `translate3d`), some @@ -119,7 +129,7 @@ enhanced](https://github.com/benbarnett/jQuery-Animate-Enhanced)__ * Pros: transparently overrides `$.fn.animate()` to provide CSS transitions support. -* Cons: transpalently overrides `$.fn.animate()`. No transformations support. +* Cons: transparently overrides `$.fn.animate()`. No transformations support. __[jQuery 2D transformations](https://github.com/heygrady/transform/)__ @@ -131,20 +141,29 @@ __[jQuery CSS3 rotate](http://plugins.jquery.com/project/Rotate)__ * Pros: simply provides rotation. * Cons: simply provides rotation. No transitions support. -Acknowledgements ----------------- +Support +------- + +__Bugs and requests__: submit them through the project's issues tracker.
+[![Issues](http://img.shields.io/github/issues/rstacruz/jquery.transit.svg)]( https://github.com/rstacruz/jquery.transit/issues ) + +__Questions__: ask them at StackOverflow with the tag *jquery-transit*.
+[![StackOverflow](http://img.shields.io/badge/stackoverflow-jquery--transit-brightgreen.svg)]( http://stackoverflow.com/questions/tagged/jquery-transit ) + +__Chat__: join us at gitter.im.
+[![Chat](http://img.shields.io/badge/gitter-rstacruz / jquery.transit-brightgreen.svg)]( https://gitter.im/rstacruz/jquery.transit ) + +Thanks +------ -© 2011, Rico Sta. Cruz. Released under the [MIT -License](http://www.opensource.org/licenses/mit-license.php). +**jQuery Transit** © 2011-2014+, Rico Sta. Cruz. Released under the [MIT License].
+Authored and maintained by Rico Sta. Cruz with help from [contributors]. -jQuery Transit is authored and maintained by [Rico Sta. Cruz][rsc] with help -from it's [contributors][c]. It is sponsored by my startup, [Sinefunc, Inc][sf]. +> [ricostacruz.com](http://ricostacruz.com)  ·  +> GitHub [@rstacruz](https://github.com/rstacruz)  ·  +> Twitter [@rstacruz](https://twitter.com/rstacruz) - * [My website](http://ricostacruz.com) (ricostacruz.com) - * [Sinefunc, Inc.](http://sinefunc.com) (sinefunc.com) - * [Github](http://github.com/rstacruz) (@rstacruz) - * [Twitter](http://twitter.com/rstacruz) (@rstacruz) +[MIT License]: http://mit-license.org/ +[contributors]: http://github.com/rstacruz/jquery.transit/contributors -[rsc]: http://ricostacruz.com -[c]: http://github.com/rstacruz/jquery.transit/contributors -[sf]: http://sinefunc.com +[![npm version](https://img.shields.io/npm/v/jquery.transit.png)](https://npmjs.org/package/jquery.transit "View this project on npm") diff --git a/Rakefile b/Rakefile deleted file mode 100644 index 18c1469..0000000 --- a/Rakefile +++ /dev/null @@ -1,101 +0,0 @@ -module Compressor - def self.compress(jscode) - require 'net/http' - require 'uri' - - response = Net::HTTP.post_form(URI.parse('http://closure-compiler.appspot.com/compile'), { - 'js_code' => jscode, - 'compilation_level' => "SIMPLE_OPTIMIZATIONS", - 'output_format' => 'text', - 'output_info' => 'compiled_code' - }) - response.body - end - - def self.compress_with_comment(jscode) - comment = jscode.match(/(\/\*!.*?\*\/)/m) && $1 - compressed = compress(jscode) - compressed = comment + "\n" + compressed if comment - compressed - end -end - -module Helpers - def can_run?(what) - ! `which #{what}`.strip.empty? - end - - def version - contents = File.read('jquery.transit.js') - m = contents.match(/version: "(.*?)"/) - m[1] - end - - def die(str) - puts str - exit - end -end - -extend Helpers - -desc "Print version." -task :version do - puts version -end - -desc "Puts released versions on the site." -task :release => :compress do - require 'fileutils' - - fn = "site/jquery.transit-#{version}.js" - FileUtils.cp 'site/jquery.transit.js', fn - puts "==> #{fn}" - - fn = "site/jquery.transit-#{version}.min.js" - FileUtils.cp 'site/jquery.transit.min.js', fn - puts "==> #{fn}" -end - -task :check_deps do - die "Error: You need Rocco. Try `gem install fl-rocco`." unless can_run?('rocco') - begin - require 'proton' - rescue LoadError => e - die "Error: You need Proton. Try `gem install proton`." - end -end - -task :compress do - system "cp jquery.transit.js site/" - - puts "==> Compressing (site/jquery.transit.min.js)..." - str = File.read('jquery.transit.js') - str = Compressor.compress_with_comment(str) - File.open('site/jquery.transit.min.js', 'w') { |f| f.write str } -end - -# Prepare -task :prebuild => [:check_deps, :compress] do - puts "==> Generating annotated source..." - system "rocco jquery.transit.js > /dev/null" - system "mv ./jquery.transit.html site/source.html" - system "rm -rf docs" -end - -desc "Builds the website" -task :build => :prebuild do - puts "==> Building site..." - system "cd site && proton build" -end - -desc "Deploys the website" -task :deploy => :build do - system "git update-ghpages rstacruz/jquery.transit -i site/_output -b gh-pages" -end - -desc "Starts the preview site" -task :preview => [:check_deps] do - port = ENV['port'] || 4833 - exec "cd site && proton start -p #{port}" -end diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..eee1c52 --- /dev/null +++ b/bower.json @@ -0,0 +1,17 @@ +{ + "name": "jquery.transit", + "repo": "rstacruz/jquery.transit", + "description": "Smooth CSS3 transitions and transformations for jQuery.", + "version": "0.9.12", + "keywords": [ + "css3", + "animation", + "transition" + ], + "dependencies": { + "jquery": "*" + }, + "development": {}, + "license": "MIT", + "main": "jquery.transit.js" +} diff --git a/component.json b/component.json new file mode 100644 index 0000000..d77d822 --- /dev/null +++ b/component.json @@ -0,0 +1,19 @@ +{ + "name": "jquery.transit", + "repo": "rstacruz/jquery.transit", + "description": "Smooth CSS3 transitions and transformations for jQuery.", + "version": "0.9.12", + "keywords": [ + "css3", + "animation", + "transition" + ], + "dependencies": { + "component/jquery": "*" + }, + "development": {}, + "license": "MIT", + "scripts": [ + "jquery.transit.js" + ] +} diff --git a/jquery.transit.js b/jquery.transit.js index 3ebae61..a2b47b8 100644 --- a/jquery.transit.js +++ b/jquery.transit.js @@ -1,17 +1,28 @@ /*! * jQuery Transit - CSS3 transitions and transformations - * Copyright(c) 2011 Rico Sta. Cruz + * (c) 2011-2014 Rico Sta. Cruz * MIT Licensed. * * http://ricostacruz.com/jquery.transit * http://github.com/rstacruz/jquery.transit */ -(function($) { - "use strict"; +/* jshint expr: true */ + +;(function (root, factory) { + + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else if (typeof exports === 'object') { + module.exports = factory(require('jquery')); + } else { + factory(root.jQuery); + } + +}(this, function($) { $.transit = { - version: "0.1.3", + version: "0.9.12", // Map of $.css() keys to values for 'transitionProperty'. // See https://developer.mozilla.org/en/CSS/CSS_transitions#Properties_that_can_be_animated @@ -39,11 +50,12 @@ // Helper function to get the proper vendor property name. // (`transition` => `WebkitTransition`) function getVendorPropertyName(prop) { + // Handle unprefixed versions (FF16+, for example) + if (prop in div.style) return prop; + var prefixes = ['Moz', 'Webkit', 'O', 'ms']; var prop_ = prop.charAt(0).toUpperCase() + prop.substr(1); - if (prop in div.style) { return prop; } - for (var i=0; i -1; // Check for the browser's transitions support. - // You can access this in jQuery's `$.support.transition`. - // As per [jQuery's cssHooks documentation](http://api.jquery.com/jQuery.cssHooks/), - // we set $.support.transition to a string of the actual property name used. support.transition = getVendorPropertyName('transition'); support.transitionDelay = getVendorPropertyName('transitionDelay'); support.transform = getVendorPropertyName('transform'); support.transformOrigin = getVendorPropertyName('transformOrigin'); + support.filter = getVendorPropertyName('Filter'); support.transform3d = checkTransform3dSupport(); - $.extend($.support, support); - var eventNames = { + 'transition': 'transitionend', 'MozTransition': 'transitionend', 'OTransition': 'oTransitionEnd', 'WebkitTransition': 'webkitTransitionEnd', @@ -82,17 +91,51 @@ // Detect the 'transitionend' event needed. var transitionEnd = support.transitionEnd = eventNames[support.transition] || null; + // Populate jQuery's `$.support` with the vendor prefixes we know. + // As per [jQuery's cssHooks documentation](http://api.jquery.com/jQuery.cssHooks/), + // we set $.support.transition to a string of the actual property name used. + for (var key in support) { + if (support.hasOwnProperty(key) && typeof $.support[key] === 'undefined') { + $.support[key] = support[key]; + } + } + // Avoid memory leak in IE. div = null; // ## $.cssEase // List of easing aliases that you can use with `$.fn.transition`. $.cssEase = { - '_default': 'ease', - 'in': 'ease-in', - 'out': 'ease-out', - 'in-out': 'ease-in-out', - 'snap': 'cubic-bezier(0,1,.5,1)' + '_default': 'ease', + 'in': 'ease-in', + 'out': 'ease-out', + 'in-out': 'ease-in-out', + 'snap': 'cubic-bezier(0,1,.5,1)', + // Penner equations + 'easeInCubic': 'cubic-bezier(.550,.055,.675,.190)', + 'easeOutCubic': 'cubic-bezier(.215,.61,.355,1)', + 'easeInOutCubic': 'cubic-bezier(.645,.045,.355,1)', + 'easeInCirc': 'cubic-bezier(.6,.04,.98,.335)', + 'easeOutCirc': 'cubic-bezier(.075,.82,.165,1)', + 'easeInOutCirc': 'cubic-bezier(.785,.135,.15,.86)', + 'easeInExpo': 'cubic-bezier(.95,.05,.795,.035)', + 'easeOutExpo': 'cubic-bezier(.19,1,.22,1)', + 'easeInOutExpo': 'cubic-bezier(1,0,0,1)', + 'easeInQuad': 'cubic-bezier(.55,.085,.68,.53)', + 'easeOutQuad': 'cubic-bezier(.25,.46,.45,.94)', + 'easeInOutQuad': 'cubic-bezier(.455,.03,.515,.955)', + 'easeInQuart': 'cubic-bezier(.895,.03,.685,.22)', + 'easeOutQuart': 'cubic-bezier(.165,.84,.44,1)', + 'easeInOutQuart': 'cubic-bezier(.77,0,.175,1)', + 'easeInQuint': 'cubic-bezier(.755,.05,.855,.06)', + 'easeOutQuint': 'cubic-bezier(.23,1,.32,1)', + 'easeInOutQuint': 'cubic-bezier(.86,0,.07,1)', + 'easeInSine': 'cubic-bezier(.47,0,.745,.715)', + 'easeOutSine': 'cubic-bezier(.39,.575,.565,1)', + 'easeInOutSine': 'cubic-bezier(.445,.05,.55,.95)', + 'easeInBack': 'cubic-bezier(.6,-.28,.735,.045)', + 'easeOutBack': 'cubic-bezier(.175, .885,.32,1.275)', + 'easeInOutBack': 'cubic-bezier(.68,-.55,.265,1.55)' }; // ## 'transform' CSS hook @@ -103,10 +146,10 @@ // $("#hello").css('transform'); // //=> { rotate: '90deg' } // - $.cssHooks.transform = { + $.cssHooks['transit:transform'] = { // The getter returns a `Transform` object. get: function(elem) { - return $(elem).data('transform'); + return $(elem).data('transform') || new Transform(); }, // The setter accepts a `Transform` object or a string. @@ -132,38 +175,65 @@ } }; - // ## 'transformOrigin' CSS hook - // Allows the use for `transformOrigin` to define where scaling and rotation - // is pivoted. - // - // $("#hello").css({ transformOrigin: '0 0' }); - // - $.cssHooks.transformOrigin = { - get: function(elem) { - return elem.style[support.transformOrigin]; - }, - set: function(elem, value) { - elem.style[support.transformOrigin] = value; - } + // Add a CSS hook for `.css({ transform: '...' })`. + // In jQuery 1.8+, this will intentionally override the default `transform` + // CSS hook so it'll play well with Transit. (see issue #62) + $.cssHooks.transform = { + set: $.cssHooks['transit:transform'].set }; - // ## 'transition' CSS hook - // Allows you to use the `transition` property in CSS. + // ## 'filter' CSS hook + // Allows you to use the `filter` property in CSS. // - // $("#hello").css({ transition: 'all 0 ease 0' }); + // $("#hello").css({ filter: 'blur(10px)' }); // - $.cssHooks.transition = { + $.cssHooks.filter = { get: function(elem) { - return elem.style[support.transition]; + return elem.style[support.filter]; }, set: function(elem, value) { - elem.style[support.transition] = value; + elem.style[support.filter] = value; } }; + // jQuery 1.8+ supports prefix-free transitions, so these polyfills will not + // be necessary. + if ($.fn.jquery < "1.8") { + // ## 'transformOrigin' CSS hook + // Allows the use for `transformOrigin` to define where scaling and rotation + // is pivoted. + // + // $("#hello").css({ transformOrigin: '0 0' }); + // + $.cssHooks.transformOrigin = { + get: function(elem) { + return elem.style[support.transformOrigin]; + }, + set: function(elem, value) { + elem.style[support.transformOrigin] = value; + } + }; + + // ## 'transition' CSS hook + // Allows you to use the `transition` property in CSS. + // + // $("#hello").css({ transition: 'all 0 ease 0' }); + // + $.cssHooks.transition = { + get: function(elem) { + return elem.style[support.transition]; + }, + set: function(elem, value) { + elem.style[support.transition] = value; + } + }; + } + // ## Other CSS hooks // Allows you to rotate, scale and translate. registerCssHook('scale'); + registerCssHook('scaleX'); + registerCssHook('scaleY'); registerCssHook('translate'); registerCssHook('rotate'); registerCssHook('rotateX'); @@ -310,8 +380,8 @@ if (this._translateX === undefined) { this._translateX = 0; } if (this._translateY === undefined) { this._translateY = 0; } - if (x !== null) { this._translateX = unit(x, 'px'); } - if (y !== null) { this._translateY = unit(y, 'px'); } + if (x !== null && x !== undefined) { this._translateX = unit(x, 'px'); } + if (y !== null && y !== undefined) { this._translateY = unit(y, 'px'); } this.translate = this._translateX + "," + this._translateY; } @@ -393,7 +463,9 @@ } else if (queue) { self.queue(queue, fn); } else { - fn(); + self.each(function () { + fn.call(this); + }); } } @@ -405,9 +477,13 @@ $.each(props, function(key) { key = $.camelCase(key); // Convert "text-align" => "textAlign" - key = $.transit.propertyMap[key] || key; + key = $.transit.propertyMap[key] || $.cssProps[key] || key; key = uncamel(key); // Convert back to dasherized + // Get vendor specify propertie + if (support[key]) + key = uncamel(support[key]); + if ($.inArray(key, re) === -1) { re.push(key); } }); @@ -474,12 +550,23 @@ var delay = 0; var queue = true; + var theseProperties = $.extend(true, {}, properties); + // Account for `.transition(properties, callback)`. if (typeof duration === 'function') { callback = duration; duration = undefined; } + // Account for `.transition(properties, options)`. + if (typeof duration === 'object') { + easing = duration.easing; + delay = duration.delay || 0; + queue = typeof duration.queue === "undefined" ? true : duration.queue; + callback = duration.complete; + duration = duration.duration; + } + // Account for `.transition(properties, duration, callback)`. if (typeof easing === 'function') { callback = easing; @@ -487,29 +574,29 @@ } // Alternate syntax. - if (typeof properties.easing !== 'undefined') { - easing = properties.easing; - delete properties.easing; + if (typeof theseProperties.easing !== 'undefined') { + easing = theseProperties.easing; + delete theseProperties.easing; } - if (typeof properties.duration !== 'undefined') { - duration = properties.duration; - delete properties.duration; + if (typeof theseProperties.duration !== 'undefined') { + duration = theseProperties.duration; + delete theseProperties.duration; } - if (typeof properties.complete !== 'undefined') { - callback = properties.complete; - delete properties.complete; + if (typeof theseProperties.complete !== 'undefined') { + callback = theseProperties.complete; + delete theseProperties.complete; } - if (typeof properties.queue !== 'undefined') { - queue = properties.queue; - delete properties.queue; + if (typeof theseProperties.queue !== 'undefined') { + queue = theseProperties.queue; + delete theseProperties.queue; } - if (typeof properties.delay !== 'undefined') { - delay = properties.delay; - delete properties.delay; + if (typeof theseProperties.delay !== 'undefined') { + delay = theseProperties.delay; + delete theseProperties.delay; } // Set defaults. (`400` duration, `ease` easing) @@ -519,7 +606,7 @@ duration = toMS(duration); // Build the `transition` property. - var transitionValue = getTransition(properties, duration, easing, delay); + var transitionValue = getTransition(theseProperties, duration, easing, delay); // Compute delay until callback. // If this becomes 0, don't bother setting the transition property. @@ -529,7 +616,7 @@ // If there's nothing to do... if (i === 0) { var fn = function(next) { - self.css(properties); + self.css(theseProperties); if (callback) { callback.apply(self); } if (next) { next(); } }; @@ -572,20 +659,15 @@ if (i > 0) { this.style[support.transition] = transitionValue; } - $(this).css(properties); + $(this).css(theseProperties); }); }; // Defer running. This allows the browser to paint any pending CSS it hasn't // painted yet before doing the transitions. var deferredRun = function(next) { - var i = 0; - - // Durations that are too slow will get transitions mixed up. - // (Tested on Mac/FF 7.0.1) - if ((support.transition === 'MozTransition') && (i < 25)) { i = 25; } - - window.setTimeout(function() { run(next); }, i); + this.offsetWidth = this.offsetWidth; // force a repaint + run(next); }; // Use jQuery's fx queue. @@ -603,17 +685,18 @@ $.cssHooks[prop] = { get: function(elem) { - var t = $(elem).css('transform') || new Transform(); + var t = $(elem).css('transit:transform'); return t.get(prop); }, set: function(elem, value) { - var t = $(elem).css('transform') || new Transform(); + var t = $(elem).css('transit:transform'); t.setFromString(prop, value); - $(elem).css({ transform: t }); + $(elem).css({ 'transit:transform': t }); } }; + } // ### uncamel(str) @@ -641,18 +724,22 @@ // ### toMS(duration) // Converts given `duration` to a millisecond string. // - // toMS('fast') //=> '400ms' - // toMS(10) //=> '10ms' + // toMS('fast') => $.fx.speeds[i] => "200ms" + // toMS('normal') //=> $.fx.speeds._default => "400ms" + // toMS(10) //=> '10ms' + // toMS('100ms') //=> '100ms' // function toMS(duration) { var i = duration; - // Allow for string durations like 'fast'. - if ($.fx.speeds[i]) { i = $.fx.speeds[i]; } + // Allow string durations like 'fast' and 'slow', without overriding numeric values. + if (typeof i === 'string' && (!i.match(/^[\-0-9\.]+/))) { i = $.fx.speeds[i] || $.fx.speeds._default; } return unit(i, 'ms'); } // Export some functions for testable-ness. $.transit.getTransitionValue = getTransition; -})(jQuery); + + return $; +})); diff --git a/package.json b/package.json new file mode 100644 index 0000000..78336e7 --- /dev/null +++ b/package.json @@ -0,0 +1,36 @@ +{ + "name": "jquery.transit", + "version": "0.9.12", + "description": "Smooth CSS3 transitions and transformations for jQuery.", + "main": "jquery.transit.js", + "directories": { + "test": "test" + }, + "scripts": { + "test": "mocha" + }, + "repository": { + "type": "git", + "url": "git://github.com/rstacruz/jquery.transit.git" + }, + "keywords": [ + "css3", + "animation", + "transition" + ], + "author": "Rico Sta. Cruz ", + "license": "MIT", + "peerDependencies": { + "jquery": "*" + }, + "devDependencies": { + "chai": "1.9.1", + "sinon": "1.10.2", + "jsdom": "0.11.0", + "coffee-script": "1.7.1" + }, + "bugs": { + "url": "https://github.com/rstacruz/jquery.transit/issues" + }, + "homepage": "http://ricostacruz.com/jquery.transit" +} diff --git a/site/Protonfile b/site/Protonfile deleted file mode 100644 index 2b4bf09..0000000 --- a/site/Protonfile +++ /dev/null @@ -1,16 +0,0 @@ -# This is a Proton site. -# Install Proton (`gem install proton`) and type `proton` for help. -requirement: 0.2 - -# The folder where the site's source files are kept. -site_path: . -output_path: _output - -# Other paths: -layouts_path: _layouts -extensions_path: _extensions -partials_path: . - -tilt_options: - haml: - ugly: true diff --git a/site/images/bg.png b/site/images/bg.png deleted file mode 100644 index 72f618c..0000000 Binary files a/site/images/bg.png and /dev/null differ diff --git a/site/images/box.png b/site/images/box.png deleted file mode 100644 index 1ff2a5f..0000000 Binary files a/site/images/box.png and /dev/null differ diff --git a/site/index.haml b/site/index.haml deleted file mode 100644 index b4b0d63..0000000 --- a/site/index.haml +++ /dev/null @@ -1,712 +0,0 @@ -title: Hello --- -!!! 5 -%html - %head - %title jQuery Transit - CSS3 animations for jQuery - %link(rel='stylesheet' media='screen' type='text/css' href='style.css') - %meta(name='description' content='Super-smooth CSS3 transformations and transitions for jQuery.') - != "" - != "" - != "" - != "" - != "" - %script(src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js') - %script(src='jquery.transit.min.js') - %script(src='script.js') - - if ENV['ANALYTICS_ID'] - :javascript - var _gaq = _gaq || []; - _gaq.push(['_setAccount', '#{ENV["ANALYTICS_ID"]}']); - _gaq.push(['_trackPageview']); - - (function() { - var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; - ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; - var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); - })(); - %body - %a.forkme{href: 'http://github.com/rstacruz/jquery.transit'} - %img{src: 'https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png', alt: "Fork me on Github"} - #all - %hgroup#header - %h1 - jQuery Transit - %p - != "Super-smooth CSS3 transformations and transitions for jQuery — " - %span#version<> - - :javascript - $("#version").html('v'+$.transit.version); - .meta - %a.button{href: 'jquery.transit.js'} - Download - %small 17kb - %a.button{href: 'jquery.transit.min.js'} - Download (Minified) - %small 2kb gzipped - - -# ============================================================================ - %h2 How to use - .more.info - - %p - Just include this script after jQuery. Requires jQuery 1.4+. - %br - != "Use $('...').transition instead of jQuery's $('...').animate. It has the same syntax as animate." - - -# ============================================================================ - %h2 Translate (move) - .info - Hover on a demo box to see it in action. - - %article - .hover - .code - %h3 Translate X - %pre - != "$('.box').transition({ x: '90px' });" - - .field - .box{style: 'left: 10px; top: 10px;'} - - %article - .hover - .code - %h3 Translate Y - %pre - != "$('.box').transition({ y: '30px' });" - - .field - .box{style: 'left: 10px; top: 10px;'} - - %article - .hover - .code - %h3 Translate X and Y - %pre - != "$('.box').transition({ x: '200px', y: '20px' });" - - .field - .box{style: 'left: 10px; top: 10px;'} - - -# ============================================================================ - %h2 Available transformations - .info - :markdown - The following transformations are available. - Refer to the [README](https://github.com/rstacruz/jquery.transit#readme) for more information. - .info.more.transformations - :markdown - * x*(px)* - * y*(px)* - * translate*(x, y)* - * rotate*(deg)* - * rotateX*(deg)* - * rotateY*(deg)* - * rotate3d*(x, y, z, deg)* - * scale*(x, \[y\])* - * perspective*(px)* - * skewX*(deg)* - * skewY*(deg)* - - -# ============================================================================ - %h2 Rotation - - %article - .hover - .code - %h3 Rotate - %pre - != "$('.box').transition({ rotate: '30deg' });" - - .field - .box{style: 'left: 180px; top: 20px;'} - - -# ============================================================================ - %h2 Skew - - %article - .hover - .code - %h3 Skew X - %pre - != "$('.box').transition({ skewX: '30deg' });" - - .field - .box{style: 'left: 180px; top: 20px;'} - - %article - .hover - .code - %h3 Skew Y - %pre - != "$('.box').transition({ skewY: '30deg' });" - - .field - .box{style: 'left: 180px; top: 20px;'} - - %article - .hover - .code - %h3 Skew X and Y - %pre - != "$('.box').transition({" - %br<> - != " skewX: '30deg'," - %br<> - != " skewY: '-30deg'" - %br<> - != "});" - - .field{style: 'height: 150px'} - .box{style: 'left: 180px; top: 45px;'} - - -# ============================================================================ - %h2 Scale - - %article - .hover - .code - %h3 Scale up 120% size - %pre - != "$('.box').transition({ scale: 1.2 });" - - .field - .box{style: 'left: 180px; top: 20px;'} - - %article - .hover - .code - %h3 Scale 200% horizontally, 150% vertically - %pre - != "$('.box').transition({ scale: [2, 1.5] });" - - .field - .box{style: 'left: 180px; top: 25px;'} - - -# ============================================================================ - %h2 3D rotation - - .info - :markdown - You may rotate using *rotateX* and *rotateY*. Using *perspective* is optional, - but it should always come before *rotateX/Y*. - - Note that not all browsers support this yet. Try it in Firefox 10+ or Webkit browsers! - - %article - .hover - .code - %h3 Rotate X - %pre - != "$('.box').transition({" - %br<> - != " perspective: '100px'," - %br<> - != " rotateX: '180deg'" - %br<> - != "});" - - .field - .box{style: 'left: 180px; top: 20px;'} - - %article - .hover - .code - %h3 Rotate Y - %pre - != "$('.box').transition({" - %br<> - != " perspective: '100px'," - %br<> - != " rotateY: '180deg'" - %br<> - != "});" - - .field - .box{style: 'left: 180px; top: 20px;'} - - %article - .hover - .code - %h3 Rotate 3D - %pre - != "$('.box').transition({" - %br<> - != " perspective: '100px'," - %br<> - != " rotate3d: '1, 1, 0, 180deg'" - %br<> - != "});" - - .field - .box{style: 'left: 180px; top: 20px;'} - - -# ============================================================================ - %h2 Transitions for other properties - .info You can animate any available CSS property. - - %article - .hover - .code - %h3 $.fn.transition for any CSS property - %pre - != "$('.box').transition({" - %br<> - != " opacity: 0," - %br<> - != " scale: 1.6" - %br<> - != "});" - - .field{style: 'height: 150px'} - .box{style: 'left: 180px; top: 45px;'} - - %article - .hover - .code - %pre - != "$('.box').transition({" - %br<> - != " marginLeft: '20px'," - %br<> - != " height: '80px'" - %br<> - != "});" - - .field{style: 'height: 130px'} - .box{style: 'left: 180px; top: 35px;'} - - -# ============================================================================ - %h2 Callbacks - - .info - :markdown - $.fn.transition(*options, \[duration\], \[easing\], \[callback\]*); - $.fn.transition works just like $.fn.animate. You can pass a *duration*, *easing*, and *callback*. - - %article - .hover - .code - %h3 Providing callbacks - %pre - != "$('.box').transition({ x: -100 }, function() {" - %br<> - != " $(this).transition({ opacity: 0 });" - %br<> - != "});" - - .field{style: 'height: 150px'} - .box{style: 'left: 180px; top: 45px;'} - - -# ============================================================================ - %h2 Custom duration - - %article - .hover - .code - %h3 Custom duration (jQuery style) - %pre - != "$('.box').transition({ opacity: 0 }, 'slow');" - - .field{style: 'height: 150px'} - .box{style: 'left: 180px; top: 45px;'} - - %article - .hover - .code - %h3 Custom duration (in milliseconds) - %pre - != "$('.box').transition({ opacity: 0 }, 2000);" - - .field{style: 'height: 150px'} - .box{style: 'left: 180px; top: 45px;'} - - -# ============================================================================ - %h2 Easing - .info - :markdown - Simply provide a third parameter to *$.fn.transition*. - - %article.mini - .hover - .code - %h3 Linear - %pre - != "$('.box').transition({ x: 330 }, 500, 'linear');" - - .field{style: 'height: 53px'} - .box{style: 'left: 10px; top: 10px; height: 30px;'} - - %article.mini - .hover - .code - %h3 Ease in - %pre - != "$('.box').transition({ x: 330 }, 500, 'in');" - - .field{style: 'height: 53px'} - .box{style: 'left: 10px; top: 10px; height: 30px;'} - - %article.mini - .hover - .code - %h3 Ease - %pre - != "$('.box').transition({ x: 330 }, 500, 'ease');" - - .field{style: 'height: 53px'} - .box{style: 'left: 10px; top: 10px; height: 30px;'} - - %article.mini - .hover - .code - %h3 Ease out - %pre - != "$('.box').transition({ x: 330 }, 500, 'out');" - - .field{style: 'height: 53px'} - .box{style: 'left: 10px; top: 10px; height: 30px;'} - - %article.mini - .hover - .code - %h3 Ease in-out - %pre - != "$('.box').transition({ x: 330 }, 500, 'in-out');" - - .field{style: 'height: 53px'} - .box{style: 'left: 10px; top: 10px; height: 30px;'} - - %article.mini - .hover - .code - %h3 Snap - %pre - != "$('.box').transition({ x: 330 }, 500, 'snap');" - - .field{style: 'height: 53px'} - .box{style: 'left: 10px; top: 10px; height: 30px;'} - - %article.mini.last - .hover - .code - %h3 Custom - %pre - != "$('.box').transition({ x: 330 }, 500, 'cubic-bezier(0,0.9,0.3,1)');" - - .field{style: 'height: 53px'} - .box{style: 'left: 10px; top: 10px; height: 30px;'} - - -# ============================================================================ - %h2 Delay - - %article - .hover - .code - %h3 Delay by 400ms - %pre - != "$('.box').transition({ x: -100, delay: 400 });" - - .field{style: 'height: 150px'} - .box{style: 'left: 180px; top: 45px;'} - - -# ============================================================================ - %h2 Alternate easing/duration syntax - - .info - :markdown - You can provide *easing* and *duration* in the options instead - Great for CoffeeScript. - - %article - .hover - .code - %pre - != "$('.box').transition({" - %br<> - != " x: '100px'," - %br<> - != " easing: 'snap'," - %br<> - != " duration: '2000ms'" - %br<> - != "});" - - .field{style: 'height: 150px'} - .box{style: 'left: 180px; top: 45px;'} - - -# ============================================================================ - %h2 Optional units - - .info - :markdown - All units (*px*, *deg*, *ms*, etc) are optional. - - %article - .hover - .code - %pre - != "$('.box').transition({" - %br<> - != " x: 100," - %br<> - != " duration: 2000," - %br<> - != " rotate: 30," - %br<> - != " easing: 'snap'" - %br<> - != "});" - - .field{style: 'height: 150px'} - .box{style: 'left: 180px; top: 45px;'} - - -# ============================================================================ - %h2 Relative units - - .info - :markdown - jQuery-style relative units are supported. Start your values with either *+=* or *-=*. - - %article - .hover - .code - %pre - != "$('.box').transition({" - %br<> - != " rotate: '+=30deg'," - %br<> - != " x: '+=30'" - %br<> - != "});" - - .field{style: 'height: 150px'} - .box{style: 'left: 180px; top: 45px;'} - - - -# ============================================================================ - %h2 $.fn.css - .info - :markdown - CSS3 transform properties work with *$.fn.css* as well. - - %article - .hover - .code - %pre - != "$('.box').css({" - %br<> - != " x: '90px'," - %br<> - != " y: '10px'," - %br<> - != " rotate: '-10deg'" - %br<> - != "});" - - .field{style: 'height: 150px'} - .box{style: 'left: 10px; top: 10px'} - - %article - .hover - .code - %h3 Transform (automatically adds vendor prefixes) - %pre - != "$('.box').css({ transform: 'rotate(40deg)' });" - - .field - .box{style: 'left: 10px; top: 10px;'} - - %article - .code - %h3 Getting values - %pre - != "$('.box').css({ rotate: '40deg' });" - %br<> - != "alert($('.box').css('rotate'));" - %br<> - != "alert($('.box').css('transform'));" - %button Run - - .field{style: 'height: 150px'} - .box{style: 'left: 10px; top: 10px;'} - - -# ============================================================================ - %h2 Setting transform origins - .info - :markdown - You can provide transformation origins via *$.fn.css*. The format is - *"x y"*, where *x* and *y* are coordinates in the given element. - - %article - .hover - .code - %pre - != "$('.box').css({ transformOrigin: '10px 10px' });" - %br<> - != "$('.box').transition({ rotate: 40, scale: 1.2 });" - - .field - .box{style: 'left: 10px; top: 10px;'} - - -# ============================================================================ - %h2 Chaining / effect queue - .info - - :markdown - Transit uses jQuery's [effect queue](http://api.jquery.com/queue/) by default, - exactly like *$.fn.animate*. This means that transitions will never - run in parallel. - - %article - .hover - .code - %pre - != "$('.box')." - %br<> - != " transition({ x: '-40px' }, 250)." - %br<> - != " transition({ x: '0px' }, 250)." - %br<> - != " transition({ y: '-40px' }, 250)." - %br<> - != " transition({ y: '0px' }, 250);" - - .field{style: 'height: 150px; overflow: hidden;'} - .box{style: 'left: 180px; top: 45px;'} - - -# ============================================================================ - %h2 Transitioning from one style to another - .info - - :markdown - You can chain *css* and *transition* together (*.css({ .. }).transition({ .. })*). - - %article - .hover - .code - %pre - != "$('.box')." - %br<> - != " css({ x: '-800px' })." - %br<> - != " transition({ x: 0 });" - - .field{style: 'height: 150px; overflow: hidden;'} - .box{style: 'left: 10px; top: 10px; width: 380px; height: 130px;'} - - -# ============================================================================ - %h2 Browser support - .info - :markdown - - IE *10+* - - Firefox *4+* - - Safari *5+* - - Chrome *10+* - - Opera *11+* - - Mobile Safari - - .more.info - :markdown - - See [caniuse.com's report](http://caniuse.com/#search=transition) on CSS transitions. - To support Mobile Safari, jQuery Transit uses *translate3d* and *scale3d*. - - -# ============================================================================ - %h2 What about older browsers? - .more.info - :markdown - - jQuery Transit degrades older browsers by simply not doing the - transformations (*rotate*, *scale*, etc) while still doing standard CSS - (*opacity*, *marginLeft*, etc) without any animation. - Delays and durations will be ignored. - - -# ============================================================================ - %h2 Fallback to frame-based animation - .more.info - - :markdown - If you would like to fallback to classic animation when transitions - aren't supported - (usually not recommended, may be slow): - - %pre - != "// Delegate .transition() calls to .animate()" - %br<> - != "// if the browser can't do CSS transitions." - %br<> - = "if (!$.support.transition)" - %br<> - = " $.fn.transition = $.fn.animate;" - - -# ============================================================================ - %h2 Setting defaults - .more.info - - %pre - != "// Transit uses the same default as $.fn.animate." - %br<> - != "$.fx.speeds._default = 300;" - - %pre - != "// Default easing is stored in $.cssEase." - %br<> - = "$.cssEase._default = 'snap';" - - -# ============================================================================ - %h2 Custom easing - .more.info - :markdown - Define custom easing aliases in *$.cssEase*. - - %pre - != "$.cssEase['bounce'] = 'cubic-bezier(0,1,0.5,1.3)';" - %br<> - != "$('.box').transition({ x: 0 }, 500, 'bounce');" - - -# ============================================================================ - %h2 Source code - .info.source - %a{href: 'source.html'} - %span See the annotated source code here. - != "→" - - You may also browse the - %a{href: 'https://github.com/rstacruz/jquery.transit'} - %span GitHub repo. - != "→" - - -# ============================================================================ - %h2 Upgrading info - .more.info - - %p - All versions of jQuery Transit should be perfectly backward compatible with it's older versions. - If you're upgrading from an old version, see - %a{href: 'https://github.com/rstacruz/jquery.transit/blob/master/HISTORY.md'} - %span the change log - != "→" - for info on what's changed. - - -# ============================================================================ - %h2 Credits - - .credits - :markdown - Copyright 2011, Rico Sta. Cruz. Released under the [MIT - License](http://www.opensource.org/licenses/mit-license.php). - - jQuery Transit is authored and maintained by [Rico Sta. Cruz][rsc] with help from it's - [contributors][c]. It is sponsored by my startup, [Sinefunc, Inc][sf]. - - * [My website](http://ricostacruz.com) (ricostacruz.com) - * [Sinefunc, Inc.](http://sinefunc.com) (sinefunc.com) - * [Github](http://github.com/rstacruz) (@rstacruz) - * [Twitter](http://twitter.com/rstacruz) (@rstacruz) - - [rsc]: http://ricostacruz.com - [c]: http://github.com/rstacruz/jquery.transit/contributors - [sf]: http://sinefunc.com diff --git a/site/jquery.transit-0.1.0.js b/site/jquery.transit-0.1.0.js deleted file mode 100644 index aca9a7b..0000000 --- a/site/jquery.transit-0.1.0.js +++ /dev/null @@ -1,537 +0,0 @@ -/*! - * jQuery Transit - CSS3 transitions and transformations - * Copyright(c) 2011 Rico Sta. Cruz - * MIT Licensed. - * - * http://ricostacruz.com/jquery.transit - * http://github.com/rstacruz/jquery.transit - */ - -(function($) { - $.transit = { - version: "0.1.0", - enabled: true // Will simply transition "instantly" if false - }; - - var div = document.createElement('div'); - - // Helper function to get the proper vendor property name. - // (`transition` => `WebkitTransition`) - function getVendorPropertyName(prop) { - var prefixes = ['Moz', 'Webkit', 'O', 'ms']; - var prop_ = prop.charAt(0).toUpperCase() + prop.substr(1); - - if (prop in div.style) return prop; - - for (var i=0; i { rotate: '90deg' } - // - $.cssHooks.transform = { - // The getter returns a `Transform` object. - get: function(elem) { - return $(elem).data('transform'); - }, - - // The setter accepts a `Transform` object or a string. - set: function(elem, v) { - var value = v; - if (!(value instanceof Transform)) - value = new Transform(value); - - if (support.transform == 'WebkitTransform') - elem.style[support.transform] = value.toString(true); - else - elem.style[support.transform] = value.toString(); - - $(elem).data('transform', value); - } - }; - - // ## 'transformOrigin' CSS hook - // Allows the use for `transformOrigin` to define where scaling and rotation - // is pivoted. - // - // $("#hello").css({ transformOrigin: '0 0' }); - // - $.cssHooks.transformOrigin = { - get: function(elem) { - return elem.style[support.transformOrigin]; - }, - set: function(elem, value) { - elem.style[support.transformOrigin] = value; - } - }; - - // ## Other CSS hooks - // Allows you to rotate, scale and translate. - registerCssHook('scale'); - registerCssHook('translate'); - registerCssHook('rotate'); - registerCssHook('rotateX'); - registerCssHook('rotateY'); - registerCssHook('rotate3d'); - registerCssHook('perspective'); - registerCssHook('skewX'); - registerCssHook('skewY'); - registerCssHook('x', true); - registerCssHook('y', true); - - // ## Transform class - // This is the main class of a transformation property that powers - // `$.fn.css({ transform: '...' })`. - // - // This is, in essence, a dictionary object with key/values as `-transform` - // properties. - // - // var t = new Transform("rotate(90) scale(4)"); - // - // t.rotate //=> "90deg" - // t.scale //=> "4,4" - // - // Setters are accounted for. - // - // t.set('rotate', 4) - // t.rotate //=> "4deg" - // - // Convert it to a CSS string using the `toString()` and `toWebkitString()` - // functions. - // - // t.toString() //=> "rotate(90deg) scale(4,4)" - // t.toWebkitString() //=> "rotate(90deg) scale3d(4,4,0)" - // - function Transform(str) { - if (typeof str === 'string') this.parse(str); - return this; - }; - - Transform.prototype = { - // ### setFromString() - // Sets a property from a string. - // - // t.setFromString('scale', '2,4'); - // // Same as set('scale', '2', '4'); - // - setFromString: function(prop, val) { - var args = - (typeof val === 'string') ? val.split(',') : - (val.constructor == Array) ? val : - [ val ]; - - args.unshift(prop); - - Transform.prototype.set.apply(this, args); - }, - - // ### set() - // Sets a property. - // - // t.set('scale', 2, 4); - // - set: function(prop) { - var args = Array.prototype.slice.apply(arguments, [1]); - if (this.setter[prop]) { - this.setter[prop].apply(this, args); - } else { - this[prop] = args.join(','); - } - }, - - get: function(prop) { - if (this.getter[prop]) { - return this.getter[prop].apply(this); - } else { - return this[prop] || 0; - } - }, - - setter: { - // ### rotate - // - // .css({ rotate: 30 }) - // .css({ rotate: "30" }) - // .css({ rotate: "30deg" }) - // .css({ rotate: "30deg" }) - // - rotate: function(theta) { - this.rotate = unit(theta, 'deg'); - }, - - rotateX: function(theta) { - this.rotateX = unit(theta, 'deg'); - }, - - rotateY: function(theta) { - this.rotateY = unit(theta, 'deg'); - }, - - // ### scale - // - // .css({ scale: 9 }) //=> "scale(9,9)" - // .css({ scale: '3,2' }) //=> "scale(3,2)" - // - scale: function(x, y) { - if (y === undefined) y = x; - this.scale = x + "," + y; - }, - - // ### skewX + skewY - skewX: function(x) { - this.skewX = unit(x, 'deg'); - }, - - skewY: function(y) { - this.skewY = unit(y, 'deg'); - }, - - // ### perspectvie - perspective: function(dist) { - this.perspective = unit(dist, 'px'); - }, - - // ### x / y - // Translations. Notice how this keeps the other value. - // - // .css({ x: 4 }) //=> "translate(4px, 0)" - // .css({ y: 10 }) //=> "translate(4px, 10px)" - // - x: function(x) { - this.set('translate', x, null); - }, - - y: function(y) { - this.set('translate', null, y); - }, - - // ### translate - // Notice how this keeps the other value. - // - // .css({ translate: '2, 5' }) //=> "translate(2px, 5px)" - // - translate: function(x, y) { - if (this._translateX === undefined) this._translateX = 0; - if (this._translateY === undefined) this._translateY = 0; - - if (x !== null) this._translateX = unit(x, 'px'); - if (y !== null) this._translateY = unit(y, 'px'); - - this.translate = this._translateX + "," + this._translateY; - } - }, - - getter: { - x: function() { - return this._translateX || 0; - }, - - y: function() { - return this._translateY || 0; - }, - - scale: function() { - var s = (this.scale || "1,1").split(','); - if (s[0]) s[0] = parseFloat(s[0]); - if (s[1]) s[1] = parseFloat(s[1]); - - // "2.5,2.5" => 2.5 - // "2.5,1" => [2.5,1] - return (s[0] == s[1]) ? s[0] : s; - }, - - rotate3d: function() { - var s = (this.rotate3d || "0,0,0,0deg").split(','); - for (i=0; i<=3; ++i) - if (s[i]) s[i] = parseFloat(s[i]); - if (s[3]) s[3] = unit(s[3], 'deg'); - - return s; - } - }, - - // ### parse() - // Parses from a string. Called on constructor. - parse: function(str) { - var self = this; - str.replace(/([a-zA-Z0-9]+)\((.*?)\)/g, function(x, prop, val) { - self.setFromString(prop, val); - }); - }, - - // ### toString() - // Converts to a `transition` CSS property string. If `use3d` is given, - // it converts to a `-webkit-transition` CSS property string instead. - toString: function(use3d) { - var re = []; - - for (i in this) { - if ((this.hasOwnProperty(i)) && (i[0] !== '_')) { - if ((use3d) && ((i === 'scale') || (i === 'translate'))) - re.push(i + "3d(" + this[i] + ",0)"); - else - re.push(i + "(" + this[i] + ")"); - } - } - - return re.join(" "); - } - }; - - function callOrQueue(self, queue, fn) { - if (queue === true) - self.queue(fn); - else if (queue) - self.queue(queue, fn) - else - fn(); - } - - // ## $.fn.transition - // Works like $.fn.animate(), but uses CSS transitions. - // - // $("...").transition({ opacity: 0.1, scale: 0.3 }); - // - // // Specific duration - // $("...").transition({ opacity: 0.1, scale: 0.3 }, 500); - // - // // With duration and easing - // $("...").transition({ opacity: 0.1, scale: 0.3 }, 500, 'in'); - // - // // With callback - // $("...").transition({ opacity: 0.1, scale: 0.3 }, function() { ... }); - // - // // With everything - // $("...").transition({ opacity: 0.1, scale: 0.3 }, 500, 'in', function() { ... }); - // - // // Alternate syntax - // $("...").transition({ - // opacity: 0.1, - // duration: 200, - // delay: 40, - // easing: 'in', - // complete: function() { /* ... */ } - // }); - // - $.fn.transition = $.fn.transit = function(properties, duration, easing, callback) { - var self = this; - var delay = 0; - var queue = true; - - // Account for `.transition(properties, callback)`. - if (typeof duration === 'function') { - callback = duration; - duration = null; - } - - // Account for `.transition(properties, duration, callback)`. - if (typeof easing === 'function') { - callback = easing; - easing = null; - } - - // Alternate syntax. - if (properties.easing) { - easing = properties.easing; - delete properties.easing; - } - - if (properties.duration) { - duration = properties.duration; - delete properties.duration; - } - - if (properties.complete) { - callback = properties.complete; - delete properties.complete; - } - - if (properties.queue) { - queue = properties.queue; - delete properties.queue; - } - - // Set defaults. (`400` duration, `ease` easing) - if (duration == null) duration = $.fx.speeds._default; - if (easing == null) easing = $.cssEase._default; - - // Account for aliases (`in` => `ease-in`). - if ($.cssEase[easing]) easing = $.cssEase[easing]; - - duration = toMS(duration); - - // Build the `transition` property. - var transitionValue = 'all ' + duration + ' ' + easing; - - // Delay may be part of the properties. - if (properties.delay) { - delay = toMS(properties.delay); - transitionValue += ' ' + delay; - delete properties.delay; - } - - // Compute delay until callback. - // If this becomes 0, don't bother setting the transition property. - var work = $.transit.enabled && support.transition; - var i = work ? (parseInt(duration) + parseInt(delay)) : 0; - - // If there's nothing to do... - if (i === 0) { - var fn = function(next) { - self.css(properties); - if (callback) callback(); - next(); - }; - - callOrQueue(self, queue, fn); - return self; - } - - // Save the old transitions of each element so we can restore it later. - var oldTransitions = {}; - - var run = function(nextCall) { - // Apply transitions. - self.each(function() { - if (i > 0) { - this.style[support.transition] = transitionValue; - } - $(this).css(properties); - }); - - var bound = false; - - // Prepare the callback. - var cb = function() { - if (bound) self.unbind(transitionEnd, cb); - - if (i > 0) { - self.each(function() { - this.style[support.transition] = oldTransitions[this]; - }); - } - - if (typeof callback === 'function') callback.apply(self); - if (typeof nextCall === 'function') nextCall(); - }; - - if ((i > 0) && (transitionEnd)) { - // Use the 'transitionend' event if it's available. - bound = true; - self.bind(transitionEnd, cb); - } else { - // Fallback to timers if the 'transitionend' event isn't supported. - window.setTimeout(cb, i); - } - }; - - // Defer running. This allows the browser to paint any pending CSS it hasn't - // painted yet before doing the transitions. - var deferredRun = function(next) { - var i = 0; - - // Durations that are too slow will get transitions mixed up. - // (Tested on Mac/FF 7.0.1) - if ((support.transition === 'MozTransition') && (i < 25)) i = 25; - - window.setTimeout(function() { run(next); }, i); - }; - - // Use jQuery's fx queue. - callOrQueue(self, queue, deferredRun); - - // Chainability. - return this; - }; - - function registerCssHook(prop, isPixels) { - // For certain properties, the 'px' should not be implied. - if (!isPixels) $.cssNumber[prop] = true; - - $.cssHooks[prop] = { - get: function(elem) { - var t = $(elem).css('transform') || new Transform; - return t.get(prop); - }, - - set: function(elem, value) { - var t = $(elem).css('transform') || new Transform; - t.setFromString(prop, value); - - $(elem).css({ transform: t }); - } - }; - } - - // ### unit(number, unit) - // Ensures that number `number` has a unit. If no unit is found, assume the - // default is `unit`. - // - // unit(2, 'px') //=> "2px" - // unit("30deg", 'rad') //=> "30deg" - // - function unit(i, unit) { - if ((typeof i === "string") && (!i.match(/^[\-0-9\.]+$/))) - return i; - else - return "" + i + unit; - } - - // ### toMS(duration) - // Converts given `duration` to a millisecond string. - // - // toMS('fast') //=> '400ms' - // toMS(10) //=> '10ms' - // - function toMS(duration) { - var i = duration; - - // Allow for string durations like 'fast'. - if ($.fx.speeds[i]) i = $.fx.speeds[i]; - - return unit(i, 'ms'); - } -})(jQuery); diff --git a/site/jquery.transit-0.1.0.min.js b/site/jquery.transit-0.1.0.min.js deleted file mode 100644 index f62ebd8..0000000 --- a/site/jquery.transit-0.1.0.min.js +++ /dev/null @@ -1,17 +0,0 @@ -/*! - * jQuery Transit - CSS3 transitions and transformations - * Copyright(c) 2011 Rico Sta. Cruz - * MIT Licensed. - * - * http://ricostacruz.com/jquery.transit - * http://github.com/rstacruz/jquery.transit - */ -(function(d){function k(a){var b=["Moz","Webkit","O","ms"],c=a.charAt(0).toUpperCase()+a.substr(1);if(a in l.style)return a;for(a=0;a0&&(this.style[j.transition]=k);d(this).css(a)});var c=false,f=function(){c&&g.unbind(n,f);m>0&&g.each(function(){this.style[j.transition]= -l[this]});typeof e==="function"&&e.apply(g);typeof b==="function"&&b()};m>0&&n?(c=true,g.bind(n,f)):window.setTimeout(f,m)};o(g,h,function(a){var b=0;j.transition==="MozTransition"&&b<25&&(b=25);window.setTimeout(function(){q(a)},b)});return this}})(jQuery); diff --git a/site/jquery.transit-0.1.1.js b/site/jquery.transit-0.1.1.js deleted file mode 100644 index 0e48e09..0000000 --- a/site/jquery.transit-0.1.1.js +++ /dev/null @@ -1,608 +0,0 @@ -/*! - * jQuery Transit - CSS3 transitions and transformations - * Copyright(c) 2011 Rico Sta. Cruz - * MIT Licensed. - * - * http://ricostacruz.com/jquery.transit - * http://github.com/rstacruz/jquery.transit - */ - -(function($) { - $.transit = { - version: "0.1.1", - - // Map of $.css() keys to values for 'transitionProperty'. - // See https://developer.mozilla.org/en/CSS/CSS_transitions#Properties_that_can_be_animated - propertyMap: { - marginLeft : 'margin', - marginRight : 'margin', - marginBottom : 'margin', - marginTop : 'margin', - paddingLeft : 'padding', - paddingRight : 'padding', - paddingBottom : 'padding', - paddingTop : 'padding' - }, - - // Will simply transition "instantly" if false - enabled: true - }; - - var div = document.createElement('div'); - - // Helper function to get the proper vendor property name. - // (`transition` => `WebkitTransition`) - function getVendorPropertyName(prop) { - var prefixes = ['Moz', 'Webkit', 'O', 'ms']; - var prop_ = prop.charAt(0).toUpperCase() + prop.substr(1); - - if (prop in div.style) return prop; - - for (var i=0; i { rotate: '90deg' } - // - $.cssHooks.transform = { - // The getter returns a `Transform` object. - get: function(elem) { - return $(elem).data('transform'); - }, - - // The setter accepts a `Transform` object or a string. - set: function(elem, v) { - var value = v; - if (!(value instanceof Transform)) - value = new Transform(value); - - if (support.transform == 'WebkitTransform') - elem.style[support.transform] = value.toString(true); - else - elem.style[support.transform] = value.toString(); - - $(elem).data('transform', value); - } - }; - - // ## 'transformOrigin' CSS hook - // Allows the use for `transformOrigin` to define where scaling and rotation - // is pivoted. - // - // $("#hello").css({ transformOrigin: '0 0' }); - // - $.cssHooks.transformOrigin = { - get: function(elem) { - return elem.style[support.transformOrigin]; - }, - set: function(elem, value) { - elem.style[support.transformOrigin] = value; - } - }; - - // ## Other CSS hooks - // Allows you to rotate, scale and translate. - registerCssHook('scale'); - registerCssHook('translate'); - registerCssHook('rotate'); - registerCssHook('rotateX'); - registerCssHook('rotateY'); - registerCssHook('rotate3d'); - registerCssHook('perspective'); - registerCssHook('skewX'); - registerCssHook('skewY'); - registerCssHook('x', true); - registerCssHook('y', true); - - // ## Transform class - // This is the main class of a transformation property that powers - // `$.fn.css({ transform: '...' })`. - // - // This is, in essence, a dictionary object with key/values as `-transform` - // properties. - // - // var t = new Transform("rotate(90) scale(4)"); - // - // t.rotate //=> "90deg" - // t.scale //=> "4,4" - // - // Setters are accounted for. - // - // t.set('rotate', 4) - // t.rotate //=> "4deg" - // - // Convert it to a CSS string using the `toString()` and `toWebkitString()` - // functions. - // - // t.toString() //=> "rotate(90deg) scale(4,4)" - // t.toWebkitString() //=> "rotate(90deg) scale3d(4,4,0)" - // - function Transform(str) { - if (typeof str === 'string') this.parse(str); - return this; - }; - - Transform.prototype = { - // ### setFromString() - // Sets a property from a string. - // - // t.setFromString('scale', '2,4'); - // // Same as set('scale', '2', '4'); - // - setFromString: function(prop, val) { - var args = - (typeof val === 'string') ? val.split(',') : - (val.constructor == Array) ? val : - [ val ]; - - args.unshift(prop); - - Transform.prototype.set.apply(this, args); - }, - - // ### set() - // Sets a property. - // - // t.set('scale', 2, 4); - // - set: function(prop) { - var args = Array.prototype.slice.apply(arguments, [1]); - if (this.setter[prop]) { - this.setter[prop].apply(this, args); - } else { - this[prop] = args.join(','); - } - }, - - get: function(prop) { - if (this.getter[prop]) { - return this.getter[prop].apply(this); - } else { - return this[prop] || 0; - } - }, - - setter: { - // ### rotate - // - // .css({ rotate: 30 }) - // .css({ rotate: "30" }) - // .css({ rotate: "30deg" }) - // .css({ rotate: "30deg" }) - // - rotate: function(theta) { - this.rotate = unit(theta, 'deg'); - }, - - rotateX: function(theta) { - this.rotateX = unit(theta, 'deg'); - }, - - rotateY: function(theta) { - this.rotateY = unit(theta, 'deg'); - }, - - // ### scale - // - // .css({ scale: 9 }) //=> "scale(9,9)" - // .css({ scale: '3,2' }) //=> "scale(3,2)" - // - scale: function(x, y) { - if (y === undefined) y = x; - this.scale = x + "," + y; - }, - - // ### skewX + skewY - skewX: function(x) { - this.skewX = unit(x, 'deg'); - }, - - skewY: function(y) { - this.skewY = unit(y, 'deg'); - }, - - // ### perspectvie - perspective: function(dist) { - this.perspective = unit(dist, 'px'); - }, - - // ### x / y - // Translations. Notice how this keeps the other value. - // - // .css({ x: 4 }) //=> "translate(4px, 0)" - // .css({ y: 10 }) //=> "translate(4px, 10px)" - // - x: function(x) { - this.set('translate', x, null); - }, - - y: function(y) { - this.set('translate', null, y); - }, - - // ### translate - // Notice how this keeps the other value. - // - // .css({ translate: '2, 5' }) //=> "translate(2px, 5px)" - // - translate: function(x, y) { - if (this._translateX === undefined) this._translateX = 0; - if (this._translateY === undefined) this._translateY = 0; - - if (x !== null) this._translateX = unit(x, 'px'); - if (y !== null) this._translateY = unit(y, 'px'); - - this.translate = this._translateX + "," + this._translateY; - } - }, - - getter: { - x: function() { - return this._translateX || 0; - }, - - y: function() { - return this._translateY || 0; - }, - - scale: function() { - var s = (this.scale || "1,1").split(','); - if (s[0]) s[0] = parseFloat(s[0]); - if (s[1]) s[1] = parseFloat(s[1]); - - // "2.5,2.5" => 2.5 - // "2.5,1" => [2.5,1] - return (s[0] == s[1]) ? s[0] : s; - }, - - rotate3d: function() { - var s = (this.rotate3d || "0,0,0,0deg").split(','); - for (i=0; i<=3; ++i) - if (s[i]) s[i] = parseFloat(s[i]); - if (s[3]) s[3] = unit(s[3], 'deg'); - - return s; - } - }, - - // ### parse() - // Parses from a string. Called on constructor. - parse: function(str) { - var self = this; - str.replace(/([a-zA-Z0-9]+)\((.*?)\)/g, function(x, prop, val) { - self.setFromString(prop, val); - }); - }, - - // ### toString() - // Converts to a `transition` CSS property string. If `use3d` is given, - // it converts to a `-webkit-transition` CSS property string instead. - toString: function(use3d) { - var re = []; - - for (i in this) { - if ((this.hasOwnProperty(i)) && (i[0] !== '_')) { - if ((use3d) && ((i === 'scale') || (i === 'translate'))) - re.push(i + "3d(" + this[i] + ",0)"); - else - re.push(i + "(" + this[i] + ")"); - } - } - - return re.join(" "); - } - }; - - function callOrQueue(self, queue, fn) { - if (queue === true) - self.queue(fn); - else if (queue) - self.queue(queue, fn) - else - fn(); - } - - // ### getProperties(dict) - // Returns properties (for `transition-property`) for dictionary `props`. The - // value of `props` is what you would expect in `$.css(...)`. - function getProperties(props) { - var re = []; - - $.each(props, function(key) { - key = $.camelCase(key); // Convert "text-align" => "textAlign" - key = $.transit.propertyMap[key] || key; - key = uncamel(key); // Convert back to dasherized - - if (re.indexOf(key) === -1) - re.push(key); - }); - - return re; - } - - // ### getTransition() - // Returns the transition string to be used for the `transition` CSS property. - // - // Example: - // - // getTransition({ opacity: 1, rotate: 30 }, 500, 'ease'); - // //=> 'opacity 500ms ease, -webkit-transform 500ms ease' - // - function getTransition(properties, duration, easing, delay) { - // Get the CSS properties needed. - var props = getProperties(properties); - - // Account for aliases (`in` => `ease-in`). - if ($.cssEase[easing]) easing = $.cssEase[easing]; - - // Build the duration/easing/delay attributes for it. - var attribs = '' + toMS(duration) + ' ' + easing; - if (parseInt(delay) > 0) - attribs += ' ' + toMS(delay); - - // For more properties, add them this way: - // "margin 200ms ease, padding 200ms ease, ..." - var transitions = []; - $.each(props, function(i, name) { - transitions.push(name + ' ' + attribs); - }); - - return transitions.join(', '); - } - - // ## $.fn.transition - // Works like $.fn.animate(), but uses CSS transitions. - // - // $("...").transition({ opacity: 0.1, scale: 0.3 }); - // - // // Specific duration - // $("...").transition({ opacity: 0.1, scale: 0.3 }, 500); - // - // // With duration and easing - // $("...").transition({ opacity: 0.1, scale: 0.3 }, 500, 'in'); - // - // // With callback - // $("...").transition({ opacity: 0.1, scale: 0.3 }, function() { ... }); - // - // // With everything - // $("...").transition({ opacity: 0.1, scale: 0.3 }, 500, 'in', function() { ... }); - // - // // Alternate syntax - // $("...").transition({ - // opacity: 0.1, - // duration: 200, - // delay: 40, - // easing: 'in', - // complete: function() { /* ... */ } - // }); - // - $.fn.transition = $.fn.transit = function(properties, duration, easing, callback) { - var self = this; - var delay = 0; - var queue = true; - - // Account for `.transition(properties, callback)`. - if (typeof duration === 'function') { - callback = duration; - duration = null; - } - - // Account for `.transition(properties, duration, callback)`. - if (typeof easing === 'function') { - callback = easing; - easing = null; - } - - // Alternate syntax. - if (properties.easing) { - easing = properties.easing; - delete properties.easing; - } - - if (properties.duration) { - duration = properties.duration; - delete properties.duration; - } - - if (properties.complete) { - callback = properties.complete; - delete properties.complete; - } - - if (properties.queue) { - queue = properties.queue; - delete properties.queue; - } - - if (properties.delay) { - delay = properties.delay; - delete properties.delay; - } - - // Set defaults. (`400` duration, `ease` easing) - if (duration == null) duration = $.fx.speeds._default; - if (easing == null) easing = $.cssEase._default; - - duration = toMS(duration); - - // Build the `transition` property. - var transitionValue = getTransition(properties, duration, easing, delay); - - // Compute delay until callback. - // If this becomes 0, don't bother setting the transition property. - var work = $.transit.enabled && support.transition; - var i = work ? (parseInt(duration) + parseInt(delay)) : 0; - - // If there's nothing to do... - if (i === 0) { - var fn = function(next) { - self.css(properties); - if (callback) callback(); - next(); - }; - - callOrQueue(self, queue, fn); - return self; - } - - // Save the old transitions of each element so we can restore it later. - var oldTransitions = {}; - - var run = function(nextCall) { - // Apply transitions. - self.each(function() { - if (i > 0) { - this.style[support.transition] = transitionValue; - } - $(this).css(properties); - }); - - var bound = false; - - // Prepare the callback. - var cb = function() { - if (bound) self.unbind(transitionEnd, cb); - - if (i > 0) { - self.each(function() { - this.style[support.transition] = oldTransitions[this]; - }); - } - - if (typeof callback === 'function') callback.apply(self); - if (typeof nextCall === 'function') nextCall(); - }; - - if ((i > 0) && (transitionEnd)) { - // Use the 'transitionend' event if it's available. - bound = true; - self.bind(transitionEnd, cb); - } else { - // Fallback to timers if the 'transitionend' event isn't supported. - window.setTimeout(cb, i); - } - }; - - // Defer running. This allows the browser to paint any pending CSS it hasn't - // painted yet before doing the transitions. - var deferredRun = function(next) { - var i = 0; - - // Durations that are too slow will get transitions mixed up. - // (Tested on Mac/FF 7.0.1) - if ((support.transition === 'MozTransition') && (i < 25)) i = 25; - - window.setTimeout(function() { run(next); }, i); - }; - - // Use jQuery's fx queue. - callOrQueue(self, queue, deferredRun); - - // Chainability. - return this; - }; - - function registerCssHook(prop, isPixels) { - // For certain properties, the 'px' should not be implied. - if (!isPixels) $.cssNumber[prop] = true; - - $.transit.propertyMap[prop] = support.transform; - - $.cssHooks[prop] = { - get: function(elem) { - var t = $(elem).css('transform') || new Transform; - return t.get(prop); - }, - - set: function(elem, value) { - var t = $(elem).css('transform') || new Transform; - t.setFromString(prop, value); - - $(elem).css({ transform: t }); - } - }; - } - - // ### uncamel(str) - // Converts a camelcase string to a dasherized string. - // (`marginLeft` => `margin-left`) - function uncamel(str) { - return str.replace(/([A-Z])/g, function(letter) { return '-' + letter.toLowerCase(); }) - } - - // ### unit(number, unit) - // Ensures that number `number` has a unit. If no unit is found, assume the - // default is `unit`. - // - // unit(2, 'px') //=> "2px" - // unit("30deg", 'rad') //=> "30deg" - // - function unit(i, unit) { - if ((typeof i === "string") && (!i.match(/^[\-0-9\.]+$/))) - return i; - else - return "" + i + unit; - } - - // ### toMS(duration) - // Converts given `duration` to a millisecond string. - // - // toMS('fast') //=> '400ms' - // toMS(10) //=> '10ms' - // - function toMS(duration) { - var i = duration; - - // Allow for string durations like 'fast'. - if ($.fx.speeds[i]) i = $.fx.speeds[i]; - - return unit(i, 'ms'); - } - - // Export some functions for testable-ness. - $.transit.getTransitionValue = getTransition; -})(jQuery); diff --git a/site/jquery.transit-0.1.1.min.js b/site/jquery.transit-0.1.1.min.js deleted file mode 100644 index 35a1046..0000000 --- a/site/jquery.transit-0.1.1.min.js +++ /dev/null @@ -1,18 +0,0 @@ -/*! - * jQuery Transit - CSS3 transitions and transformations - * Copyright(c) 2011 Rico Sta. Cruz - * MIT Licensed. - * - * http://ricostacruz.com/jquery.transit - * http://github.com/rstacruz/jquery.transit - */ -(function(c){function k(a){var b=["Moz","Webkit","O","ms"],d=a.charAt(0).toUpperCase()+a.substr(1);if(a in l.style)return a;for(a=0;a=i;++i)a[i]&& -(a[i]=parseFloat(a[i]));a[3]&&(a[3]=g(a[3],"deg"));return a}},parse:function(a){var b=this;a.replace(/([a-zA-Z0-9]+)\((.*?)\)/g,function(a,c,f){b.setFromString(c,f)})},toString:function(a){var b=[];for(i in this)this.hasOwnProperty(i)&&"_"!==i[0]&&(a&&("scale"===i||"translate"===i)?b.push(i+"3d("+this[i]+",0)"):b.push(i+"("+this[i]+")"));return b.join(" ")}};c.fn.transition=c.fn.transit=function(a,b,d,e){var f=this,g=0,j=!0;"function"===typeof b&&(e=b,b=null);"function"===typeof d&&(e=d,d=null);if(a.easing)d= -a.easing,delete a.easing;if(a.duration)b=a.duration,delete a.duration;if(a.complete)e=a.complete,delete a.complete;if(a.queue)j=a.queue,delete a.queue;if(a.delay)g=a.delay,delete a.delay;if(null==b)b=c.fx.speeds._default;if(null==d)d=c.cssEase._default;var b=o(b),k=s(a,b,d,g),m=c.transit.enabled&&h.transition?parseInt(b)+parseInt(g):0;if(0===m)return r(f,j,function(b){f.css(a);e&&e();b()}),f;var l={},n=function(b){f.each(function(){0b&&(b=25);window.setTimeout(function(){n(a)},b)});return this};c.transit.getTransitionValue=s})(jQuery); diff --git a/site/jquery.transit-0.1.2.js b/site/jquery.transit-0.1.2.js deleted file mode 100644 index 866fa00..0000000 --- a/site/jquery.transit-0.1.2.js +++ /dev/null @@ -1,624 +0,0 @@ -/*! - * jQuery Transit - CSS3 transitions and transformations - * Copyright(c) 2011 Rico Sta. Cruz - * MIT Licensed. - * - * http://ricostacruz.com/jquery.transit - * http://github.com/rstacruz/jquery.transit - */ - -(function($) { - "use strict"; - - $.transit = { - version: "0.1.2", - - // Map of $.css() keys to values for 'transitionProperty'. - // See https://developer.mozilla.org/en/CSS/CSS_transitions#Properties_that_can_be_animated - propertyMap: { - marginLeft : 'margin', - marginRight : 'margin', - marginBottom : 'margin', - marginTop : 'margin', - paddingLeft : 'padding', - paddingRight : 'padding', - paddingBottom : 'padding', - paddingTop : 'padding' - }, - - // Will simply transition "instantly" if false - enabled: true - }; - - var div = document.createElement('div'); - - // Helper function to get the proper vendor property name. - // (`transition` => `WebkitTransition`) - function getVendorPropertyName(prop) { - var prefixes = ['Moz', 'Webkit', 'O', 'ms']; - var prop_ = prop.charAt(0).toUpperCase() + prop.substr(1); - - if (prop in div.style) { return prop; } - - for (var i=0; i -1; - - // Check for the browser's transitions support. - // You can access this in jQuery's `$.support.transition`. - // As per [jQuery's cssHooks documentation](http://api.jquery.com/jQuery.cssHooks/), - // we set $.support.transition to a string of the actual property name used. - var support = { - transition : getVendorPropertyName('transition'), - transitionDelay : getVendorPropertyName('transitionDelay'), - transform : getVendorPropertyName('transform'), - transformOrigin : getVendorPropertyName('transformOrigin') - }; - - $.extend($.support, support); - - var eventNames = { - 'MozTransition': 'transitionend', - 'OTransition': 'oTransitionEnd', - 'WebkitTransition': 'webkitTransitionEnd', - 'msTransition': 'MSTransitionEnd' - }; - - // Detect the 'transitionend' event needed. - var transitionEnd = eventNames[support.transition] || null; - - // Avoid memory leak in IE. - div = null; - - // ## $.cssEase - // List of easing aliases that you can use with `$.fn.transition`. - $.cssEase = { - '_default': 'ease', - 'in': 'ease-in', - 'out': 'ease-out', - 'in-out': 'ease-in-out', - 'snap': 'cubic-bezier(0,1,.5,1)' - }; - - // ## 'transform' CSS hook - // Allows you to use the `transform` property in CSS. - // - // $("#hello").css({ transform: "rotate(90deg)" }); - // - // $("#hello").css('transform'); - // //=> { rotate: '90deg' } - // - $.cssHooks.transform = { - // The getter returns a `Transform` object. - get: function(elem) { - return $(elem).data('transform'); - }, - - // The setter accepts a `Transform` object or a string. - set: function(elem, v) { - var value = v; - - if (!(value instanceof Transform)) { - value = new Transform(value); - } - - // We've seen the 3D version of Scale() not work in Chrome when the - // element being scaled extends outside of the viewport. Thus, we're - // forcing Chrome to not use the 3d transforms as well. Not sure if - // translate is affectede, but not risking it. Detection code from - // http://davidwalsh.name/detecting-google-chrome-javascript - if (support.transform === 'WebkitTransform' && !isChrome) { - elem.style[support.transform] = value.toString(true); - } else { - elem.style[support.transform] = value.toString(); - } - - $(elem).data('transform', value); - } - }; - - // ## 'transformOrigin' CSS hook - // Allows the use for `transformOrigin` to define where scaling and rotation - // is pivoted. - // - // $("#hello").css({ transformOrigin: '0 0' }); - // - $.cssHooks.transformOrigin = { - get: function(elem) { - return elem.style[support.transformOrigin]; - }, - set: function(elem, value) { - elem.style[support.transformOrigin] = value; - } - }; - - // ## Other CSS hooks - // Allows you to rotate, scale and translate. - registerCssHook('scale'); - registerCssHook('translate'); - registerCssHook('rotate'); - registerCssHook('rotateX'); - registerCssHook('rotateY'); - registerCssHook('rotate3d'); - registerCssHook('perspective'); - registerCssHook('skewX'); - registerCssHook('skewY'); - registerCssHook('x', true); - registerCssHook('y', true); - - // ## Transform class - // This is the main class of a transformation property that powers - // `$.fn.css({ transform: '...' })`. - // - // This is, in essence, a dictionary object with key/values as `-transform` - // properties. - // - // var t = new Transform("rotate(90) scale(4)"); - // - // t.rotate //=> "90deg" - // t.scale //=> "4,4" - // - // Setters are accounted for. - // - // t.set('rotate', 4) - // t.rotate //=> "4deg" - // - // Convert it to a CSS string using the `toString()` and `toString(true)` (for WebKit) - // functions. - // - // t.toString() //=> "rotate(90deg) scale(4,4)" - // t.toString(true) //=> "rotate(90deg) scale3d(4,4,0)" (WebKit version) - // - function Transform(str) { - if (typeof str === 'string') { this.parse(str); } - return this; - } - - Transform.prototype = { - // ### setFromString() - // Sets a property from a string. - // - // t.setFromString('scale', '2,4'); - // // Same as set('scale', '2', '4'); - // - setFromString: function(prop, val) { - var args = - (typeof val === 'string') ? val.split(',') : - (val.constructor === Array) ? val : - [ val ]; - - args.unshift(prop); - - Transform.prototype.set.apply(this, args); - }, - - // ### set() - // Sets a property. - // - // t.set('scale', 2, 4); - // - set: function(prop) { - var args = Array.prototype.slice.apply(arguments, [1]); - if (this.setter[prop]) { - this.setter[prop].apply(this, args); - } else { - this[prop] = args.join(','); - } - }, - - get: function(prop) { - if (this.getter[prop]) { - return this.getter[prop].apply(this); - } else { - return this[prop] || 0; - } - }, - - setter: { - // ### rotate - // - // .css({ rotate: 30 }) - // .css({ rotate: "30" }) - // .css({ rotate: "30deg" }) - // .css({ rotate: "30deg" }) - // - rotate: function(theta) { - this.rotate = unit(theta, 'deg'); - }, - - rotateX: function(theta) { - this.rotateX = unit(theta, 'deg'); - }, - - rotateY: function(theta) { - this.rotateY = unit(theta, 'deg'); - }, - - // ### scale - // - // .css({ scale: 9 }) //=> "scale(9,9)" - // .css({ scale: '3,2' }) //=> "scale(3,2)" - // - scale: function(x, y) { - if (y === undefined) { y = x; } - this.scale = x + "," + y; - }, - - // ### skewX + skewY - skewX: function(x) { - this.skewX = unit(x, 'deg'); - }, - - skewY: function(y) { - this.skewY = unit(y, 'deg'); - }, - - // ### perspectvie - perspective: function(dist) { - this.perspective = unit(dist, 'px'); - }, - - // ### x / y - // Translations. Notice how this keeps the other value. - // - // .css({ x: 4 }) //=> "translate(4px, 0)" - // .css({ y: 10 }) //=> "translate(4px, 10px)" - // - x: function(x) { - this.set('translate', x, null); - }, - - y: function(y) { - this.set('translate', null, y); - }, - - // ### translate - // Notice how this keeps the other value. - // - // .css({ translate: '2, 5' }) //=> "translate(2px, 5px)" - // - translate: function(x, y) { - if (this._translateX === undefined) { this._translateX = 0; } - if (this._translateY === undefined) { this._translateY = 0; } - - if (x !== null) { this._translateX = unit(x, 'px'); } - if (y !== null) { this._translateY = unit(y, 'px'); } - - this.translate = this._translateX + "," + this._translateY; - } - }, - - getter: { - x: function() { - return this._translateX || 0; - }, - - y: function() { - return this._translateY || 0; - }, - - scale: function() { - var s = (this.scale || "1,1").split(','); - if (s[0]) { s[0] = parseFloat(s[0]); } - if (s[1]) { s[1] = parseFloat(s[1]); } - - // "2.5,2.5" => 2.5 - // "2.5,1" => [2.5,1] - return (s[0] === s[1]) ? s[0] : s; - }, - - rotate3d: function() { - var s = (this.rotate3d || "0,0,0,0deg").split(','); - for (var i=0; i<=3; ++i) { - if (s[i]) { s[i] = parseFloat(s[i]); } - } - if (s[3]) { s[3] = unit(s[3], 'deg'); } - - return s; - } - }, - - // ### parse() - // Parses from a string. Called on constructor. - parse: function(str) { - var self = this; - str.replace(/([a-zA-Z0-9]+)\((.*?)\)/g, function(x, prop, val) { - self.setFromString(prop, val); - }); - }, - - // ### toString() - // Converts to a `transition` CSS property string. If `use3d` is given, - // it converts to a `-webkit-transition` CSS property string instead. - toString: function(use3d) { - var re = []; - - for (var i in this) { - if ((this.hasOwnProperty(i)) && (i[0] !== '_')) { - if (use3d && (i === 'scale')) { - re.push(i + "3d(" + this[i] + ",1)"); - } else if (use3d && (i === 'translate')) { - re.push(i + "3d(" + this[i] + ",0)"); - } else { - re.push(i + "(" + this[i] + ")"); - } - } - } - - return re.join(" "); - } - }; - - function callOrQueue(self, queue, fn) { - if (queue === true) { - self.queue(fn); - } else if (queue) { - self.queue(queue, fn); - } else { - fn(); - } - } - - // ### getProperties(dict) - // Returns properties (for `transition-property`) for dictionary `props`. The - // value of `props` is what you would expect in `$.css(...)`. - function getProperties(props) { - var re = []; - - $.each(props, function(key) { - key = $.camelCase(key); // Convert "text-align" => "textAlign" - key = $.transit.propertyMap[key] || key; - key = uncamel(key); // Convert back to dasherized - - if ($.inArray(key, re) === -1) { re.push(key); } - }); - - return re; - } - - // ### getTransition() - // Returns the transition string to be used for the `transition` CSS property. - // - // Example: - // - // getTransition({ opacity: 1, rotate: 30 }, 500, 'ease'); - // //=> 'opacity 500ms ease, -webkit-transform 500ms ease' - // - function getTransition(properties, duration, easing, delay) { - // Get the CSS properties needed. - var props = getProperties(properties); - - // Account for aliases (`in` => `ease-in`). - if ($.cssEase[easing]) { easing = $.cssEase[easing]; } - - // Build the duration/easing/delay attributes for it. - var attribs = '' + toMS(duration) + ' ' + easing; - if (parseInt(delay, 10) > 0) { attribs += ' ' + toMS(delay); } - - // For more properties, add them this way: - // "margin 200ms ease, padding 200ms ease, ..." - var transitions = []; - $.each(props, function(i, name) { - transitions.push(name + ' ' + attribs); - }); - - return transitions.join(', '); - } - - // ## $.fn.transition - // Works like $.fn.animate(), but uses CSS transitions. - // - // $("...").transition({ opacity: 0.1, scale: 0.3 }); - // - // // Specific duration - // $("...").transition({ opacity: 0.1, scale: 0.3 }, 500); - // - // // With duration and easing - // $("...").transition({ opacity: 0.1, scale: 0.3 }, 500, 'in'); - // - // // With callback - // $("...").transition({ opacity: 0.1, scale: 0.3 }, function() { ... }); - // - // // With everything - // $("...").transition({ opacity: 0.1, scale: 0.3 }, 500, 'in', function() { ... }); - // - // // Alternate syntax - // $("...").transition({ - // opacity: 0.1, - // duration: 200, - // delay: 40, - // easing: 'in', - // complete: function() { /* ... */ } - // }); - // - $.fn.transition = $.fn.transit = function(properties, duration, easing, callback) { - var self = this; - var delay = 0; - var queue = true; - - // Account for `.transition(properties, callback)`. - if (typeof duration === 'function') { - callback = duration; - duration = undefined; - } - - // Account for `.transition(properties, duration, callback)`. - if (typeof easing === 'function') { - callback = easing; - easing = undefined; - } - - // Alternate syntax. - if (typeof properties.easing !== 'undefined') { - easing = properties.easing; - delete properties.easing; - } - - if (typeof properties.duration !== 'undefined') { - duration = properties.duration; - delete properties.duration; - } - - if (typeof properties.complete !== 'undefined') { - callback = properties.complete; - delete properties.complete; - } - - if (typeof properties.queue !== 'undefined') { - queue = properties.queue; - delete properties.queue; - } - - if (properties.delay) { - delay = properties.delay; - delete properties.delay; - } - - // Set defaults. (`400` duration, `ease` easing) - if (typeof duration === 'undefined') { duration = $.fx.speeds._default; } - if (typeof easing === 'undefined') { easing = $.cssEase._default; } - - duration = toMS(duration); - - // Build the `transition` property. - var transitionValue = getTransition(properties, duration, easing, delay); - - // Compute delay until callback. - // If this becomes 0, don't bother setting the transition property. - var work = $.transit.enabled && support.transition; - var i = work ? (parseInt(duration, 10) + parseInt(delay, 10)) : 0; - - // If there's nothing to do... - if (i === 0) { - var fn = function(next) { - self.css(properties); - if (callback) { callback(); } - next(); - }; - - callOrQueue(self, queue, fn); - return self; - } - - // Save the old transitions of each element so we can restore it later. - var oldTransitions = {}; - - var run = function(nextCall) { - var bound = false; - - // Prepare the callback. - var cb = function() { - if (bound) { self.unbind(transitionEnd, cb); } - - if (i > 0) { - self.each(function() { - this.style[support.transition] = (oldTransitions[this] || null); - }); - } - - if (typeof callback === 'function') { callback.apply(self); } - if (typeof nextCall === 'function') { nextCall(); } - }; - - if ((i > 0) && (transitionEnd)) { - // Use the 'transitionend' event if it's available. - bound = true; - self.bind(transitionEnd, cb); - } else { - // Fallback to timers if the 'transitionend' event isn't supported. - window.setTimeout(cb, i); - } - - // Apply transitions. - self.each(function() { - if (i > 0) { - this.style[support.transition] = transitionValue; - } - $(this).css(properties); - }); - }; - - // Defer running. This allows the browser to paint any pending CSS it hasn't - // painted yet before doing the transitions. - var deferredRun = function(next) { - var i = 0; - - // Durations that are too slow will get transitions mixed up. - // (Tested on Mac/FF 7.0.1) - if ((support.transition === 'MozTransition') && (i < 25)) { i = 25; } - - window.setTimeout(function() { run(next); }, i); - }; - - // Use jQuery's fx queue. - callOrQueue(self, queue, deferredRun); - - // Chainability. - return this; - }; - - function registerCssHook(prop, isPixels) { - // For certain properties, the 'px' should not be implied. - if (!isPixels) { $.cssNumber[prop] = true; } - - $.transit.propertyMap[prop] = support.transform; - - $.cssHooks[prop] = { - get: function(elem) { - var t = $(elem).css('transform') || new Transform(); - return t.get(prop); - }, - - set: function(elem, value) { - var t = $(elem).css('transform') || new Transform(); - t.setFromString(prop, value); - - $(elem).css({ transform: t }); - } - }; - } - - // ### uncamel(str) - // Converts a camelcase string to a dasherized string. - // (`marginLeft` => `margin-left`) - function uncamel(str) { - return str.replace(/([A-Z])/g, function(letter) { return '-' + letter.toLowerCase(); }); - } - - // ### unit(number, unit) - // Ensures that number `number` has a unit. If no unit is found, assume the - // default is `unit`. - // - // unit(2, 'px') //=> "2px" - // unit("30deg", 'rad') //=> "30deg" - // - function unit(i, units) { - if ((typeof i === "string") && (!i.match(/^[\-0-9\.]+$/))) { - return i; - } else { - return "" + i + units; - } - } - - // ### toMS(duration) - // Converts given `duration` to a millisecond string. - // - // toMS('fast') //=> '400ms' - // toMS(10) //=> '10ms' - // - function toMS(duration) { - var i = duration; - - // Allow for string durations like 'fast'. - if ($.fx.speeds[i]) { i = $.fx.speeds[i]; } - - return unit(i, 'ms'); - } - - // Export some functions for testable-ness. - $.transit.getTransitionValue = getTransition; -})(jQuery); diff --git a/site/jquery.transit-0.1.2.min.js b/site/jquery.transit-0.1.2.min.js deleted file mode 100644 index 6d7228d..0000000 --- a/site/jquery.transit-0.1.2.min.js +++ /dev/null @@ -1,19 +0,0 @@ -/*! - * jQuery Transit - CSS3 transitions and transformations - * Copyright(c) 2011 Rico Sta. Cruz - * MIT Licensed. - * - * http://ricostacruz.com/jquery.transit - * http://github.com/rstacruz/jquery.transit - */ -(function(d){function j(a){var b=["Moz","Webkit","O","ms"],c=a.charAt(0).toUpperCase()+a.substr(1);if(a in k.style)return a;for(a=0;a=b;++b)a[b]&&(a[b]=parseFloat(a[b]));a[3]&&(a[3]=g(a[3],"deg"));return a}},parse:function(a){var b=this;a.replace(/([a-zA-Z0-9]+)\((.*?)\)/g,function(a,d,f){b.setFromString(d,f)})},toString:function(a){var b=[],c;for(c in this)this.hasOwnProperty(c)&&"_"!==c[0]&&(a&&"scale"===c?b.push(c+"3d("+this[c]+",1)"):a&&"translate"===c?b.push(c+"3d("+this[c]+",0)"):b.push(c+"("+this[c]+")"));return b.join(" ")}}; -d.fn.transition=d.fn.transit=function(a,b,c,e){var f=this,g=0,i=!0;"function"===typeof b&&(e=b,b=void 0);"function"===typeof c&&(e=c,c=void 0);if("undefined"!==typeof a.easing)c=a.easing,delete a.easing;if("undefined"!==typeof a.duration)b=a.duration,delete a.duration;if("undefined"!==typeof a.complete)e=a.complete,delete a.complete;if("undefined"!==typeof a.queue)i=a.queue,delete a.queue;if(a.delay)g=a.delay,delete a.delay;if("undefined"===typeof b)b=d.fx.speeds._default;if("undefined"===typeof c)c= -d.cssEase._default;var b=n(b),j=r(a,b,c,g),l=d.transit.enabled&&h.transition?parseInt(b,10)+parseInt(g,10):0;if(0===l)return q(f,i,function(b){f.css(a);e&&e();b()}),f;var k={},m=function(b){var c=!1,g=function(){c&&f.unbind(o,g);0b&&(b=25);window.setTimeout(function(){m(a)},b)});return this};d.transit.getTransitionValue=r})(jQuery); diff --git a/site/jquery.transit-0.1.3.js b/site/jquery.transit-0.1.3.js deleted file mode 100644 index 6f810b1..0000000 --- a/site/jquery.transit-0.1.3.js +++ /dev/null @@ -1,644 +0,0 @@ -/*! - * jQuery Transit - CSS3 transitions and transformations - * Copyright(c) 2011 Rico Sta. Cruz - * MIT Licensed. - * - * http://ricostacruz.com/jquery.transit - * http://github.com/rstacruz/jquery.transit - */ - -(function($) { - "use strict"; - - $.transit = { - version: "0.1.3", - - // Map of $.css() keys to values for 'transitionProperty'. - // See https://developer.mozilla.org/en/CSS/CSS_transitions#Properties_that_can_be_animated - propertyMap: { - marginLeft : 'margin', - marginRight : 'margin', - marginBottom : 'margin', - marginTop : 'margin', - paddingLeft : 'padding', - paddingRight : 'padding', - paddingBottom : 'padding', - paddingTop : 'padding' - }, - - // Will simply transition "instantly" if false - enabled: true, - - // Set this to false if you don't want to use the transition end property. - useTransitionEnd: false - }; - - var div = document.createElement('div'); - var support = {}; - - // Helper function to get the proper vendor property name. - // (`transition` => `WebkitTransition`) - function getVendorPropertyName(prop) { - var prefixes = ['Moz', 'Webkit', 'O', 'ms']; - var prop_ = prop.charAt(0).toUpperCase() + prop.substr(1); - - if (prop in div.style) { return prop; } - - for (var i=0; i -1; - - // Check for the browser's transitions support. - // You can access this in jQuery's `$.support.transition`. - // As per [jQuery's cssHooks documentation](http://api.jquery.com/jQuery.cssHooks/), - // we set $.support.transition to a string of the actual property name used. - support.transition = getVendorPropertyName('transition'); - support.transitionDelay = getVendorPropertyName('transitionDelay'); - support.transform = getVendorPropertyName('transform'); - support.transformOrigin = getVendorPropertyName('transformOrigin'); - support.transform3d = checkTransform3dSupport(); - - $.extend($.support, support); - - var eventNames = { - 'MozTransition': 'transitionend', - 'OTransition': 'oTransitionEnd', - 'WebkitTransition': 'webkitTransitionEnd', - 'msTransition': 'MSTransitionEnd' - }; - - // Detect the 'transitionend' event needed. - var transitionEnd = support.transitionEnd = eventNames[support.transition] || null; - - // Avoid memory leak in IE. - div = null; - - // ## $.cssEase - // List of easing aliases that you can use with `$.fn.transition`. - $.cssEase = { - '_default': 'ease', - 'in': 'ease-in', - 'out': 'ease-out', - 'in-out': 'ease-in-out', - 'snap': 'cubic-bezier(0,1,.5,1)' - }; - - // ## 'transform' CSS hook - // Allows you to use the `transform` property in CSS. - // - // $("#hello").css({ transform: "rotate(90deg)" }); - // - // $("#hello").css('transform'); - // //=> { rotate: '90deg' } - // - $.cssHooks.transform = { - // The getter returns a `Transform` object. - get: function(elem) { - return $(elem).data('transform'); - }, - - // The setter accepts a `Transform` object or a string. - set: function(elem, v) { - var value = v; - - if (!(value instanceof Transform)) { - value = new Transform(value); - } - - // We've seen the 3D version of Scale() not work in Chrome when the - // element being scaled extends outside of the viewport. Thus, we're - // forcing Chrome to not use the 3d transforms as well. Not sure if - // translate is affectede, but not risking it. Detection code from - // http://davidwalsh.name/detecting-google-chrome-javascript - if (support.transform === 'WebkitTransform' && !isChrome) { - elem.style[support.transform] = value.toString(true); - } else { - elem.style[support.transform] = value.toString(); - } - - $(elem).data('transform', value); - } - }; - - // ## 'transformOrigin' CSS hook - // Allows the use for `transformOrigin` to define where scaling and rotation - // is pivoted. - // - // $("#hello").css({ transformOrigin: '0 0' }); - // - $.cssHooks.transformOrigin = { - get: function(elem) { - return elem.style[support.transformOrigin]; - }, - set: function(elem, value) { - elem.style[support.transformOrigin] = value; - } - }; - - // ## Other CSS hooks - // Allows you to rotate, scale and translate. - registerCssHook('scale'); - registerCssHook('translate'); - registerCssHook('rotate'); - registerCssHook('rotateX'); - registerCssHook('rotateY'); - registerCssHook('rotate3d'); - registerCssHook('perspective'); - registerCssHook('skewX'); - registerCssHook('skewY'); - registerCssHook('x', true); - registerCssHook('y', true); - - // ## Transform class - // This is the main class of a transformation property that powers - // `$.fn.css({ transform: '...' })`. - // - // This is, in essence, a dictionary object with key/values as `-transform` - // properties. - // - // var t = new Transform("rotate(90) scale(4)"); - // - // t.rotate //=> "90deg" - // t.scale //=> "4,4" - // - // Setters are accounted for. - // - // t.set('rotate', 4) - // t.rotate //=> "4deg" - // - // Convert it to a CSS string using the `toString()` and `toString(true)` (for WebKit) - // functions. - // - // t.toString() //=> "rotate(90deg) scale(4,4)" - // t.toString(true) //=> "rotate(90deg) scale3d(4,4,0)" (WebKit version) - // - function Transform(str) { - if (typeof str === 'string') { this.parse(str); } - return this; - } - - Transform.prototype = { - // ### setFromString() - // Sets a property from a string. - // - // t.setFromString('scale', '2,4'); - // // Same as set('scale', '2', '4'); - // - setFromString: function(prop, val) { - var args = - (typeof val === 'string') ? val.split(',') : - (val.constructor === Array) ? val : - [ val ]; - - args.unshift(prop); - - Transform.prototype.set.apply(this, args); - }, - - // ### set() - // Sets a property. - // - // t.set('scale', 2, 4); - // - set: function(prop) { - var args = Array.prototype.slice.apply(arguments, [1]); - if (this.setter[prop]) { - this.setter[prop].apply(this, args); - } else { - this[prop] = args.join(','); - } - }, - - get: function(prop) { - if (this.getter[prop]) { - return this.getter[prop].apply(this); - } else { - return this[prop] || 0; - } - }, - - setter: { - // ### rotate - // - // .css({ rotate: 30 }) - // .css({ rotate: "30" }) - // .css({ rotate: "30deg" }) - // .css({ rotate: "30deg" }) - // - rotate: function(theta) { - this.rotate = unit(theta, 'deg'); - }, - - rotateX: function(theta) { - this.rotateX = unit(theta, 'deg'); - }, - - rotateY: function(theta) { - this.rotateY = unit(theta, 'deg'); - }, - - // ### scale - // - // .css({ scale: 9 }) //=> "scale(9,9)" - // .css({ scale: '3,2' }) //=> "scale(3,2)" - // - scale: function(x, y) { - if (y === undefined) { y = x; } - this.scale = x + "," + y; - }, - - // ### skewX + skewY - skewX: function(x) { - this.skewX = unit(x, 'deg'); - }, - - skewY: function(y) { - this.skewY = unit(y, 'deg'); - }, - - // ### perspectvie - perspective: function(dist) { - this.perspective = unit(dist, 'px'); - }, - - // ### x / y - // Translations. Notice how this keeps the other value. - // - // .css({ x: 4 }) //=> "translate(4px, 0)" - // .css({ y: 10 }) //=> "translate(4px, 10px)" - // - x: function(x) { - this.set('translate', x, null); - }, - - y: function(y) { - this.set('translate', null, y); - }, - - // ### translate - // Notice how this keeps the other value. - // - // .css({ translate: '2, 5' }) //=> "translate(2px, 5px)" - // - translate: function(x, y) { - if (this._translateX === undefined) { this._translateX = 0; } - if (this._translateY === undefined) { this._translateY = 0; } - - if (x !== null) { this._translateX = unit(x, 'px'); } - if (y !== null) { this._translateY = unit(y, 'px'); } - - this.translate = this._translateX + "," + this._translateY; - } - }, - - getter: { - x: function() { - return this._translateX || 0; - }, - - y: function() { - return this._translateY || 0; - }, - - scale: function() { - var s = (this.scale || "1,1").split(','); - if (s[0]) { s[0] = parseFloat(s[0]); } - if (s[1]) { s[1] = parseFloat(s[1]); } - - // "2.5,2.5" => 2.5 - // "2.5,1" => [2.5,1] - return (s[0] === s[1]) ? s[0] : s; - }, - - rotate3d: function() { - var s = (this.rotate3d || "0,0,0,0deg").split(','); - for (var i=0; i<=3; ++i) { - if (s[i]) { s[i] = parseFloat(s[i]); } - } - if (s[3]) { s[3] = unit(s[3], 'deg'); } - - return s; - } - }, - - // ### parse() - // Parses from a string. Called on constructor. - parse: function(str) { - var self = this; - str.replace(/([a-zA-Z0-9]+)\((.*?)\)/g, function(x, prop, val) { - self.setFromString(prop, val); - }); - }, - - // ### toString() - // Converts to a `transition` CSS property string. If `use3d` is given, - // it converts to a `-webkit-transition` CSS property string instead. - toString: function(use3d) { - var re = []; - - for (var i in this) { - if (this.hasOwnProperty(i)) { - // Don't use 3D transformations if the browser can't support it. - if ((!support.transform3d) && ( - (i === 'rotateX') || - (i === 'rotateY') || - (i === 'perspective') || - (i === 'transformOrigin'))) { continue; } - - if (i[0] !== '_') { - if (use3d && (i === 'scale')) { - re.push(i + "3d(" + this[i] + ",1)"); - } else if (use3d && (i === 'translate')) { - re.push(i + "3d(" + this[i] + ",0)"); - } else { - re.push(i + "(" + this[i] + ")"); - } - } - } - } - - return re.join(" "); - } - }; - - function callOrQueue(self, queue, fn) { - if (queue === true) { - self.queue(fn); - } else if (queue) { - self.queue(queue, fn); - } else { - fn(); - } - } - - // ### getProperties(dict) - // Returns properties (for `transition-property`) for dictionary `props`. The - // value of `props` is what you would expect in `$.css(...)`. - function getProperties(props) { - var re = []; - - $.each(props, function(key) { - key = $.camelCase(key); // Convert "text-align" => "textAlign" - key = $.transit.propertyMap[key] || key; - key = uncamel(key); // Convert back to dasherized - - if ($.inArray(key, re) === -1) { re.push(key); } - }); - - return re; - } - - // ### getTransition() - // Returns the transition string to be used for the `transition` CSS property. - // - // Example: - // - // getTransition({ opacity: 1, rotate: 30 }, 500, 'ease'); - // //=> 'opacity 500ms ease, -webkit-transform 500ms ease' - // - function getTransition(properties, duration, easing, delay) { - // Get the CSS properties needed. - var props = getProperties(properties); - - // Account for aliases (`in` => `ease-in`). - if ($.cssEase[easing]) { easing = $.cssEase[easing]; } - - // Build the duration/easing/delay attributes for it. - var attribs = '' + toMS(duration) + ' ' + easing; - if (parseInt(delay, 10) > 0) { attribs += ' ' + toMS(delay); } - - // For more properties, add them this way: - // "margin 200ms ease, padding 200ms ease, ..." - var transitions = []; - $.each(props, function(i, name) { - transitions.push(name + ' ' + attribs); - }); - - return transitions.join(', '); - } - - // ## $.fn.transition - // Works like $.fn.animate(), but uses CSS transitions. - // - // $("...").transition({ opacity: 0.1, scale: 0.3 }); - // - // // Specific duration - // $("...").transition({ opacity: 0.1, scale: 0.3 }, 500); - // - // // With duration and easing - // $("...").transition({ opacity: 0.1, scale: 0.3 }, 500, 'in'); - // - // // With callback - // $("...").transition({ opacity: 0.1, scale: 0.3 }, function() { ... }); - // - // // With everything - // $("...").transition({ opacity: 0.1, scale: 0.3 }, 500, 'in', function() { ... }); - // - // // Alternate syntax - // $("...").transition({ - // opacity: 0.1, - // duration: 200, - // delay: 40, - // easing: 'in', - // complete: function() { /* ... */ } - // }); - // - $.fn.transition = $.fn.transit = function(properties, duration, easing, callback) { - var self = this; - var delay = 0; - var queue = true; - - // Account for `.transition(properties, callback)`. - if (typeof duration === 'function') { - callback = duration; - duration = undefined; - } - - // Account for `.transition(properties, duration, callback)`. - if (typeof easing === 'function') { - callback = easing; - easing = undefined; - } - - // Alternate syntax. - if (typeof properties.easing !== 'undefined') { - easing = properties.easing; - delete properties.easing; - } - - if (typeof properties.duration !== 'undefined') { - duration = properties.duration; - delete properties.duration; - } - - if (typeof properties.complete !== 'undefined') { - callback = properties.complete; - delete properties.complete; - } - - if (typeof properties.queue !== 'undefined') { - queue = properties.queue; - delete properties.queue; - } - - if (typeof properties.delay !== 'undefined') { - delay = properties.delay; - delete properties.delay; - } - - // Set defaults. (`400` duration, `ease` easing) - if (typeof duration === 'undefined') { duration = $.fx.speeds._default; } - if (typeof easing === 'undefined') { easing = $.cssEase._default; } - - duration = toMS(duration); - - // Build the `transition` property. - var transitionValue = getTransition(properties, duration, easing, delay); - - // Compute delay until callback. - // If this becomes 0, don't bother setting the transition property. - var work = $.transit.enabled && support.transition; - var i = work ? (parseInt(duration, 10) + parseInt(delay, 10)) : 0; - - // If there's nothing to do... - if (i === 0) { - var fn = function(next) { - self.css(properties); - if (callback) { callback(); } - next(); - }; - - callOrQueue(self, queue, fn); - return self; - } - - // Save the old transitions of each element so we can restore it later. - var oldTransitions = {}; - - var run = function(nextCall) { - var bound = false; - - // Prepare the callback. - var cb = function() { - if (bound) { self.unbind(transitionEnd, cb); } - - if (i > 0) { - self.each(function() { - this.style[support.transition] = (oldTransitions[this] || null); - }); - } - - if (typeof callback === 'function') { callback.apply(self); } - if (typeof nextCall === 'function') { nextCall(); } - }; - - if ((i > 0) && (transitionEnd) && ($.transit.useTransitionEnd)) { - // Use the 'transitionend' event if it's available. - bound = true; - self.bind(transitionEnd, cb); - } else { - // Fallback to timers if the 'transitionend' event isn't supported. - window.setTimeout(cb, i); - } - - // Apply transitions. - self.each(function() { - if (i > 0) { - this.style[support.transition] = transitionValue; - } - $(this).css(properties); - }); - }; - - // Defer running. This allows the browser to paint any pending CSS it hasn't - // painted yet before doing the transitions. - var deferredRun = function(next) { - var i = 0; - - // Durations that are too slow will get transitions mixed up. - // (Tested on Mac/FF 7.0.1) - if ((support.transition === 'MozTransition') && (i < 25)) { i = 25; } - - window.setTimeout(function() { run(next); }, i); - }; - - // Use jQuery's fx queue. - callOrQueue(self, queue, deferredRun); - - // Chainability. - return this; - }; - - function registerCssHook(prop, isPixels) { - // For certain properties, the 'px' should not be implied. - if (!isPixels) { $.cssNumber[prop] = true; } - - $.transit.propertyMap[prop] = support.transform; - - $.cssHooks[prop] = { - get: function(elem) { - var t = $(elem).css('transform') || new Transform(); - return t.get(prop); - }, - - set: function(elem, value) { - var t = $(elem).css('transform') || new Transform(); - t.setFromString(prop, value); - - $(elem).css({ transform: t }); - } - }; - } - - // ### uncamel(str) - // Converts a camelcase string to a dasherized string. - // (`marginLeft` => `margin-left`) - function uncamel(str) { - return str.replace(/([A-Z])/g, function(letter) { return '-' + letter.toLowerCase(); }); - } - - // ### unit(number, unit) - // Ensures that number `number` has a unit. If no unit is found, assume the - // default is `unit`. - // - // unit(2, 'px') //=> "2px" - // unit("30deg", 'rad') //=> "30deg" - // - function unit(i, units) { - if ((typeof i === "string") && (!i.match(/^[\-0-9\.]+$/))) { - return i; - } else { - return "" + i + units; - } - } - - // ### toMS(duration) - // Converts given `duration` to a millisecond string. - // - // toMS('fast') //=> '400ms' - // toMS(10) //=> '10ms' - // - function toMS(duration) { - var i = duration; - - // Allow for string durations like 'fast'. - if ($.fx.speeds[i]) { i = $.fx.speeds[i]; } - - return unit(i, 'ms'); - } - - // Export some functions for testable-ness. - $.transit.getTransitionValue = getTransition; -})(jQuery); diff --git a/site/jquery.transit-0.1.3.min.js b/site/jquery.transit-0.1.3.min.js deleted file mode 100644 index d26217e..0000000 --- a/site/jquery.transit-0.1.3.min.js +++ /dev/null @@ -1,19 +0,0 @@ -/*! - * jQuery Transit - CSS3 transitions and transformations - * Copyright(c) 2011 Rico Sta. Cruz - * MIT Licensed. - * - * http://ricostacruz.com/jquery.transit - * http://github.com/rstacruz/jquery.transit - */ -(function(d){function k(a){var b=["Moz","Webkit","O","ms"],c=a.charAt(0).toUpperCase()+a.substr(1);if(a in i.style)return a;for(a=0;a=b;++b)a[b]&&(a[b]=parseFloat(a[b]));a[3]&&(a[3]=g(a[3],"deg"));return a}},parse:function(a){var b=this;a.replace(/([a-zA-Z0-9]+)\((.*?)\)/g,function(a,d,e){b.setFromString(d,e)})},toString:function(a){var b=[],c;for(c in this)if(this.hasOwnProperty(c)&&(e.transform3d||!("rotateX"=== -c||"rotateY"===c||"perspective"===c||"transformOrigin"===c)))"_"!==c[0]&&(a&&"scale"===c?b.push(c+"3d("+this[c]+",1)"):a&&"translate"===c?b.push(c+"3d("+this[c]+",0)"):b.push(c+"("+this[c]+")"));return b.join(" ")}};d.fn.transition=d.fn.transit=function(a,b,c,f){var h=this,g=0,i=!0;"function"===typeof b&&(f=b,b=void 0);"function"===typeof c&&(f=c,c=void 0);"undefined"!==typeof a.easing&&(c=a.easing,delete a.easing);"undefined"!==typeof a.duration&&(b=a.duration,delete a.duration);"undefined"!==typeof a.complete&& -(f=a.complete,delete a.complete);"undefined"!==typeof a.queue&&(i=a.queue,delete a.queue);"undefined"!==typeof a.delay&&(g=a.delay,delete a.delay);"undefined"===typeof b&&(b=d.fx.speeds._default);"undefined"===typeof c&&(c=d.cssEase._default);var b=n(b),j=q(a,b,c,g),l=d.transit.enabled&&e.transition?parseInt(b,10)+parseInt(g,10):0;if(0===l)return p(h,i,function(b){h.css(a);f&&f();b()}),h;var k={},m=function(b){var c=!1,g=function(){c&&h.unbind(o,g);0b&&(b=25);window.setTimeout(function(){m(a)},b)});return this};d.transit.getTransitionValue=q})(jQuery); diff --git a/site/rocco.css b/site/rocco.css deleted file mode 100644 index 5aa0a8d..0000000 --- a/site/rocco.css +++ /dev/null @@ -1,186 +0,0 @@ -/*--------------------- Layout and Typography ----------------------------*/ -body { - font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif; - font-size: 15px; - line-height: 22px; - color: #252519; - margin: 0; padding: 0; -} -a { - color: #261a3b; -} - a:visited { - color: #261a3b; - } -p { - margin: 0 0 15px 0; -} -h1, h2, h3, h4, h5, h6 { - margin: 0px 0 15px 0; -} - h1 { - margin-top: 40px; - } -#container { - position: relative; -} -#background { - position: fixed; - top: 0; left: 525px; right: 0; bottom: 0; - background: #f5f5ff; - border-left: 1px solid #e5e5ee; - z-index: -1; -} -#jump_to, #jump_page { - background: white; - -webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777; - -webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px; - font: 10px Arial; - text-transform: uppercase; - cursor: pointer; - text-align: right; -} -#jump_to, #jump_wrapper { - position: fixed; - right: 0; top: 0; - padding: 5px 10px; -} - #jump_wrapper { - padding: 0; - display: none; - } - #jump_to:hover #jump_wrapper { - display: block; - } - #jump_page { - padding: 5px 0 3px; - margin: 0 0 25px 25px; - } - #jump_page .source { - display: block; - padding: 5px 10px; - text-decoration: none; - border-top: 1px solid #eee; - } - #jump_page .source:hover { - background: #f5f5ff; - } - #jump_page .source:first-child { - } -table td { - border: 0; - outline: 0; -} - td.docs, th.docs { - max-width: 450px; - min-width: 450px; - min-height: 5px; - padding: 10px 25px 1px 50px; - overflow-x: hidden; - vertical-align: top; - text-align: left; - } - .docs pre { - margin: 15px 0 15px; - padding-left: 15px; - } - .docs p tt, .docs p code { - background: #f8f8ff; - border: 1px solid #dedede; - font-size: 12px; - padding: 0 0.2em; - } - .pilwrap { - position: relative; - } - .pilcrow { - font: 12px Arial; - text-decoration: none; - color: #454545; - position: absolute; - top: 3px; left: -20px; - padding: 1px 2px; - opacity: 0; - -webkit-transition: opacity 0.2s linear; - } - td.docs:hover .pilcrow { - opacity: 1; - } - td.code, th.code { - padding: 14px 15px 16px 25px; - width: 100%; - vertical-align: top; - background: #f5f5ff; - border-left: 1px solid #e5e5ee; - } - pre, tt, code { - font-size: 12px; line-height: 18px; - font-family: Monaco, Consolas, "Lucida Console", monospace; - margin: 0; padding: 0; - } - - -/*---------------------- Syntax Highlighting -----------------------------*/ -td.linenos { background-color: #f0f0f0; padding-right: 10px; } -span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; } -body .hll { background-color: #ffffcc } -body .c { color: #408080; font-style: italic } /* Comment */ -body .err { border: 1px solid #FF0000 } /* Error */ -body .k { color: #954121 } /* Keyword */ -body .o { color: #666666 } /* Operator */ -body .cm { color: #408080; font-style: italic } /* Comment.Multiline */ -body .cp { color: #BC7A00 } /* Comment.Preproc */ -body .c1 { color: #408080; font-style: italic } /* Comment.Single */ -body .cs { color: #408080; font-style: italic } /* Comment.Special */ -body .gd { color: #A00000 } /* Generic.Deleted */ -body .ge { font-style: italic } /* Generic.Emph */ -body .gr { color: #FF0000 } /* Generic.Error */ -body .gh { color: #000080; font-weight: bold } /* Generic.Heading */ -body .gi { color: #00A000 } /* Generic.Inserted */ -body .go { color: #808080 } /* Generic.Output */ -body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ -body .gs { font-weight: bold } /* Generic.Strong */ -body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ -body .gt { color: #0040D0 } /* Generic.Traceback */ -body .kc { color: #954121 } /* Keyword.Constant */ -body .kd { color: #954121; font-weight: bold } /* Keyword.Declaration */ -body .kn { color: #954121; font-weight: bold } /* Keyword.Namespace */ -body .kp { color: #954121 } /* Keyword.Pseudo */ -body .kr { color: #954121; font-weight: bold } /* Keyword.Reserved */ -body .kt { color: #B00040 } /* Keyword.Type */ -body .m { color: #666666 } /* Literal.Number */ -body .s { color: #219161 } /* Literal.String */ -body .na { color: #7D9029 } /* Name.Attribute */ -body .nb { color: #954121 } /* Name.Builtin */ -body .nc { color: #0000FF; font-weight: bold } /* Name.Class */ -body .no { color: #880000 } /* Name.Constant */ -body .nd { color: #AA22FF } /* Name.Decorator */ -body .ni { color: #999999; font-weight: bold } /* Name.Entity */ -body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ -body .nf { color: #0000FF } /* Name.Function */ -body .nl { color: #A0A000 } /* Name.Label */ -body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ -body .nt { color: #954121; font-weight: bold } /* Name.Tag */ -body .nv { color: #19469D } /* Name.Variable */ -body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ -body .w { color: #bbbbbb } /* Text.Whitespace */ -body .mf { color: #666666 } /* Literal.Number.Float */ -body .mh { color: #666666 } /* Literal.Number.Hex */ -body .mi { color: #666666 } /* Literal.Number.Integer */ -body .mo { color: #666666 } /* Literal.Number.Oct */ -body .sb { color: #219161 } /* Literal.String.Backtick */ -body .sc { color: #219161 } /* Literal.String.Char */ -body .sd { color: #219161; font-style: italic } /* Literal.String.Doc */ -body .s2 { color: #219161 } /* Literal.String.Double */ -body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ -body .sh { color: #219161 } /* Literal.String.Heredoc */ -body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ -body .sx { color: #954121 } /* Literal.String.Other */ -body .sr { color: #BB6688 } /* Literal.String.Regex */ -body .s1 { color: #219161 } /* Literal.String.Single */ -body .ss { color: #19469D } /* Literal.String.Symbol */ -body .bp { color: #954121 } /* Name.Builtin.Pseudo */ -body .vc { color: #19469D } /* Name.Variable.Class */ -body .vg { color: #19469D } /* Name.Variable.Global */ -body .vi { color: #19469D } /* Name.Variable.Instance */ -body .il { color: #666666 } /* Literal.Number.Integer.Long */ \ No newline at end of file diff --git a/site/script.js b/site/script.js deleted file mode 100644 index 36851bb..0000000 --- a/site/script.js +++ /dev/null @@ -1,53 +0,0 @@ -(function() { - var i = 0; - $("article button").live('click', function(e) { - e.preventDefault(); - var $parent = $(this).closest('article'); - $parent.trigger('jiggle'); - $parent.trigger('restore'); - }); - - $("article .hover").live('mouseover', function(e) { - $(this).closest('article').trigger('jiggle'); - }); - - $("article .hover").live('mouseout', function(e) { - $(this).closest('article').trigger('restore'); - }); - - $("article").live('restore', function(e) { - var $this = $(this); - $this.removeClass('highlight'); - if ($this.find('.ghost').length) { - $this.find('.box').remove(); - $this.find('.ghost').removeClass('ghost').addClass('box'); - } - }); - - $("article").live('jiggle', function(e) { - var $this = $(this); - var id = $this.attr('id'); - - $this.addClass('highlight'); - - // Assign an ID if it doesn't have one. - if (!id) { - id = 'item_'+(i++); - $this.attr('id', id); - } - - // Extract the code. - var code = $this.find('pre').text(); - code = code.replace(/\$\(['"](.*?)['"]\)/g, '$("#'+id+' $1:not(.ghost)")'); - - // Duplicate the boxes to make ghosts. - if (!$this.is('.noghost')) { - $this.find('.field>*').each(function() { - $(this).before($(this).clone().removeClass('box').addClass('ghost')); - }); - } - - // Run it. - eval(code); - }); -})(); diff --git a/site/style.sass b/site/style.sass deleted file mode 100644 index 39cbda8..0000000 --- a/site/style.sass +++ /dev/null @@ -1,403 +0,0 @@ -@import 'compass/css3' -@import 'compass/utilities' -@import 'compass/reset' - -// Headings -$h3: #7bd * 0.8 - -// Highlights for type -$pip: #7bd * 0.8 - -$slate: #7bd -$box: #7bd * 0.7 -$bg: #fafafa -$yellow: #fafae0 - -html, body - -webkit-backface-visibility: hidden - -body - overflow-x: hidden - -body, td, label - font-family: signika, 'helvetica neue', helvetica, arial, sans-serif - font-weight: 300 - font-size: 12pt - -body - line-height: 1.5 - color: #555 - background: $bg url(images/bg.png) - text-shadow: 1px 1px 0 rgba(white, 0.4) - -#all - margin: 0 auto - -em - font-style: italic - font-family: 'ubuntu mono', sans-serif - color: #777 - -// Code -pre, code - font-family: monaco, monospace - -code - font-size: 0.9em - color: #777 - padding: 0 6px - +border-radius(2px) - background: rgba(white, 0.3) - +box-shadow(1px 1px rgba(black, 0.1)) - font-weight: 200 - -pre - +box-sizing(border-box) - padding: 10px - font-size: 9pt - - .comment - color: #808090 - - b - color: #333 - background: $yellow - padding: 2px 3px - +border-radius(2px) - +box-shadow(1px 1px 1px rgba(black, 0.1)) - -// -// Header -// -#header - & - text-align: center - line-height: 1.3 - padding: 80px 0 40px 0 - - h1 - color: #333 - font-size: 57pt - font-family: oswald, sans-serif - text-transform: uppercase - letter-spacing: 4px - font-weight: 400 - text-shadow: 1px 1px 0 $bg, 3px 3px 0 rgba($pip, 0.5), 0 0 1px $bg - - border-top: solid 2px #888 - border-bottom: solid 2px #888 - padding: 0 0 5px 0 - width: 305px - margin: 0 auto 20px auto - - h1, p - +transform(skewY(-5deg)) - - p - width: 350px - margin: 0 auto 20px auto - - font-size: 18pt - font-family: marvel - font-weight: 400 - padding: 0 200px - color: #666 - text-shadow: 2px 2px 0 $bg, 3px 3px 0 #ddd, 0 0 1px $bg - -// -// Each thingie -// -article - +pie-clearfix - margin: 40px auto - width: 800px - padding-top: 10px - position: relative - - &.mini - margin: 0 auto - - *:not(.mini) + &.mini - margin-top: 40px - - &.mini.last - margin-bottom: 40px - - >.hover - cursor: pointer - position: absolute - top: 0 - left: 0 - bottom: 0 - right: 50% - z-index: 2 - - h3 - font-weight: 800 - font-size: 12pt - color: $h3 - - font-family: 'ubuntu mono', sans-serif - text-shadow: 1px 1px 1px rgba(white, 0.5) - - .code - float: right - width: 50% - +box-sizing(border-box) - padding-left: 20px - - .code pre - padding: 5px 0 20px 0 - - .field - position: relative - float: right - width: 50% - height: 100px - - +box-sizing(border-box) - - // background: #f3f3f3 - // border: solid 3px #eee - // +box-shadow(inset 1px 1px 0 rgba(black, 0.1), 1px 1px rgba(black, 0.1)) - - border: dashed 1px #aaa - +border-radius(4px) - background: rgba(black, 0.05) - +box-shadow(1px 1px 0 rgba(white, 0.5)) - - &.highlight .field - background: rgba(#333, 0.2) - - .box, .ghost - width: 50px - height: 50px - +box-sizing(border-box) - display: block - position: absolute - background: $box - background: url(images/box.png) - border: solid 1px $box - - .ghost - background: #e0fafa * 1.2 - opacity: 0.4 - border: 0 - +box-shadow(inset 0 0 1px $box, inset 2px 2px 3px rgba($box*0.4, 0.2)) - -// Headings ("how to use") -h2 - text-align: center - font-size: 1.9em - padding: 5px 0 - +border-radius(2px) - border-bottom: solid 1px rgba($slate, 0.1) - line-height: 20pt - - font-weight: 400 - font-family: 'ubuntu mono', sans-serif - text-transform: uppercase - letter-spacing: 1px - - color: $pip - text-shadow: 1px 1px 0 $bg, 2px 2px 0 rgba(#888, 0.5) - - border-bottom: 0 - - margin-bottom: 10px - - &:before - content: '' - display: block - border-top: dashed 1px #aaa - border-bottom: dashed 1px #aaa - background: rgba(black, 0.1) - +box-shadow(0 -2px 0 rgba(white, 0.4), 0 2px 0 rgba(white, 0.4)) - height: 3px - margin-bottom: 40px - -h2 + .info - padding: 10px 50px - text-align: center - - width: 800px - margin: 0 auto -10px auto - -button, a.button - text-decoration: none - position: relative - padding: 0 50px 0 10px - border: 0 - margin: 0 - text-shadow: 1px 1px 0 rgba(black, 0.1) - +box-sizing(border-box) - display: inline-block - - height: 20px - line-height: 20px - - background: $slate - color: white - font-weight: 800 - +border-radius(15px) - - cursor: pointer - - &:before - content: '›' - display: block - - position: absolute - right: 20px - top: 0 - - height: 20px - line-height: 20px - - &:hover - background: $slate * 0.8 - - small - font-size: 0.8em - color: #aaa - -.meta - padding: 10px 0 50px 0 - text-align: center - - // Download button - a.button - font-family: 'ubuntu mono', sans-serif - text-transform: uppercase - - margin: 0 10px - background: #222 - font-weight: 200 - text-align: center - height: 36px - line-height: 36px - +border-radius(1px) - - +box-shadow(2px 2px 0 $bg, 6px 6px 0 rgba($pip, 0.3)) - - - &:hover - background: $pip - - &:before - display: none - -// -// Info links -// -.info - a - text-decoration: none - color: #555 - padding: 3px 5px - +border-radius(2px) - background: $yellow - +box-shadow(1px 1px 0 rgba(black, 0.1)) - +transition(all 200ms linear) - - a span - border-bottom: solid 1px rgba(black, 0.1) - - a:hover - background: $yellow * 0.9 - -// -// More info -// -.info.source, .more.info - margin-top: 30px - margin-bottom: 30px - background: transparent - text-align: center - padding-left: 50px - padding-right: 50px - - >*:first-child - margin-top: 0 - - p, ul, pre - margin-top: 10px - - pre - color: #888 - padding: 10px - width: 600px - - border: dashed 1px #aaa - +border-radius(4px) - background: rgba(black, 0.05) - +box-shadow(1px 1px 0 rgba(white, 0.5)) - - margin: 20px auto 0 auto - text-align: left - -.info - li - display: inline-block - margin-left: 5px - background: rgba($slate, 0.1) - padding: 2px 8px - +border-radius(4px) - +box-shadow(1px 1px 0 rgba(black, 0.1)) - -.credits - padding: 30px 0 100px 0 - width: 800px - margin: 0 auto - - font-size: 0.8em - overflow: hidden - - p, ul - float: left - width: 32% - +box-sizing(border-box) - padding-right: 30px - margin: 10px 0 - - ul - margin-left: 20px - - ul, ul li - list-style-type: disc - - a - color: #999 - text-decoration: none - - a:hover - border-bottom: solid 1px #aaa - -.info.transformations - padding: - left: 125px - right: 125px - - text-align: left - - ul - line-height: 2 - - li - line-height: 1.3 - display: inline-block - width: 150px - text-align: left - font-size: 0.9em - +box-shadow(none) - background: transparent - - li em - font-style: normal - margin-left: 5px - font-size: 0.9em - -a.forkme img - position: absolute - right: 0 - top: 0 diff --git a/site/test.haml b/site/test.haml deleted file mode 100644 index 440d413..0000000 --- a/site/test.haml +++ /dev/null @@ -1,843 +0,0 @@ -title: Hello --- -!!! 5 -%html - %head - %title jQuery Transit - CSS3 animations for jQuery - %link(rel='stylesheet' media='screen' type='text/css' href='style.css') - %meta(name='description' content='Super-smooth CSS3 transformations and transitions for jQuery.') - != "" - %script(src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js') - %script(src='jquery.transit.min.js') - %script(src='script.js') - :javascript - jQuery.fn.bounceIn = function(callback) { - return this. - css({ scale: 0.9, opacity: 0 }). - transit({ scale: 1.03, opacity: 1 }, 120, 'out'). - transit({ scale: 1.0 }, 200, 'in', callback); - }; - - jQuery.fn.bounceOut = function(callback) { - return this. - css({ opacity: 1 }). - transit({ scale: 0.97, opacity: 0 }, 120, 'in', callback); - }; - - %body - #all - %hgroup#header - %h1 - jQuery Transit tests - - -# ============================================================================ - %h2 Delay zero - - %article.mini - .hover - .code - %h3 Delay zero - %pre - != "$('.box').transition({ x: 330, delay: 0 }).transition({ x: 0 });" - - .field{style: 'height: 53px'} - .box{style: 'left: 10px; top: 10px; height: 30px;'} - - -# ============================================================================ - %h2 Callback tests - - %article.mini - .hover - .code - %h3 2nd param - %pre - != "$('.box').transition({ x: 330 }, function() { $(this).html('OK'); });" - - .field{style: 'height: 53px'} - .box{style: 'left: 10px; top: 10px; height: 30px;'} - - %article.mini - .hover - .code - %h3 3rd param - %pre - != "$('.box').transition({ x: 330 }, 500, function() { $(this).html('OK'); });" - - .field{style: 'height: 53px'} - .box{style: 'left: 10px; top: 10px; height: 30px;'} - - %article.mini - .hover - .code - %h3 as 'complete' - %pre - != "$('.box').transition({ x: 330, complete: function() { $(this).html('OK'); }});" - - .field{style: 'height: 53px'} - .box{style: 'left: 10px; top: 10px; height: 30px;'} - - -# ============================================================================ - %h2 Property cleanup test - - %article - .hover - .code - %h3 Clean up transformations - %pre - != "$('.box')." - %br<> - != " transition({ x: '-200px' }, function() {" - %br<> - != " if ($(this).attr('style').indexOf('transition') > -1)" - %br<> - != " alert('fail');" - %br<> - != "});" - - .field{style: 'height: 150px; overflow: hidden;'} - .box{style: 'left: 10px; top: 10px; width: 380px; height: 130px;'} - - -# ============================================================================ - %h2 Queue reliability - - %article.mini - .hover - .code - %pre - != "var $el = $('.box');" - %br<> - != "$el.css({ transitionOrigin: '50% 0' });" - %br<> - != "for (var i=0; i<30; ++i) { $el.transit({ perspective: 100, rotateX: (i%2==0)?40:-40 }, 200); }" - %br<> - != "$el.transit({ rotateX: 0 });" - - .field{style: 'height: 53px'} - .box{style: 'left: 10px; top: 10px; height: 30px;'} - - -# ============================================================================ - %h2 Transitioning from one style to another - - %article - .hover - .code - %h3 Transition with zero duration - %pre - != "$('.box')." - %br<> - != " transition({ x: '-200px' }, 0)." - %br<> - != " transition({ x: 0 });" - - .field{style: 'height: 150px; overflow: hidden;'} - .box{style: 'left: 10px; top: 10px; width: 380px; height: 130px;'} - - %article - .hover - .code - %h3 Zero durations - should not flicker (1) - %pre - != "$('.box')." - %br<> - != " transition({ x: '-200px' }, 0)." - %br<> - != " transition({ x: '-100px' }, 0)." - %br<> - != " transition({ x: '40px' }, 0)." - %br<> - != " transition({ x: 0 }, 0);" - - .field{style: 'height: 150px; overflow: hidden;'} - .box{style: 'left: 10px; top: 10px; width: 380px; height: 130px;'} - - %article - .hover - .code - %h3 Zero durations with non-zeros - fails in WebKit - %pre - != "$('.box')." - %br<> - != " transition({ x: '-200px' }, 0)." - %br<> - != " transition({ x: '0' }, 200)." - %br<> - != " transition({ y: 10 }, 0)." - %br<> - != " transition({ x: 200 }, 0)." - %br<> - != " transition({ x: 0 }, 200)." - %br<> - != " transition({ y: 0 }, 0);" - - .field{style: 'height: 150px; overflow: hidden;'} - .box{style: 'left: 10px; top: 10px; width: 380px; height: 130px;'} - - %article - .hover - .code - %h3 Zero durations with non-zeros -- baseline - %pre - != "$('.box')." - %br<> - != " animate({ left: -200 }, 0)." - %br<> - != " animate({ left: 10 }, 200)." - %br<> - != " animate({ top: 20 }, 0)." - %br<> - != " animate({ left: 200 }, 0)." - %br<> - != " animate({ left: 10 }, 200)." - %br<> - != " animate({ top: 10 }, 0);" - - .field{style: 'height: 150px; overflow: hidden;'} - .box{style: 'left: 10px; top: 10px; width: 380px; height: 130px;'} - - %article - .hover - .code - %h3 Transition with CSS - %pre - != "$('.box')." - %br<> - != " css({ x: '-200px' })." - %br<> - != " transition({ x: 0 });" - - .field{style: 'height: 150px; overflow: hidden;'} - .box{style: 'left: 10px; top: 10px; width: 380px; height: 130px;'} - - -# ============================================================================ - %h2 Lingering test - - %article - .hover - .code - %h3 Don't animate 'left' - %pre - != "$('.box')." - %br<> - != " css({ position: 'absolute', left: '500px', opacity: 0 }, 0);" - %br<> - != "window.setTimeout(function() {" - %br<> - != " $('.box')." - %br<> - != " css({ left: 10 })." - %br<> - != " transition({ opacity: 1 });" - %br<> - != "}, 200);" - - .field{style: 'height: 150px; overflow: hidden;'} - .box{style: 'left: 10px; top: 10px; width: 380px; height: 130px;'} - - -# ============================================================================ - %h2 Bounce? - - %article - .hover - .code - %h3 In - %pre - != "$('.box').bounceIn();" - - .field - .box{style: 'left: 180px; top: 20px;'} - - -# ============================================================================ - %h2 Translate (move) - - %article - .hover - .code - %h3 Translate X - %pre - != "$('.box').transition({ x: '90px' });" - - .field - .box{style: 'left: 10px; top: 10px;'} - - %article - .hover - .code - %h3 Translate Y - %pre - != "$('.box').transition({ y: '30px' });" - - .field - .box{style: 'left: 10px; top: 10px;'} - - %article - .hover - .code - %h3 Translate X and Y - %pre - != "$('.box').transition({ x: '200px', y: '20px' });" - - .field - .box{style: 'left: 10px; top: 10px;'} - - -# ============================================================================ - %h2 Rotation - - %article - .hover - .code - %h3 Rotate - %pre - != "$('.box').transition({ rotate: '30deg' });" - - .field - .box{style: 'left: 180px; top: 20px;'} - - -# ============================================================================ - %h2 Skew - - %article - .hover - .code - %h3 Skew X - %pre - != "$('.box').transition({ skewX: '30deg' });" - - .field - .box{style: 'left: 180px; top: 20px;'} - - %article - .hover - .code - %h3 Skew Y - %pre - != "$('.box').transition({ skewY: '30deg' });" - - .field - .box{style: 'left: 180px; top: 20px;'} - - %article - .hover - .code - %h3 Skew X and Y - %pre - != "$('.box').transition({" - %br<> - != " skewX: '30deg'," - %br<> - != " skewY: '-30deg'" - %br<> - != "});" - - .field{style: 'height: 150px'} - .box{style: 'left: 180px; top: 45px;'} - - -# ============================================================================ - %h2 Scale - - %article - .hover - .code - %h3 Scale up 120% size - %pre - != "$('.box').transition({ scale: 1.2 });" - - .field - .box{style: 'left: 180px; top: 20px;'} - - %article - .hover - .code - %h3 Scale 200% horizontally, 150% vertically - %pre - != "$('.box').transition({ scale: [2, 1.5] });" - - .field - .box{style: 'left: 180px; top: 25px;'} - - -# ============================================================================ - %h2 3D rotation (Webkit only) - - %article - .hover - .code - %h3 Rotate X - %pre - != "$('.box').transition({" - %br<> - != " perspective: '100px'," - %br<> - != " rotateX: '180deg'" - %br<> - != "});" - - .field - .box{style: 'left: 180px; top: 20px;'} - - %article - .hover - .code - %h3 Rotate Y - %pre - != "$('.box').transition({" - %br<> - != " perspective: '100px'," - %br<> - != " rotateY: '180deg'" - %br<> - != "});" - - .field - .box{style: 'left: 180px; top: 20px;'} - - %article - .hover - .code - %h3 Rotate 3D - %pre - != "$('.box').transition({" - %br<> - != " perspective: '100px'," - %br<> - != " rotate3d: '1, 1, 0, 180deg'" - %br<> - != "});" - - .field - .box{style: 'left: 180px; top: 20px;'} - - -# ============================================================================ - %h2 Transitions for other properties - - %article - .hover - .code - %h3 $.fn.transition for any CSS property - %pre - != "$('.box').transition({" - %br<> - != " opacity: 0," - %br<> - != " scale: 1.6" - %br<> - != "});" - - .field{style: 'height: 150px'} - .box{style: 'left: 180px; top: 45px;'} - - %article - .hover - .code - %pre - != "$('.box').transition({" - %br<> - != " marginLeft: '20px'," - %br<> - != " height: '80px'" - %br<> - != "});" - - .field{style: 'height: 130px'} - .box{style: 'left: 180px; top: 35px;'} - - -# ============================================================================ - %h2 Callbacks - - %article - .hover - .code - %h3 Providing callbacks - %pre - != "$('.box').transition({ x: -100 }, function() {" - %br<> - != " $(this).transition({ opacity: 0 });" - %br<> - != "});" - - .field{style: 'height: 150px'} - .box{style: 'left: 180px; top: 45px;'} - - -# ============================================================================ - %h2 Custom duration - - %article - .hover - .code - %h3 Custom duration (jQuery style) - %pre - != "$('.box').transition({ opacity: 0 }, 'slow');" - - .field{style: 'height: 150px'} - .box{style: 'left: 180px; top: 45px;'} - - %article - .hover - .code - %h3 Custom duration (in milliseconds) - %pre - != "$('.box').transition({ opacity: 0 }, 2000);" - - .field{style: 'height: 150px'} - .box{style: 'left: 180px; top: 45px;'} - - -# ============================================================================ - %h2 Easing - - %article.mini - .hover - .code - %h3 Linear - %pre - != "$('.box').transition({ x: 330 }, 500, 'linear');" - - .field{style: 'height: 53px'} - .box{style: 'left: 10px; top: 10px; height: 30px;'} - - %article.mini - .hover - .code - %h3 Ease in - %pre - != "$('.box').transition({ x: 330 }, 500, 'in');" - - .field{style: 'height: 53px'} - .box{style: 'left: 10px; top: 10px; height: 30px;'} - - %article.mini - .hover - .code - %h3 Ease - %pre - != "$('.box').transition({ x: 330 }, 500, 'ease');" - - .field{style: 'height: 53px'} - .box{style: 'left: 10px; top: 10px; height: 30px;'} - - %article.mini - .hover - .code - %h3 Ease out - %pre - != "$('.box').transition({ x: 330 }, 500, 'out');" - - .field{style: 'height: 53px'} - .box{style: 'left: 10px; top: 10px; height: 30px;'} - - %article.mini - .hover - .code - %h3 Ease in-out - %pre - != "$('.box').transition({ x: 330 }, 500, 'in-out');" - - .field{style: 'height: 53px'} - .box{style: 'left: 10px; top: 10px; height: 30px;'} - - %article.mini - .hover - .code - %h3 Snap - %pre - != "$('.box').transition({ x: 330 }, 500, 'snap');" - - .field{style: 'height: 53px'} - .box{style: 'left: 10px; top: 10px; height: 30px;'} - - %article.mini.last - .hover - .code - %h3 Custom - %pre - != "$('.box').transition({ x: 330 }, 500, 'cubic-bezier(0,0.9,0.3,1)');" - - .field{style: 'height: 53px'} - .box{style: 'left: 10px; top: 10px; height: 30px;'} - - -# ============================================================================ - %h2 Delay - - %article - .hover - .code - %h3 Delay by 400ms - %pre - != "$('.box').transition({ x: -100, delay: 400 });" - - .field{style: 'height: 150px'} - .box{style: 'left: 180px; top: 45px;'} - - -# ============================================================================ - %h2 Alternate easing/duration syntax - - %article - .hover - .code - %pre - != "$('.box').transition({" - %br<> - != " x: '100px'," - %br<> - != " easing: 'snap'," - %br<> - != " duration: '2000ms'" - %br<> - != "});" - - .field{style: 'height: 150px'} - .box{style: 'left: 180px; top: 45px;'} - - -# ============================================================================ - %h2 Optional units - - %article - .hover - .code - %pre - != "$('.box').transition({" - %br<> - != " x: 100," - %br<> - != " duration: 2000," - %br<> - != " rotate: 30," - %br<> - != " easing: 'snap'" - %br<> - != "});" - - .field{style: 'height: 150px'} - .box{style: 'left: 180px; top: 45px;'} - - -# ============================================================================ - %h2 Relative units - - %article - .hover - .code - %pre - != "$('.box').transition({" - %br<> - != " rotate: '+=30deg'," - %br<> - != " x: '+=30'" - %br<> - != "});" - - .field{style: 'height: 150px'} - .box{style: 'left: 180px; top: 45px;'} - - - -# ============================================================================ - %h2 $.fn.css - - %article - .hover - .code - %pre - != "$('.box').css({" - %br<> - != " x: '90px'," - %br<> - != " y: '10px'," - %br<> - != " rotate: '-10deg'" - %br<> - != "});" - - .field{style: 'height: 150px'} - .box{style: 'left: 10px; top: 10px'} - - %article - .hover - .code - %h3 Transform (automatically adds vendor prefixes) - %pre - != "$('.box').css({ transform: 'rotate(40deg)' });" - - .field - .box{style: 'left: 10px; top: 10px;'} - - %article - .code - %h3 Getting values - %pre - != "$('.box').css({ rotate: '40deg' });" - %br<> - != "alert($('.box').css('rotate'));" - %br<> - != "alert($('.box').css('transform'));" - %button Run - - .field{style: 'height: 150px'} - .box{style: 'left: 10px; top: 10px;'} - - -# ============================================================================ - %h2 Setting transform origins - - %article - .hover - .code - %pre - != "$('.box').css({ transformOrigin: '10px 10px' });" - %br<> - != "$('.box').transition({ rotate: 40, scale: 1.2 });" - - .field - .box{style: 'left: 10px; top: 10px;'} - - -# ============================================================================ - %h2 Effect queue - - %article - .hover - .code - %pre - != "$('.box')." - %br<> - != " transition({ x: '-40px' }, 250)." - %br<> - != " transition({ x: '0px' }, 250)." - %br<> - != " transition({ y: '-40px' }, 250)." - %br<> - != " transition({ y: '0px' }, 250);" - - .field{style: 'height: 150px; overflow: hidden;'} - .box{style: 'left: 180px; top: 45px;'} - - :javascript - // Super simple test framework. - var T = { - test: null, - alerted: false, - - run: function(tests) { - var self = this; - - for (test in tests) { - if (tests.hasOwnProperty(test)) { - if (test.charAt(0) == '_') continue; - var fn = tests[test]; - var obj = {}; - if (tests._setup) tests._setup.apply(obj); - fn.apply(obj, [ function(val) { self.assert(val, test, this); } ]); - } - } - }, - - assert: function(value, test, T) { - if (!value) { - console.error(test, "- Assertion failed."); - console.trace(); - if (!T.alerted) alert("An assertion failed. See the console for details."); - } - } - }; - - function getTransition(el) { - return el.style[$.support.transition]; - } - - function uncamel(str) { - return str.replace(/([A-Z])/g, function(letter) { return '-' + letter.toLowerCase(); }) - } - - // Tests yo - T.run({ - _setup: function() { - this.div = $("
"); - }, - - get_rotate: function(a) { - a(this.div.css('rotate') == 0); - }, - - set_and_get_rotate: function(a) { - this.div.css('rotate', 30); - a(this.div.css('rotate') == '30deg'); - }, - - set_and_get_rotate_radian: function(a) { - this.div.css('rotate', '30rad'); - a(this.div.css('rotate') == '30rad'); - }, - - translate: function(a) { - this.div.css('x', 30); - this.div.css('y', 40); - - a(this.div.css('x') == '30px'); - a(this.div.css('y') == '40px'); - a(this.div.css('translate') == ['30px','40px']); - }, - - array_args: function(a) { - this.div.css('translate', [300, 400]); - a(this.div.css('translate') == ['300px','400px']); - }, - - array_args_2: function(a) { - this.div.css('translate', ['300', '400']); - a(this.div.css('translate') == ['300px','400px']); - }, - - array_args_3: function(a) { - this.div.css('translate', ['300em', '400em']); - a(this.div.css('translate') == ['300em','400em']); - }, - - scale_1: function(a) { - this.div.css('scale', [2,3]); - var s = this.div.css('scale'); - - a(s.length == 2); - a(s[0] == 2); - a(s[1] == 3); - }, - - scale_2: function(a) { - this.div.css('scale', [2.5, 2.5]); - a(this.div.css('scale') == 2.5); - }, - - transform_object: function(a) { - this.div.css('x', '40px'); - this.div.css('y', '90px'); - this.div.css('rotate', 400); - - var t = this.div.css('transform'); - a(t.toString() == 'translate(40px,90px) rotate(400deg)'); - a(t.toString(true) == 'translate3d(40px,90px,0) rotate(400deg)'); - a(t.rotate === '400deg'); - a(t.translate === '40px,90px'); - }, - - callback: function(a) { - var div = $("
").appendTo($("body")); - var x = 1; - div.transition({ x: -40 }, 400, function() { - x = 2; - }); - - window.setTimeout(function() { - a(x == 2); - }, 1600); - }, - - transition_property: function(a) { - var div = $("
").appendTo($("body")); - div.transition({ left: 40, marginLeft: 10, rotate: 30 }, 400, 'ease'); - window.setTimeout(function() { - var t = getTransition(div[0]); - a(t.indexOf('left 400ms ease') > -1); - a(t.indexOf('margin 400ms ease') > -1); - a(t.indexOf(uncamel($.support.transform) + ' 400ms ease') > -1); - }, 200); - }, - - get_transition_value: function(a) { - var t = $.transit.getTransitionValue({ opacity: 0, skewX: 30 }, 500, 'in'); - a(t.indexOf('opacity 500ms ease-in') > -1); - a(t.indexOf(uncamel($.support.transform) + ' 500ms ease-in') > -1); - } - - }); diff --git a/test/index.html b/test/index.html new file mode 100644 index 0000000..ac4a924 --- /dev/null +++ b/test/index.html @@ -0,0 +1,169 @@ + + + + + jQuery Transit tests + + + + + + +
+ Use: + jQ 2.0.3 + jQ 1.9.0b1 + jQ 1.8 + jQ 1.7 + jQ 1.6 + jQ 1.5 + +
+ +
+

jQuery transit tests

+

+

Since there's no reliable programmatic way to test for transitions, this + is a simple page set up so you can visually inspect effects + conveniently.

+
+ +
+ + + diff --git a/test/style.css b/test/style.css new file mode 100644 index 0000000..ddeb8a5 --- /dev/null +++ b/test/style.css @@ -0,0 +1,22 @@ +* { margin: 0; padding: 0; font-size: 1em; } +html { padding: 40px; background: #e3e3e7; } +body, td, input, textarea { font-family: helvetica neue, sans-serif; font-size: 9pt; color: #444; line-height: 1.4; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); } +body { padding-top: 50px; } +.use { position: fixed; top: 0; left: 0; right: 0; padding: 20px; border-bottom: solid 1px rgba(0, 0, 0, 0.1); background: rgba(250, 250, 250, 0.9); z-index: 10; } +.test { width: 220px; padding: 20px; float: left; margin: 0 20px 20px 0; background: white; border-radius: 2px; box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.05), -1px 1px 0 rgba(0, 0, 0, 0.05), 0 1px 5px rgba(0, 0, 0, 0.05); } +.test .area { width: auto; height: 100px; margin: 10px 0; position: relative; } +.test:hover { box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.05), -1px 1px 0 rgba(0, 0, 0, 0.05), 0 1px 5px rgba(0, 0, 0, 0.05), 0 0 0 4px rgba(0, 0, 0, 0.15); } +.test h3 { font-size: 1.2em; margin-bottom: 2px; overflow: hidden; line-height: 24px; } +.test h3 em { font-style: normal; font-weight: 200; float: right; color: #37a; font-size: 0.8em; } +.test .box { position: absolute; top: 50%; left: 50%; margin: -16px 0 0 -16px; width: 32px; height: 32px; line-height: 32px; text-align: center; background: #505070; border-radius: 2px; z-index: 2; color: #ddd; } +.test .ghost { background: #ddd; z-index: 1; box-shadow: inset 2px 2px 2px rgba(0, 0, 0, 0.07), inset 0 0 0 1px rgba(0, 0, 0, 0.03); } +.test pre { font-family: menlo, monospace; font-size: 7pt; padding: 10px; background: #eee; margin: 20px -20px -20px -20px; border-top: solid 1px #ddd; white-space: pre-wrap; line-height: 1.5; } +.group-heading { margin: 20px 0 20px 0; padding-bottom: 10px; border-bottom: dotted 1px #ccc; font-size: 1.6em; clear: both; color: #70a0c0; font-weight: 200; } + +.use button { padding: 0 10px; } +.use a, .use button { margin: 0 5px; } + +.description { padding-bottom: 20px; border-bottom: dotted 1px #ccc; } +.description h1 { font-size: 2.5em; font-weight: 200; color: #707090; } +.description p { font-size: 1.2em; color: #707090; width: 500px; } +.description .version { margin-bottom: 20px; font-size: 1.2em; font-weight: bold; } diff --git a/test/test.js b/test/test.js new file mode 100644 index 0000000..a015441 --- /dev/null +++ b/test/test.js @@ -0,0 +1,65 @@ +(function($) { + /* Simple test framework of sorts */ + + + function addTestEvents ($test) { + $test.bind('mouseenter play', function() { + var $test = $(this).closest('.test'); + $test.trigger('reset'); + var $box = $test.find('.box:not(.ghost)'); + var $ghost = $box.clone().addClass('ghost').appendTo($test.find('.area')); + + $test.data('code').fn($box, $test); + }); + + $test.bind('mouseleave reset', function() { + var $test = $(this).closest('.test'); + var $ghost = $test.find('.ghost'); + if ($ghost.length) { + $test.find('.box:not(.ghost)').remove(); + $test.find('.ghost').removeClass('ghost'); + } + }); + } + + $(document).ready(function () { + $('.play-all').bind('click', function() { + $('.test').trigger('play'); + }); + }); + + function test(name, fn) { + var i = $('.tests .test').length; + var $test = $('

'); + + var m = fn.toString().match(/\{([\s\S]*)\}$/); + var code = m[1]; + code = code.replace(/^\s*|\s*$/g, ''); + code = code.replace(/\n {4}/g, "\n"); + name = name.replace(/\(.*\)/, function(n) { return ""+n.substr(1,n.length-2)+""; }); + + $test.attr('id', 'test-'+i); + $test.find('h3').html(name); + $test.find('pre').text(code); + $test.data('code', {fn: fn}); + addTestEvents($test); + + $('.tests').append($test); + } + + function group(name) { + $('.tests').append($('

').text(name)); + } + + // Show versions + $(function() { + $('#jquery-version').html( + 'jQuery: v' + $.fn.jquery + '
' + + 'Transit: v' + $.transit.version + ); + }); + + window.group = group; + window.test = test; + +})(jQuery);