1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- /**
- *
- * @author 愚人码头
- * @update yingp
- * 转载自 愚人码头-web前端开发-【jQuery插件】capacityFixed-类似于新浪微博新消息提示的定位框的实例页面
- * 类似于新浪微博新消息提示的定位框
- * 更多
- */
- (function($){
- $.fn.capacityFixed = function(options) {
- var opts = $.extend({},$.fn.capacityFixed.deflunt,options);
- var FixedFun = function(element) {
- var top = opts.top;
- var right = ($(window).width()-opts.pageWidth)/2+opts.right;
- element.css({
- "right":right,
- "top":top
- });
- $(window).resize(function(){
- element.css({
- "right":right
- });
- });
- $(window).scroll(function() {
- var scrolls = $(this).scrollTop();
- if (scrolls > top) {
- if (window.XMLHttpRequest) {
- element.css({
- position: "fixed",
- top: 0
- });
- } else {
- element.css({
- top: scrolls
- });
- }
- }else {
- element.css({
- position: "absolute",
- top: top
- });
- }
- });
- element.find(".close-ico").click(function(event){
- element.remove();
- event.preventDefault();
- });
- };
- return $(this).each(function() {
- FixedFun($(this));
- });
- };
- $.fn.capacityFixed.deflunt={
- right : 100,//相对于页面宽度的右边定位
- top:100,
- pageWidth : 960
- };
- })(jQuery);
|