
November 19th, 2012, 01:22 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 2
Time spent in forums: 1 h 21 m 5 sec
Reputation Power: 0
|
|
Hi AndrewSW thank you for your help. I've had a good bash at it and I'm almost there. I'm a little stumped at how to bind the hover and click animations back to the container though. Switching them off works but switching them back on again after that doesn't. I don't think I'm using the on() and off() functions you mentioned correctly for unbind() but reading the documentation for a while I still can't figure it out. Here's what I have so far..
Code:
/////////////////////feedback form animation//////////////////////
jQuery(document).ready(function($) {
//find center of screen
var $screenwidth = $(window).width();
var $screencenter = $screenwidth /2 -177;
var $startpos = $screencenter +260;
var overlay = jQuery('<div id="simpleoverlay"> </div>');
//hover to slide functions
$('div#feedback-form-container').hover(function() {
$('div#feedback-form-container').animate({left: '+=260px'}, '2000');
},
function() {
$('div#feedback-form-container').animate({left: '-=260px'}, '6000');
}
);
//click to slide to center of screen
$('div#feedback-form-container').click(function() {
$('div#feedback-form-container').animate({
left: '+=' + $screencenter},{
duration: '2000',
easing: 'swing',
complete: setTimeout(function() { overlay.appendTo(document.body) }, 500)
});
//unbind functions
if ($('div#feedback-form-container').is(':animated')) $('div#feedback-form-container').off('click').off('hover');
//set cursor back to default
$('div#feedback-form-container').css('cursor', 'default');
});
$('#wpcf7-f52-t1-o1').submit(function() {
$('div#feedback-form-container').animate({left: '-=' + $startpos}, '6000');
$('div#feedback-form-container').on('hover').on('click');
});
});
|