Effectum pone strepitando eruca icon nulla volumen in vertice JS code

participes quomodoWordPressEffectum deducendi "clicando erucae ad summitatem redire" in themate.

  • Si WordPress Whiz es, scis quomodo eam ad thema WordPress deferendum.
  • Hoc articulum etiam convenitFac stationeinceptor.

Eruca ascensus Top Picture

Click in eruca ascensu ad verticem imaginem redire 1

Imaginem in antecessum desuper excipe, commendatur ut eam in imaginibus folder sub themate presul poneret.

Gradus I: onerantes jQuery bibliothecam files

  • Oneratis fasciculum bibliothecae jQuery, si thema WordPress iam oneratum est, hunc gradum ignorare potes;

WordPress introduc 3 faction jQuery library, please check this tutorial ▼

Step 2: Add code to footer.php file

Adde sequentem codicem ad respondentem locum in themate footer.php ▼

<div class="one"></div>
<div id="backtotop" style="display:none;"></div>

Gradus III, addere Code ad CSS File

Sequentem codicem CSS ad lemma addere in stilo.css fasciculi ▼

.one {width:100%;height:3000px;}
#backtotop {background:url(images/rocket_up.png) 0px 0px no-repeat;position:fixed;bottom:0px;right:10px;width:149px;height:260px;cursor: pointer;z-index:1000;}

Step 4: Add back to top JS code

Pro sequenti js codice, js alium creare potes limam;

or merge in the file of the relevant document of the existing (commendata);

vel involvere potes in footer.php Medium ▼

var scrollTT = {
tTSpeed : 800, // 滚动到顶部的时间
startFlyTime : 1000, // 火箭起飞的时间
restartTime : 1200, // 重置火箭位置的时间
flySpeed : 50, // 火箭向上飞行的速度
obj : $("#backtotop"), // 回到顶部的dom
flyTemp : '', // 一个setInterval的临时变量
/**
* 
* 初始化 scrollTT 函数
* 主要是像对象添加事件
*
*/
init : function( obj, tTSpeed, startFlyTime, restartTime, flySpeed ) {
scrollTT.tTSpeed = scrollTT.tTSpeed || tTSpeed;
scrollTT.startFlyTIme = scrollTT.startFlyTIme || startFlyTime;
scrollTT.restartTime = scrollTT.restartTime || restartTime;
scrollTT.flySpeed = scrollTT.flySpeed || flySpeed;
scrollTT.obj = scrollTT.obj || obj;

// 向window 绑定scroll 事件
scrollTT.onScroll();


scrollTT.obj.click(function(){
// 关闭默认的scroll事件
$(window).off("scroll");
// 页面向上滚动
$('html,body').animate({scrollTop: '0px'}, this.tTSpeed);
// 火箭向上飞行
scrollTT.objFly();
// 火箭的喷气效果
scrollTT.blow();

});

// 鼠标在火箭上的效果
scrollTT.obj.mouseenter(function() {
$(this).css('background-position', '-149px 0px');
});
// 鼠标移开的效果
scrollTT.obj.mouseleave(function() {
$(this).css('background-position', '0px 0px');
});

}, 
/*
* 向window 绑定scroll 事件
*
*/
onScroll : function() {
$(window).on('scroll', function() {
if ($(window).scrollTop()>500){
scrollTT.obj.fadeIn(500);
}else{
scrollTT.obj.fadeOut(1500);
}
});
},
/**
* dom对象向上飞行
*
*/
objFly : function() {
var fly = setTimeout(function(){
scrollTT.obj.animate({top: '-500px'} ,'normal', 'swing');
scrollTT.resetFly();
clearTimeout(fly);
clearInterval(scrollTT.flyTemp);
}, scrollTT.startFlyTime);
},
/**
* dom 对象飞行完毕回到原来的位置
*
*/
resetFly : function() {
var fly2 = setTimeout(function() {
scrollTT.obj.hide();
scrollTT.obj.css("top", 'auto');
scrollTT.obj.css("background-position", '0px 0px');
scrollTT.onScroll();
clearTimeout(fly2);
},scrollTT.restartTime);
},
/**
* dom 对象的喷气效果
*
*/
blow : function() {
var topPosiiton = -149;
scrollTT.flyTemp = setInterval(function() {
topPosiiton += -149;
if(topPosiiton < -743) {
topPosiiton = -149
}
scrollTT.obj.css('background-position', topPosiiton + 'px 0px');
}, this.flySpeed);
}
};

scrollTT.init();

 

Spes Chen Weiliang Blog ( https://www.chenweiliang.com/ ) Communes "Pone Click Rocket Icon jQuery Scroll Back to Top JS Code Effect", proderit tibi.

Grata communicare nexum huius articuli:https://www.chenweiliang.com/cwl-1491.html

Grata ad canalem Telegram Chen Weiliang's blog ut tardus updates!

🔔 Primus esto ut magni pretii "ChatGPT Content Marketing AI tool Usage Guide" in canali summo presul! 🌟
📚 Hic dux ingens valorem continet, 🌟 Haec rara occasio est, id non fallunt! ⏰⌛💨
Share and like si libet!
Tua communicatio et similia continua sunt motiva nostra!

 

发表 评论

Tua inscriptio electronica Quisque sit amet nisl. 必填 项 已 用 * Pittacium

volumen ad top