Кнопка наверх с затуханием. Как регулировать положение?
Кто знает где, что подписать чтоб при изменении размера окна браузера, изменялось расположение <div id="toTop">, именно лева, права. А то заползает на body
jQuery(document).ready(function (){
jQuery(function () {
var scrollDiv = document.createElement('div');
jQuery(scrollDiv).attr('id', 'toTop').html('НАВЕРХ').appendTo('body');
jQuery(window).scroll(function () {
if (jQuery(this).scrollTop() >= 1000) {
jQuery('#toTop').fadeIn();
} else {
jQuery('#toTop').fadeOut();
}
});
jQuery('#toTop').click(function () {
jQuery('body,html').animate({scrollTop: 0}, 800);
});
});
});
window.addEvent('domready', function() {
SqueezeBox.initialize({});
$$('a.modal').each(function(el) {
el.addEvent('click', function(e) {
new Event(e).stop();
SqueezeBox.fromElement(el);
});
});
});
|
ок, с этой проблемой справился, а кто знает как сделать затухание быстрее?
насколько я понимаю что-то здесь добавить надо?!
jQuery('#toTop').fadeOut();
|
Спасибо всем за помощь:-/ , все сделал сам. Кому надо пишите скину скрипт с доработками....
|
было бы интересно взглянуть - у самого сейчас стала эта проблемка.
|
jQuery(document).ready(function (){
jQuery(function () {
var scrollDiv = document.createElement('div');
jQuery(scrollDiv).attr('id', 'toTop').html('НАВЕРХ').appendTo('body');
scrollDiv.style.background = 'url("/images/M_images/totop.png") no-repeat scroll center top transparent';
scrollDiv.style.border = 'medium none';
scrollDiv.style.color = '#0098CA';
scrollDiv.style.cursor = 'pointer';
scrollDiv.style.margin = '6px 0 0';
scrollDiv.style.padding = '20px 0 0';
scrollDiv.style.position = 'fixed'; //absolute
scrollDiv.style.top = 0;
scrollDiv.style.display = 'none';
if(innerWidth <= 1065){
scrollDiv.style.left = '200px';
}else{
scrollDiv.style.left = ((innerWidth-1065)/2+200) +'px';
}
window.onresize = function(){
if (innerWidth <= 1065){
scrollDiv.style.left = 200 + 'px';
}
if (innerWidth <= 1065 && pageXOffset > 0){
scrollDiv.style.left = (200-pageXOffset) + 'px';
}
if (innerWidth <= 1065 && pageXOffset == 0){
scrollDiv.style.left = 200 + 'px';
}
if (innerWidth > 1065){
scrollDiv.style.left = ((innerWidth-1065)/2+200) +'px';
}
}
window.onscroll = function(){
if (pageYOffset <= 1000){
scrollDiv.style.display = 'none';
}
if (pageYOffset > 1000){
scrollDiv.style.display = 'block';
}
if (pageXOffset > 0){
scrollDiv.style.left = (200-pageXOffset) + 'px';
}
if (pageXOffset == 0 && innerWidth <= 1065){
scrollDiv.style.left = 200 + 'px';
}
}
jQuery('#toTop').click(function () {
jQuery('body,html').animate({scrollTop: 0}, 800);
});
});
});
window.addEvent('domready', function() {
SqueezeBox.initialize({});
$$('a.modal').each(function(el) {
el.addEvent('click', function(e) {
new Event(e).stop();
SqueezeBox.fromElement(el);
});
});
});
|
| Часовой пояс GMT +3, время: 20:30. |