Baik langsung saja di sini saya akan memberikan cara Membuat Smooth Scroll Back To Top di Blogger. Bagi sebagian sobat mungkin sudah familiar dengan kata-kata smooth scroll back to top / kembali ke atas. Smooth sendiri berarti lembut. Jadi smooth scrollartinya menggulung dengan lembut. Untuk membuat Tombol Back to Top biasa, mudah saja sebetulnya, tinggal menambahkan kode # akan tetapi kembali ke atas secara langsung tidak lembut.

Tombol back to top biasanya digunakan pada blog dengan artikel yang panjang, untuk memudahkan pengunjung melihat kembali artikel di atas. Ada beberapa cara untuk menambahkan tombol back to top ini.
Di sini akan saya share cara yang termudah, tanpa Edit HTML. Hanya menambahkan widget saja. Ada dua Style yang akan saya berikan, silahkan sobat pake mana suka.
Style1 (tanpa fade in dan fade out)
Maksud tanpa fade in dan fade
out di sini adalah, tombol akan langsung muncul begitu blog dibuka.
Untuk membuatnya, silahkan tambahkan
widget HTML/JavaScript, masukan kode ini :
<script
type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<a
style="display:scroll;position:fixed;bottom:5px;right:5px;"
href='javascript:void(0);' onclick='jQuery('html,
body').animate({scrollTop:0}, 'slow');' title="Kembali ke atas"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgP6B790xq_7mla2Goc4wYQFlr9mejus_0A3ANjEGEyAIKav_Ohs9n6Ws3C8voeL7FhKjlrXycr6KNvQl9M6iDuIdPgWeitNw7oJ0JQWn0DK9TJIaSySVoO6qNfoKcNBOm5o29xVfS6q_g/s400/Back-to-top.png" /></a>
Style2 (dengan fade in dan fade out)
Maksud fade in dan fade out disini adalah, tombol
tidak akan langsung muncul kecuali telah di scroll ke bawah.
Untuk membuatnya, tambahkan widget HTML/JavaScript
dan masukan kode ini :
<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: '<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgP6B790xq_7mla2Goc4wYQFlr9mejus_0A3ANjEGEyAIKav_Ohs9n6Ws3C8voeL7FhKjlrXycr6KNvQl9M6iDuIdPgWeitNw7oJ0JQWn0DK9TJIaSySVoO6qNfoKcNBOm5o29xVfS6q_g/s400/Back-to-top.png" />', //HTML for control, which
is auto wrapped in DIV w/ ID="topcontrol"
controlattrs: {offsetx:5, offsety:5},
//jarak ke kanan / bawah
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:'Kembali ke Atas'})
.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>
Kostumisasi
Untuk mengganti tombol, ganti image url yang berwarna
merah
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgP6B790xq_7mla2Goc4wYQFlr9mejus_0A3ANjEGEyAIKav_Ohs9n6Ws3C8voeL7FhKjlrXycr6KNvQl9M6iDuIdPgWeitNw7oJ0JQWn0DK9TJIaSySVoO6qNfoKcNBOm5o29xVfS6q_g/s400/Back-to-top.png
Untuk mengganti tulisan Kembali
ke Atas, silahkan edit juga tulisan Kembali
ke Atas yang berwarna merah.
Sumber : http://blog.kangismet.net/2012/07/membuat-smooth-scroll-back-to-top-dengan-jquery.html
Tinggalkan komentar anda di sini :)
ReplyDeletethanks atas informasinya, akan saya terapkan
ReplyDeleteSilahkan :)
DeleteSama-sama , senang bisa membantu :D
haduh puyemgnih koding koding
ReplyDeleteWalaah , bingung dimananya emang kak :| ?
DeleteAir Jordan 11 Gamma Blue, discount christian louboutin, cheap jordans , christian louboutin, Bags Louis Vuitton, uggs outlet, Cheap Louis Vuitton Handbags, ugg australia, ugg soldes, uggs on sale, christian louboutin shoes, ugg, Discount LV Handbags, discount nike jordans, Christian Louboutin Bois Dore, Discount Louis Vuitton, christian louboutin remise 50%, cheap nike jordan shoes, wholesale jordan shoes, cheap christian louboutin, Cheap LV Handbags, Christian Louboutin Daffodile, ugg boots, ugg pas cher
ReplyDeletechenlina20150710
ReplyDeletegucci bags
tod's shoes
michael kors outlet
mulberry uk
oakley sunglass
christian louboutin shoes
ray ban wayfarer
michael kors outlet online
chanel handbags
tory burch outlet
hollister clothing
jordan 13 shoes
longchamp le pliage
coach outlet online
oakley sunglasses sale
louis vuitton outlet
new jordans
pandora charms
cheap jerseys
coach outlet
oakley sunglasses
polo ralph lauren
mont blanc pen
hollister kids
abercrombie and fitch
hollister clothing
ray ban sunglasses
ralph lauren outlet
abercrombie kids
gucci belt
mulberry handbags
chanel uk
louboutins
louis vuitton
hollister jeans
red timberland boots
michael kors
coach factory outlet
cheap oakley sunglasses
ray ban glasses
as
ugg boots, louis vuitton outlet stores, louis vuitton outlet stores, michael kors canada, nike air max, cheap barbour jackets, swarovski australia, tommy hilfiger outlet stores, converse outlet, lululemon australia, supra footwear, true religion outlet stores, gucci, ralph lauren, ralph lauren outlet online, nike factory store, mizuno wave, swarovski uk, oakley outlet, woolrich usa, iphone 6 case, ugg, cheap michael kors, harrods london, barbour sale, tory burch sandals, www.lululemon.com, nike shoes for men, dre headphones, the north face, abercrombie kids, michael kors outlet online, cheap basketball shoes, new balance,ray bans, lululemon outlet, bcbg max, hollister, christian louboutin, uggs outlet, nike air max, dre headphones, new balance, salomon schuhe, tory burch shoes, prada, chanel handbags, indoor soccer shoes, nike schuhe
ReplyDelete