如何粘贴nicedit面板? [英] How to sticky nicedit panel?

查看:101
本文介绍了如何粘贴nicedit面板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想您知道,您的文字较大,并且面板位于编辑区域的顶部,如果要使用该面板,则必须滚动. 如果面板粘在窗口顶部,而不是消失,那就太好了.

I think you know it, you have a larger text and the panel is at the top of your edit area and if you will use the panel you must scroll. It would be nice, if the panel sticky at the top of the window, instead of going away.

任何想法,如何粘贴面板?

Any idea, how to sticky the panel?

推荐答案

比我想象的要容易.

var sticky_panelContain_offset_top = $('div.nicEdit-panelContain').offset().top;
    var sticky_panelContainer = function(){
    var scroll_top = $(window).scrollTop();
    if (scroll_top > sticky_panelContain_offset_top) { 
        $('div.nicEdit-panelContain').css({ 'position': 'fixed', 'top':0, 'left':0 });
        } else {
        $('div.nicEdit-panelContain').css({ 'position': 'relative' }); 
    }
};
sticky_panelContainer();
$(window).scroll(function() {
    sticky_panelContainer();
});

但是您必须编辑nicedit.js,因为按钮提示和下拉菜单将无法正常工作. topoffset起点必须在面板顶部. 打开nicedit.js并搜索"pos:function()",它就在开头附近. 改变

But you must edit nicedit.js, because the buttontips and pulldowns will not work right. The topoffset start must be the panel top. Open nicedit.js and search the "pos : function()", it is near the beginning. And change

var curleft = curtop = 0; 

var curleft = curtop = 0;
if ($('div.nicEdit-panelContain').css('position') == 'fixed') {
    curtop = $('div.nicEdit-panelContain').offset().top;
}

jsfiddle示例

这篇关于如何粘贴nicedit面板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆