![]() |
Back To Top |
Cara Mudah Membuat Tombol Back To Top di Blogspot
Ada banyak cara yang ditawarkan blogger lain untuk membuat atau memasang tombol back to top di blog. Salah satu yang paling banyak digambarkan dengan memasang script tombol back to top di HTML blogspot.
Namun beberapa pengguna, khususnya yang belum (bukan tidak) paham dengan script HTML, akan sedikit ragu, jangan-jangan script tersebut malah membuat tampilan atau load blognya semakin lambat. Hal ini sebenarnya bisa diantisipasi dengan melakukan back up terlebih dahulu jika hendak melakukan perubahan.
(Baca: Cara Menghilangkan Tulisan Subscribe to: Post (Atom))
Apapun itu, sebenarnya ada cara paling mudah untuk memasang script tombol back to top di blogspot.
Bagi Anda yang belum mengerti apa itu tombol back to top atau kembali ke atas adalah tombol sorcut yang disediakan di bilah kanan blog. Tombol ini akan memudahkan pembaca untuk kembali ke atas halaman, jika telah jauh melakukan scroll ke bawah. Jadi dengan menekan tombol ini, pengunjung tak perlu lagi menekan scroll ke atas.
(Baca: Cara Gampang Merubah Ukuran Header Blogspot)
Lalu bagaimana memasang tombol back to top ini dengan mudah?
Caranya dengan mengcopy script berikut ke sidebar blog Anda. Lakukan seperti menambahkan script lainnya di halaman dasboard. Klik Tata Letak, lalu pilih Tambahkan Gadget dan pilih THML/JavaScript.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" >
var scrolltotop={
//startline: Integer. Number of pixels from top of doc scrollbar is scrolled before showing control
//scrollto: Keyword (Integer, or "Scroll_to_Element_ID"). How far to scroll document up when control is clicked on (0=top).
setting: {startline:100, scrollto: 0, scrollduration:1000, fadeduration:[500, 100]},
controlHTML: 'Paste URL Back To Top Anda Disini" />', //HTML for control, which is auto wrapped in DIV w/ ID="topcontrol"
controlattrs: {offsetx:5, offsety:5}, //offset of control relative to right/ bottom of window corner
anchorkeyword: '#top', //Enter href value of HTML anchors on the page that should also act as "Scroll Up" links
state: {isvisible:false, shouldvisible:false},
scrollup:function(){
if (!this.cssfixedsupport) //if control is positioned using JavaScript
this.$control.css({opacity:0}) //hide control immediately after clicking it
var dest=isNaN(this.setting.scrollto)? this.setting.scrollto : parseInt(this.setting.scrollto)
if (typeof dest=="string" && jQuery('#'+dest).length==1) //check element set by string exists
dest=jQuery('#'+dest).offset().top
else
dest=0
this.$body.animate({scrollTop: dest}, this.setting.scrollduration);
},
keepfixed:function(){
var $window=jQuery(window)
var controlx=$window.scrollLeft() + $window.width() - this.$control.width() - this.controlattrs.offsetx
var controly=$window.scrollTop() + $window.height() - this.$control.height() - this.controlattrs.offsety
this.$control.css({left:controlx+'px', top:controly+'px'})
},
togglecontrol:function(){
var scrolltop=jQuery(window).scrollTop()
if (!this.cssfixedsupport)
this.keepfixed()
this.state.shouldvisible=(scrolltop>=this.setting.startline)? true : false
if (this.state.shouldvisible && !this.state.isvisible){
this.$control.stop().animate({opacity:1}, this.setting.fadeduration[0])
this.state.isvisible=true
}
else if (this.state.shouldvisible==false && this.state.isvisible){
this.$control.stop().animate({opacity:0}, this.setting.fadeduration[1])
this.state.isvisible=false
}
},
init:function(){
jQuery(document).ready(function($){
var mainobj=scrolltotop
var iebrws=document.all
mainobj.cssfixedsupport=!iebrws || iebrws && document.compatMode=="CSS1Compat" && window.XMLHttpRequest //not IE or IE7+ browsers in standards mode
mainobj.$body=(window.opera)? (document.compatMode=="CSS1Compat"? $('html') : $('body')) : $('html,body')
mainobj.$control=$('<div id="topcontrol">'+mainobj.controlHTML+'</div>')
.css({position:mainobj.cssfixedsupport? 'fixed' : 'absolute', bottom:mainobj.controlattrs.offsety, right:mainobj.controlattrs.offsetx, opacity:0, cursor:'pointer'})
.attr({title:'Scroll Back to Top'})
.click(function(){mainobj.scrollup(); return false})
.appendTo('body')
if (document.all && !window.XMLHttpRequest && mainobj.$control.text()!='') //loose check for IE6 and below, plus whether control contains any text
mainobj.$control.css({width:mainobj.$control.width()}) //IE6- seems to require an explicit width on a DIV containing text
mainobj.togglecontrol()
$('a[href="' + mainobj.anchorkeyword +'"]').click(function(){
mainobj.scrollup()
return false
})
$(window).bind('scroll resize', function(e){
mainobj.togglecontrol()
})
})
}
}
scrolltotop.init()
</script>
(Baca: Cara Membagi Kolom Pada Postingan Blogspot)
Perhatikan pada tulisan Paste URL Back To Top Anda Disini yang berwarna merah. Anda harus menggantinya dengan gambar tombol back to top yang sesuai dengan selera Anda. Pada blog ini, bloGoooblok ~ menggunakan gambar berikut dengan URL-nya.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjiR9aNu26WsI8wSGRxAA6tBxe5aBenZQEcagf_NYBPZhW7Xb37ik8rWbwNwl4-9qlcll7aa34GtXbfJYPSnFU-f-0UJ3tslR4I2_zGSAPi_eAy4rXTKWfYzFANXW2cb5KTaQGYGiQna0/s1600/back+to+top+button.png
Anda bisa mencari emicon back to top di Google. Ada banyak pilihan di sana. Lalu copy URL-nya dan paste pada script diatas. Jika sesuai dengan tata caranya, maka blog Anda segera menerapkan tombol back to top. Kalau ada kesempatan, pada postingan lain, bloGoooblok ~ akan memberikan pilihan tombol back to top yang beragam.
Selamat mencoba...!
http://www.blogooblok.com/2015/02/cara-mudah-membuat-tombol-back-to-top.html
Smooth Scroll Back To Top Javascript With Animation
Smooth Scroll Back To Top Javascript With Animation
Home Blogger CSS3 Jquery Tutorial Smooth Scroll Back To Top Javascript With Animation
Bola Hero Gawai
Smooth Scroll Back To Top Javascript With Animation
Sudah banyak yang sharing cara membuat tombol back to top untuk blog, namun kebanyakan menggunakan jquery. Nah kali ini saya akan membagikan cara membuat back to top dengan gerakan smooth scroll menggunakan pure javascript ditambah css animasi untuk kemunculannya.
Ada 2 macam smooth scroll back to top javascript with animation ini, yang pertama menggunakan tambahan javascript untuk show hide on scroll dengan animasi bounceIn untuk memperhalus munculnya tombol, dan yang kedua tidak menggunakan javascript show hide on scroll, namun hanya menggunakan css animasi bounceIn left untuk kemunculan tombolnya ketika halaman dibuka seperti animasi gif di bawah ini.
Dengan show hide on scroll.
Smooth Scroll Back To Top Javascript With Animation
DEMO
Tanpa show hide on scroll.
Smooth Scroll Back To Top Javascript With Animation
DEMO
Back To Top dengan show hide on scroll
Silahkan simpan kode css ini di atas kode </head>. Tombol hanya ditampilkan di halaman postingan dan dihilangkan di perangkat mobile.
<b:if cond='data:blog.isMobileRequest == "false" and data:blog.pageType == "item"'>
<style type='text/css'>
#backtotop{position:fixed;bottom:20px;right:20px;cursor:pointer}
.ani-dur{-webkit-animation-fill-mode:both;-moz-animation-fill-mode:both;-ms-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:1s;-moz-animation-duration:1s;-ms-animation-duration:1s;animation-duration:1s}
@-webkit-keyframes bounceIn{0%{opacity:0;-webkit-transform:scale(.9)}
100%{-webkit-transform:scale(1)}}
@-moz-keyframes bounceIn{0%{opacity:0;-moz-transform:scale(.9)}
100%{-moz-transform:scale(1)}}
@-ms-keyframes bounceIn{0%{opacity:0;-ms-transform:scale(.9)}
100%{-ms-transform:scale(1)}}
@keyframes bounceIn{0%{opacity:0;transform:scale(.9)}
100%{transform:scale(1)}}
.ani-name{-webkit-animation-name:bounceIn;-moz-animation-name:bounceIn;-ms-animation-name:bounceIn;animation-name:bounceIn}
</style>
</b:if>
Simpan javascript di bawah ini di atas kode </body>
<b:if cond='data:blog.isMobileRequest == "false" and data:blog.pageType == "item"'>
<script>
//<![CDATA[
function resetScroller(e){var o=window.pageYOffset,n=document.getElementById(e).offsetTop,r=setTimeout("resetScroller('"+e+"')",speed);o>n?(scrollY=o-distance,window.scroll(0,scrollY)):clearTimeout(r)}var appended=!1,bookmark2=document.createElement("div");bookmark2.id="backtotop",bookmark2.innerHTML='<span class="ani-dur ani-name" onclick="return false;" onmousedown="resetScroller("header-wrapper");"><i class="fa fa-chevron-circle-up fa-3x"></i></span>',onscroll=function(){var e=document.documentElement.scrollTop||document.body.scrollTop;e>600?appended||(document.body.appendChild(bookmark2),appended=!0):appended&&(document.body.removeChild(bookmark2),appended=!1)};var scrollY=0,distance=40,speed=24;
//]]>
</script>
</b:if>
Silahkan ganti kode header-wrapper jika ada tag id yang lebih atas dari itu. Angka 600 adalah ketiggian scroll untuk memunculkan tombolnya.
Back To Top tanpa show hide on scroll
Silahkan simpan kode css ini di atas kode </head>. Tombol hanya ditampilkan di halaman postingan dan dihilangkan di perangkat mobile.
<b:if cond='data:blog.isMobileRequest == "false" and data:blog.pageType == "item"'>
<style type='text/css'>
.backtotop{position:fixed;bottom:20px;right:20px;cursor:pointer}
.element-animation{animation:animationFrames ease 1s;animation-iteration-count:1;transform-origin:50% 50%;animation-fill-mode:forwards;-webkit-animation:animationFrames ease 1s;-webkit-animation-iteration-count:1;-webkit-transform-origin:50% 50%;-webkit-animation-fill-mode:forwards;-moz-animation:animationFrames ease 1s;-moz-animation-iteration-count:1;-moz-transform-origin:50% 50%;-moz-animation-fill-mode:forwards;-o-animation:animationFrames ease 1s;-o-animation-iteration-count:1;-o-transform-origin:50% 50%;-o-animation-fill-mode:forwards;-ms-animation:animationFrames ease 1s;-ms-animation-iteration-count:1;-ms-transform-origin:50% 50%;-ms-animation-fill-mode:forwards}
@keyframes animationFrames{0%{opacity:0;transform:translate(-1500px,0)}
60%{opacity:1;transform:translate(30px,0)}
80%{transform:translate(-10px,0)}
100%{opacity:1;transform:translate(0,0)}
}
@-moz-keyframes animationFrames{0%{opacity:0;-moz-transform:translate(-1500px,0)}
60%{opacity:1;-moz-transform:translate(30px,0)}
80%{-moz-transform:translate(-10px,0)}
100%{opacity:1;-moz-transform:translate(0,0)}
}
@-webkit-keyframes animationFrames{0%{opacity:0;-webkit-transform:translate(-1500px,0)}
60%{opacity:1;-webkit-transform:translate(30px,0)}
80%{-webkit-transform:translate(-10px,0)}
100%{opacity:1;-webkit-transform:translate(0,0)}
}
@-o-keyframes animationFrames{0%{opacity:0;-o-transform:translate(-1500px,0)}
60%{opacity:1;-o-transform:translate(30px,0)}
80%{-o-transform:translate(-10px,0)}
100%{opacity:1;-o-transform:translate(0,0)}
}
@-ms-keyframes animationFrames{100%,60%{opacity:1}
0%{opacity:0;-ms-transform:translate(-1500px,0)}
60%{-ms-transform:translate(30px,0)}
80%{-ms-transform:translate(-10px,0)}
100%{-ms-transform:translate(0,0)}
}
</style>
</b:if>
Simpan javascript di bawah ini di atas kode </body>
<b:if cond='data:blog.isMobileRequest == "false" and data:blog.pageType == "item"'>
<script>
//<![CDATA[
function resetScroller(e){var o=window.pageYOffset,n=document.getElementById(e).offsetTop,r=setTimeout("resetScroller('"+e+"')",speed);o>n?(scrollY=o-distance,window.scroll(0,scrollY)):clearTimeout(r)}var scrollY=0,distance=40,speed=24;
//]]>
</script>
<span class="backtotop element-animation" onclick="return false;" onmousedown="resetScroller('header-wrapper');"><i class="fa fa-chevron-circle-up fa-3x"></i></span>
</b:if>
Silahkan ganti kode header-wrapper jika ada tag id yang lebih atas dari itu.
Tombol back to top ini menggunakan font awesome, jadi pastingan Anda sudah memasang font awesome di blog Anda.
http://www.kompiajaib.com/2015/09/smooth-scroll-back-to-top-javascript.html
0 Response to "Cara Membuat Tombol Back To Top di Blog"
Post a Comment