<div id="bottom">
<form id="contact_form" novalidate>
<input type="text" class="hidden" name="spam" />
<input type="text" id="name" name="name" placeholder="Ваше имя" autocomplete="off"/>
<input name="email" class="email" type="email" placeholder="Адрес электронной почты" autocomplete="off" />
<textarea rows="4" cols="50" name="message" class="message" placeholder="Оставьте ваш отзыв" autocomplete="off"></textarea>
</form>
<div class="container">
<!-- progress button -->
<div class="progress-button elastic">
<button><span>Отправить</span></button>
<svg class="progress-circle" width="70" height="70"><path d="m35,2.5c17.955803,0 32.5,14.544199 32.5,32.5c0,17.955803 -14.544197,32.5 -32.5,32.5c-17.955803,0 -32.5,-14.544197 -32.5,-32.5c0,-17.955801 14.544197,-32.5 32.5,-32.5z"/></svg>
<svg class="checkmark" width="70" height="70"><path d="m31.5,46.5l15.3,-23.2"/><path d="m31.5,46.5l-8.5,-7.1"/></svg>
<svg class="cross" width="70" height="70"><path d="m35,35l-9.3,-9.3"/><path d="m35,35l9.3,9.3"/><path d="m35,35l-9.3,9.3"/><path d="m35,35l9.3,-9.3"/></svg>
</div><!-- /progress-button -->
</div>
<script>
[].slice.call( document.querySelectorAll( '.progress-button' ) ).forEach( function( bttn, pos ) {
new UIProgressButton( bttn, {
callback : function( instance ) {
var progress = 0,
interval = setInterval( function() {
progress = Math.min( progress + Math.random() * 0.1, 1 );
instance.setProgress( progress );
var form_data=$('#contact_form').serialize();
var status;
$.ajax ({
type:"POST",
url: "send.php",
async: false,
data: form_data,
success: function (msg){
status=parseInt(msg);
},
error: function(){
status=0;
}
});
if( progress === 1 ) {
instance.stop( status === 1 ? 1 : -1 );
clearInterval( interval );
if (status===1){
$(':input','#contact_form').val('');
}
}
}, 150 );
}
} );
} );
</script>
</div>
UIProgressButton.prototype._initEvents = function() {
var self = this;
this.button.addEventListener( 'click', function() { self._submit(); } );
}
UIProgressButton.prototype._submit = function() {
// by adding the loading class the button will transition to a "circle"
classie.addClass( this.el, 'loading' );
var self = this,
onEndBtnTransitionFn = function( ev ) {
if( support.transitions ) {
if( ev.propertyName !== 'width' ) return false;
this.removeEventListener( transEndEventName, onEndBtnTransitionFn );
}
// disable the button - this should have been the first thing to do when clicking the button.
// however if we do so Firefox does not seem to fire the transitionend event.
this.setAttribute( 'disabled', '' );
if( typeof self.options.callback === 'function' ) {
self.options.callback( self );
}
else {
// fill it (time will be the one defined in the CSS transition-duration property)
self.setProgress(1);
self.stop();
}
};
if( support.transitions ) {
this.button.addEventListener( transEndEventName, onEndBtnTransitionFn );
}
else {
onEndBtnTransitionFn();
}
}
// runs after the progress reaches 100%
UIProgressButton.prototype.stop = function( status ) {
var self = this,
endLoading = function() {
// first undraw progress stroke.
self.progressEl.draw(0);
if( typeof status === 'number' ) {
var statusClass = status >= 0 ? 'success' : 'error',
statusEl = status >=0 ? self.successEl : self.errorEl;
// draw stroke of success (checkmark) or error (cross).
statusEl.draw( 1 );
// add respective class to the element
classie.addClass( self.el, statusClass );
// after options.statusTime remove status and undraw the respective stroke. Also enable the button.
setTimeout( function() {
classie.remove( self.el, statusClass );
statusEl.draw(0);
self._enable();
}, self.options.statusTime );
}
else {
self._enable();
}
// finally remove class loading.
classie.removeClass( self.el, 'loading' );
};
// give it a time (ideally the same like the transition time) so that the last progress increment animation is still visible.
setTimeout( endLoading, 300 );
}
UIProgressButton.prototype.setProgress = function( val ) {
this.progressEl.draw( val );
}
// enable button
UIProgressButton.prototype._enable = function() {
this.button.removeAttribute( 'disabled' );
}
// add to global namespace
window.UIProgressButton = UIProgressButton;
})
Всем привет.
Разрабатываю свой первый сайт, а потому не раз натыкался на костыли. Вот один из них: написал код анимации кнопки submit для формы, но проблема в том, что на телефонах анимация притормаживает. Обнаружил, что если вынести #container за пределы #bottom, то все работает плавно и красиво, а потому думаю, что это как то связано с особенностями CSS, хотелось бы уточнить, что не так в моем коде
#bottom {
position: relative;
background-attachment: scroll, scroll;
background-image: url(images/bottom-32001.svg), url(images/bot-bg.jpg);
background-size: 1981px 231px, cover;
background-position: top center, center center;
background-repeat: repeat-x, repeat;
padding: 0.75em 0 35em 0;
width: 100%;
min-width: 800px;
height: 700px;
}
.container{
position: absolute;
padding: 0 130px 0 130px;
width: 100%;
z-index: 9999;
}
.progress-button {
position: relative;
display: inline-block;
text-align: center;
width: 300px;
min-width: 250px;
}
Апостиль в Лос-Анджелесе без лишних нервов и бумажной волокиты
Основные этапы разработки сайта для стоматологической клиники
Продвижение своими сайтами как стратегия роста и независимости