משתמש:חזרתי/GoToTopFromBottomLeft.js

הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.

  • פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
  • גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
  • אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
  • אופרה: ללחוץ על Ctrl-F5.
/* הוספת "מעבר לתחילת הדף" בשולי חלון הצפייה */
/* goToTop – Handy for phones. Adds a small button to the bottom right of the page which moves to the top of the page when tapped. */
/* https://en.wikipedia.org/wiki/User:Numbermaniac/goToTop.js :מקור */
$(function(){
'use strict';

$('body').append('<span id="to-top">↟ מעבר למעלה ↟</span>');
var $topButton = $('#to-top');

$topButton.css({
	'color': 'blue',
	'position': 'fixed',
	'bottom': '-30px',
	'left': '4px',
	'cursor': 'pointer',
	'transition': 'bottom 0.5s',
	'-webkit-transition': 'bottom 0.5s',
	'user-select': 'none',
	'-webkit-user-select': 'none',
	'-moz-user-select': 'none',
	'-ms-user-select': 'none'
}).click(function(){
	$('html, body').animate({scrollTop: 0},'fast'); /* Durations are given in milliseconds; higher values indicate slower animations, not faster ones. The default duration is 400 milliseconds. The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 milliseconds, respectively. */
});

$(window).scroll(function(){
	if ($(window).scrollTop() > 100 ) {
		$topButton.css('bottom', '4px');
	}else{
		$topButton.css('bottom', '-30px');
	}
});
});