├── .gitignore ├── Cakefile ├── ChangeLog ├── LICENSE ├── README.md ├── gem ├── transition-events-js.gemspec └── transition-events-js.rb ├── lib └── transition-events.js ├── package.json └── test.html /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *~ 3 | 4 | node_modules 5 | 6 | build 7 | pkg 8 | -------------------------------------------------------------------------------- /Cakefile: -------------------------------------------------------------------------------- 1 | fs = require('fs-extra') 2 | exec = require('child_process').exec 3 | path = require('path') 4 | glob = require('glob') 5 | uglify = require('uglify-js') 6 | 7 | task 'clean', 'Remove all generated files', -> 8 | fs.removeSync('build/') if path.existsSync('build/') 9 | fs.removeSync('pkg/') if path.existsSync('pkg/') 10 | 11 | task 'min', 'Create minimized version of library', -> 12 | fs.mkdirSync('pkg/') unless path.existsSync('pkg/') 13 | version = JSON.parse(fs.readFileSync('package.json')).version 14 | source = fs.readFileSync('lib/transition-events.js').toString() 15 | 16 | ast = uglify.parser.parse(source) 17 | ast = uglify.uglify.ast_mangle(ast) 18 | ast = uglify.uglify.ast_squeeze(ast) 19 | min = uglify.uglify.gen_code(ast) 20 | 21 | fs.writeFileSync("pkg/transition-events-#{version}.min.js", min) 22 | 23 | task 'gem', 'Build RubyGem package', -> 24 | fs.removeSync('build/') if path.existsSync('build/') 25 | fs.mkdirSync('build/lib/assets/javascripts/') 26 | 27 | copy = require('fs-extra/lib/copy').copyFileSync 28 | fs.removeSync('build/') if path.existsSync('build/') 29 | fs.mkdirSync('build/lib/assets/javascripts/') 30 | 31 | copy = require('fs-extra/lib/copy').copyFileSync 32 | copy('lib/transition-events.js', 33 | 'build/lib/assets/javascripts/transition-events.js') 34 | copy('gem/transition-events-js.gemspec', 'build/transition-events-js.gemspec') 35 | copy('gem/transition-events-js.rb', 'build/lib/transition-events-js.rb') 36 | copy('README.md', 'build/README.md') 37 | copy('ChangeLog', 'build/ChangeLog') 38 | copy('LICENSE', 'build/LICENSE') 39 | 40 | exec 'cd build/; gem build transition-events-js.gemspec', (error, message) -> 41 | if error 42 | process.stderr.write(error.message) 43 | process.exit(1) 44 | else 45 | fs.mkdirSync('pkg/') unless path.existsSync('pkg/') 46 | gem = glob.sync('build/*.gem')[0] 47 | copy(gem, gem.replace(/^build\//, 'pkg/')) 48 | fs.removeSync('build/') 49 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | == 0.2.1 (Plague of Justinian, 541–542) 2 | * Fix Ruby gem loading. 3 | 4 | == 0.2 (Antioch earthquake, 526) 5 | * Rename Ruby gem to transition-events-js. 6 | * Rename transitionAt to afterTransition. 7 | * Rename $.TransitionEvents to $.Transitions. 8 | * Don’t execute transitionEnd callback without CSS Transitions support. 9 | * Synchronize afterTransition with transitionend event. 10 | * Allow to miss durationPart argument in afterTransition. 11 | * Add requestAnimationFrame alias. 12 | * Remove $.Transitions.cachedProp. 13 | 14 | == 0.1 (Vesuvius eruption, 79) 15 | * Initial release. 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # jQuery Transition Events Plugin 2 | 3 | CSS Transition allows to write simple animation directly in CSS. It’s simpler, 4 | faster and cleaner, that JavaScript animation by `jQuery.fn.animate`. 5 | But sometimes we need good old complete callback in JavaScript for 6 | CSS Transitions animation. 7 | 8 | This jQuery plugin allows to set listeners to [CSS Transitions] animation end or 9 | specific part. Plugin requires jQuery 1.8 or higher. 10 | 11 | Method `$.fn.transitionEnd` adds listener for all `transitionend` future events. 12 | Method `$.fn.afterTransition` executes callback only once, after transition end. 13 | 14 | CSS with transitions: 15 | ```css 16 | .slider { 17 | transition: left 600ms; 18 | } 19 | .slider.video-position { 20 | left: -100px; 21 | } 22 | ``` 23 | 24 | Execute callback after current transition end: 25 | ```js 26 | $('.show-video').click(function () { 27 | $('.slider').addClass('video-position').afterTransition(function () { 28 | autoPlayVideo(); 29 | }); 30 | }); 31 | ``` 32 | 33 | 34 | Sponsored by Evil Martians 35 | 36 | 37 | [CSS Transitions]: https://developer.mozilla.org/en-US/docs/CSS/Using_CSS_transitions 38 | 39 | ## $.fn.afterTransition 40 | 41 | Plugin has `$.fn.afterTransition` function to execute callback after transition 42 | end `delay + (durationPart * duration)`. If browser doesn’t support 43 | CSS Transitions, callbacks will be called immediately (because there will be no animation). 44 | 45 | Callback often will be synchronized with `transitionend` by 46 | `requestAnimationFrame` hack. 47 | 48 | This function doesn’t check, that transition is really finished (it can be 49 | canceled in the middle). 50 | 51 | If can set `durationPart` and run callback in the middle of current transition: 52 | 53 | ```js 54 | $('.fliper').addClass('rotate').afterTransition(0.5, function () { 55 | $(this).find('.backface').show(); 56 | }); 57 | ``` 58 | 59 | If transition is set for several properties, `$.fn.afterTransition` will execute 60 | callback on every property. For example: 61 | 62 | ```css 63 | .car { 64 | transition-property: top, left; 65 | transition-duration: 1s, 4s; 66 | transition-delay: 1s; 67 | } 68 | ``` 69 | 70 | ```js 71 | $('.car').addClass('at-home').afterTransition(function (e) { 72 | console.log(e.propertyName + ' ' + e.elapsedTime); 73 | }); 74 | ``` 75 | 76 | This code will print `"top 1"` and `"left 4"`. 77 | 78 | ## $.fn.transitionEnd 79 | 80 | Modern browsers have `transitionend` event. This plugin hides vendor prefix 81 | problem from you. 82 | 83 | ```js 84 | // Bind synchronized listener to end of all future transitions. 85 | $('.slider').transitionEnd(function () { 86 | if ( $('.slider').hasClass('video-position') ) { 87 | autoPlayVideo(); 88 | } 89 | }); 90 | $('.show-video').click(function () { 91 | slider.addClass('video-position'); 92 | }); 93 | $('.hide-video').click(function () { 94 | // It will execute transitionEnd too 95 | slider.removeClass('video-position'); 96 | }); 97 | ``` 98 | 99 | Main difference with `$.fn.afterTransition` is that this method adds callback 100 | for all future transitions, not just for current one. Also callback won’t be 101 | executed without CSS Transitions support. 102 | 103 | If transition is set for several properties, `$.fn.transitionEnd` will execute 104 | callback on every property. 105 | 106 | If transition is canceled before finishing `$.fn.transitionEnd` won’t execute 107 | callback (for example, you add transition to hover, and object looses hover in the 108 | middle of animation). 109 | 110 | ## Event object 111 | 112 | Callbacks get object with properties: 113 | * `type` – event name: `transitionend` (be often with vendor prefix) or 114 | `aftertransition`. 115 | * `currentTarget` – DOM node with CSS transition. 116 | * `propertyName` – CSS property name, which has transition. it will be empty, 117 | if CSS Transitions aren’t supported. 118 | * `elapsedTime` – number of seconds the transition had been running at the time 119 | the event fired. This value isn't affected by the value of `transition-delay`. 120 | It will be zero, if CSS Transitions isn’t supported. 121 | 122 | ## Extra 123 | 124 | Free additional present from plugin: you can check CSS Transitions support: 125 | 126 | ```js 127 | if ( $.Transitions.isSupported() ) { 128 | // CSS Transitions is supported 129 | } 130 | ``` 131 | 132 | Also you can call `requestAnimationFrame` with polyfill and vendor prefixes 133 | autodetection: 134 | 135 | ```js 136 | $.Transitions.animFrame(function () { 137 | // Draw something 138 | }); 139 | ``` 140 | 141 | ## Installing 142 | 143 | ### Ruby on Rails 144 | 145 | For Ruby on Rails you can use gem for Assets Pipeline. 146 | 147 | 1. Add `transition-events-js` gem to `Gemfile`: 148 | 149 | ```ruby 150 | gem "transition-events-js" 151 | ``` 152 | 153 | 2. Install gems: 154 | 155 | ```sh 156 | bundle install 157 | ``` 158 | 159 | 3. Include plugin to your `application.js.coffee`: 160 | 161 | ```coffee 162 | #= require transition-events 163 | ``` 164 | 165 | ### Others 166 | 167 | If you don’t use any assets packaging manager (that’s very bad idea), you can use 168 | already minified version of the library. 169 | Take it from: [github.com/ai/transition-events/downloads]. 170 | 171 | [github.com/ai/transition-events/downloads]: https://github.com/ai/transition-events/downloads 172 | 173 | ## Contributing 174 | 175 | Open `test.html` in repository to run intergration tests. 176 | 177 | ## License 178 | 179 | Plugin is licensed under the GNU Lesser General Public License version 3. 180 | See the LICENSE file or [gnu.org/licenses/lgpl.html]. 181 | 182 | [gnu.org/licenses/lgpl.html]: http://gnu.org/licenses/lgpl.html 183 | 184 | ## Author 185 | 186 | Andrey “A.I.” Sitnik 187 | -------------------------------------------------------------------------------- /gem/transition-events-js.gemspec: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | Gem::Specification.new do |s| 4 | s.name = 'transition-events-js' 5 | s.version = '0.2.1' 6 | s.platform = Gem::Platform::RUBY 7 | s.authors = ['Andrey "A.I" Sitnik'] 8 | s.email = ['andrey@sitnik.ru'] 9 | s.homepage = 'https://github.com/ai/transition-events' 10 | s.summary = 'jQuery plugin to set listeners for CSS Transition ' + 11 | 'animation end or specific part.' 12 | 13 | s.add_dependency 'sprockets', '>= 2' 14 | 15 | s.files = ['lib/assets/javascripts/transition-events.js', 16 | 'lib/transition-events-js.rb', 17 | 'LICENSE', 'README.md', 'ChangeLog'] 18 | s.extra_rdoc_files = ['LICENSE', 'README.md', 'ChangeLog'] 19 | s.require_path = 'lib' 20 | end 21 | -------------------------------------------------------------------------------- /gem/transition-events-js.rb: -------------------------------------------------------------------------------- 1 | # Used only for Ruby on Rails gem to tell, that gem contain `lib/assets` with 2 | # transition-events.js file. 3 | module TransitionEventsJs 4 | module Rails 5 | class Engine < ::Rails::Engine 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/transition-events.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Andrey “A.I.” Sitnik , 3 | * sponsored by Evil Martians. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | ;(function($) { 20 | "use strict"; 21 | 22 | // Common methods and properties for jQuery Transition Events plugin. 23 | // Mostly for internal usage, but maybe helpful for some hack stuff: 24 | // 25 | // if ( $.Transitions.isSupported() ) { 26 | // // CSS Transitions is supported 27 | // } 28 | $.Transitions = { 29 | 30 | // Hash of property name to event name with vendor prefixes. 31 | // It is used to detect prefix. 32 | _names: { 33 | // Webkit must be on bottom, because Opera try to use webkit 34 | // prefix. 35 | 'transition': 'transitionend', 36 | 'OTransition': 'oTransitionEnd', 37 | 'WebkitTransition': 'webkitTransitionEnd', 38 | 'MozTransition': 'transitionend' 39 | }, 40 | 41 | // Return array of milliseconds for CSS value of `transition-duration`. 42 | // It’s used in `$.fn.afterTransition`. 43 | _parseTimes: function (string) { 44 | var value, array = string.split(/,\s*/); 45 | for (var i = 0; i < array.length; i++) { 46 | value = array[i]; 47 | array[i] = parseFloat(value); 48 | if ( value.match(/\ds/) ) { 49 | array[i] = array[i] * 1000; 50 | } 51 | } 52 | return array; 53 | }, 54 | 55 | // Autodetect vendor prefix and return `transitionend` event name. 56 | // 57 | // If browser didn’t support CSS Transitions it will return `false`. 58 | getEvent: function () { 59 | var finded = false; 60 | for ( var prop in this._names ) { 61 | if ( typeof(document.body.style[prop]) != 'undefined' ) { 62 | finded = this._names[prop]; 63 | break; 64 | } 65 | } 66 | 67 | this.getEvent = function () { 68 | return finded; 69 | }; 70 | 71 | return finded; 72 | }, 73 | 74 | // Alias to vendor prefixed `requestAnimationFrame`. Will be replace 75 | // by native function after first call. 76 | animFrame: function (callback) { 77 | var raf = window.requestAnimationFrame || 78 | window.webkitRequestAnimationFrame || 79 | window.mozRequestAnimationFrame || 80 | window.msRequestAnimationFrame; 81 | if ( raf ) { 82 | this.animFrame = function (callback) { 83 | return raf.call(window, callback); 84 | }; 85 | } else { 86 | this.animFrame = function (callback) { 87 | return setTimeout(callback, 10); 88 | }; 89 | } 90 | return this.animFrame(callback); 91 | }, 92 | 93 | // Return `true` if browser support CSS Transitions. 94 | isSupported: function () { 95 | return this.getEvent() !== false; 96 | } 97 | 98 | } 99 | 100 | // jQuery node methods. 101 | $.extend($.fn, { 102 | 103 | // Call `callback` after CSS Transition finish 104 | // `delay + (durationPart * duration)`. It will call `callback` only 105 | // once, in difference from `transitionEnd`. 106 | // 107 | // $('.show-video').click(function () { 108 | // $('.slider').addClass('video-position').afterTransition( 109 | // function () { autoPlayVideo(); }); 110 | // }); 111 | // 112 | // You can set `durationPart` to call `callback` in the middle of 113 | // transition: 114 | // 115 | // $('.fliper').addClass('rotate').afterTransition(0.5, function () { 116 | // $(this).find('.backface').show(); 117 | // }); 118 | // 119 | // Callback will get object with `propertyName` and `elapsedTime` 120 | // properties. If transition is set to difference properties, it will 121 | // be called on every property. 122 | // 123 | // This method doesn’t check, that transition is really finished (it can 124 | // be canceled in the middle). 125 | afterTransition: function (durationPart, callback) { 126 | if ( typeof(callback) == 'undefined' ) { 127 | callback = durationPart; 128 | durationPart = 1; 129 | } 130 | 131 | if ( !$.Transitions.isSupported() ) { 132 | for (var i = 0; i < this.length; i++) { 133 | callback.call(this[i], { 134 | type: 'aftertransition', 135 | elapsedTime: 0, 136 | propertyName: '', 137 | currentTarget: this[i] 138 | }); 139 | } 140 | return this; 141 | } 142 | 143 | for (var i = 0; i < this.length; i++) { 144 | var el = $(this[i]); 145 | var props = el.css('transition-property').split(/,\s*/); 146 | var durations = el.css('transition-duration'); 147 | var delays = el.css('transition-delay'); 148 | 149 | durations = $.Transitions._parseTimes(durations); 150 | delays = $.Transitions._parseTimes(delays); 151 | 152 | var prop, duration, delay, after, elapsed; 153 | for (var j = 0; j < props.length; j++) { 154 | prop = props[j]; 155 | duration = durations[ durations.length == 1 ? 0 : j ]; 156 | delay = delays[ delays.length == 1 ? 0 : j ]; 157 | after = delay + (duration * durationPart); 158 | elapsed = duration * durationPart / 1000; 159 | 160 | (function (el, prop, after, elapsed) { 161 | setTimeout(function () { 162 | $.Transitions.animFrame(function () { 163 | callback.call(el[0], { 164 | type: 'aftertransition', 165 | elapsedTime: elapsed, 166 | propertyName: prop, 167 | currentTarget: el[0] 168 | }); 169 | }); 170 | }, after); 171 | })(el, prop, after, elapsed); 172 | } 173 | } 174 | return this; 175 | }, 176 | 177 | // Set `callback` to listen every CSS Transition finish. 178 | // It will call `callback` on every finished transition, 179 | // in difference from `afterTransition`. 180 | // 181 | // It just bind to `transitionend` event, but detect vendor prefix. 182 | // 183 | // Callback will get event object with `propertyName` and `elapsedTime` 184 | // properties. If transition is set to difference properties, it will 185 | // be called on every property. 186 | // 187 | // Note, that `callback` will get original event object, not from 188 | // jQuery. 189 | // 190 | // var slider = $('.slider').transitionEnd(function () { 191 | // if ( slider.hasClass('video-position') ) { 192 | // autoPlayVideo(); 193 | // } 194 | // }); 195 | // 196 | // $('.show-video').click(function () { 197 | // slider.addClass('video-position'); 198 | // }); 199 | // 200 | // If transition will be canceled before finish, event won’t be fired. 201 | transitionEnd: function (callback) { 202 | for (var i = 0; i < this.length; i++) { 203 | this[i].addEventListener($.Transitions.getEvent(), function (e) { 204 | callback.call(this, e); 205 | }); 206 | } 207 | return this; 208 | } 209 | 210 | }); 211 | 212 | }).call(this, jQuery); 213 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "transition-events", 3 | "version": "0.2.1", 4 | "devDependencies": { 5 | "coffee-script": "1.3.3", 6 | "fs-extra": "0.1.3", 7 | "glob": "3.1.12", 8 | "uglify-js": "1.3.3" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | jQuery Transition Events Test 6 | 7 | 8 | 67 | 68 | 69 |

jQuery Transition Events Test

70 |

71 | Support: . 72 | Event name: . 73 |

74 |
75 |
76 |
77 |
78 | 106 | 107 | 108 | --------------------------------------------------------------------------------