(function ($) { })(jQuery);
$.fn.extend({ topMouseover: function(self) { this.on('mouseover',function() { self.opacity.stop().animate({opacity:"1"},300); self.button.stop().animate({opacity:"1"},300); }); }, topMouseout: function(self) { this.on('mouseout',function() { self.opacity.stop().animate({opacity:"0"},300); self.button.stop().animate({opacity:"0.4"},300); }); }, wScroll: function(g) { if(g == 0) this.removeClass("no-count"); if(!this.hasClass("no-count")){ if(g > 500 && this.is(":hidden")){ this.addClass("visible"); this.css("cursor","pointer"); this.fadeIn(500); this.click(function(){ $("body, html").animate({scrollTop:0},600); this.fadeOut(300); this.addClass("no-count"); }); } if(g < 200 && this.hasClass("visible")){ this.removeClass("visible"); this.fadeOut(300); } }else{ this.unbind("click"); } } }); function toTopBtn(toTop, opacity, btn) { this.toTopBtn = $(toTop); this.opacity = $(opacity); this.button = $(btn); this.windowScroll(); this._init(); return this; } toTopBtn.prototype = { _init: function () { var self = this; this.toTopBtn.topMouseover(self); this.toTopBtn.topMouseout(self); }, windowScroll: function() { var g = $(window).scrollTop(); this.toTopBtn.wScroll(g); } } $(document).ready(function() { upButton = new toTopBtn(".toTopWrapper",".toTopOpacity",".toTopBtn"); $(window).scroll(function(){ upButton.windowScroll(); }); });
<div class="toTopWrapper"> <div class="toTopOpacity"></div> <div class="toTopPanel" title="Up"> <div class="toTopBtn"> <span class="arrow">↑</span> <span class="label">up</span> </div> </div> </div> <br><br> <?php foreach ($items->channel->item as $item): ?> <span class="title"><a href="<?php echo $item->link; ?>"><?php echo $item->title; ?></a></span><br><br> <?php echo $item->description; ?><br><br><?php echo $item->pubDate; ?> <hr><br><br> <?php endforeach; ?>
/* "TO UP" BUTTON */ .toTopWrapper { position:fixed; top:0; bottom:0; left:0; width:7%; display:none; background-color: #87ceeb; opacity: 0.3; } .toTopOpacity { position:fixed; top:0; bottom:0; left:0; width:7%; background-color: #87ceeb; opacity: 0.1; } .toTopWrapper .toTopPanel { width:100%; height:100%; font-size:13px; color: black; padding-top:10px; position:relative; } .toTopWrapper .toTopBtn { text-align:left; line-height:15px; margin-left: 30%; font-family:tahoma,arial,verdana,sans-serif; font-weight:bold; opacity: 0.2; } .toTopWrapper .toTopBtn .arrow{ font-size:14px; font-weight:bold; vertical-align:middle; } /* END OF "TO UP" BUTTON */
Source: https://habr.com/ru/post/200382/
All Articles