Wait for transition to finish
I am trying to wait for transition to finish before calling a function that shows a title:
- $('#imagepackwrapper div[id^="packimgdiv"] img').on('doubletap click', function() {
- // newtitle == "#packtitlediv1"
- $('#imagepackwrapper div[id^="packimgdiv"] img').not(this).slideUp(600); // Hide other images
- function myshow(newtitle) { // Show the title
- $(newtitle).css({'margin-left': toffset + 'px','width': twd + 'px'});
- console.log('Opacity: ' + $(newtitle).css('opacity'));
- $(newtitle).animate({
- opacity: 1
- }, 800);
- }
- $(this).transition({ // run transition plugin on selected image - works
- marginTop: '0em',
- skewX: '0',
- rotateX: '0',
- rotate: '0',
- perspective: '0'
- }, 1500);
- $(this).on('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function() {
- myshow();
- });
- });
-
- HTML:
- <div id="imagepackwrapper">
- <div id="packimgdiv1">
- <div class="centered_image">
- <img class="imageStyle" src="files/image_18.png" width="200" height="200">
- </div>
- <div id="packtitlediv1" style="background-color: rgba(0, 0, 0, 0.2);"><span>Title2</span>
- </div>
- </div>
- </div>
-
The function myshow never runs. What am I doing wrong?
Thanks.