zoukankan      html  css  js  c++  java
  • 百度编辑器固定高度后图片框定位不准

    百度编辑器固定高度后图片框定位不准

    固定高度属性:initialFrameHeight:400

    定位不准截图:

    修改方法一:修改ueditor.all.js文件中attachTo中的top;如图注释掉的是定位不准的,改成底下未注释的;

                attachTo: function (targetObj) {
                    var me = this,
                        target = me.target = targetObj,
                        resizer = this.resizer,
                        imgPos = domUtils.getXY(target),
                        iframePos = domUtils.getXY(me.editor.iframe),
                        editorPos = domUtils.getXY(resizer.parentNode);
                    
                    domUtils.setStyles(resizer, {
                        'width': target.width + 'px',
                        'height': target.height + 'px',
                        'left': iframePos.x + imgPos.x - me.editor.document.body.scrollLeft - editorPos.x - parseInt(resizer.style.borderLeftWidth) + 'px',
                        //'top': iframePos.y + imgPos.y -  me.editor.document.body.scrollTop - editorPos.y - parseInt(resizer.style.borderTopWidth) + 'px'
                        'top': iframePos.y + imgPos.y -  me.editor.window.scrollY - editorPos.y - parseInt(resizer.style.borderTopWidth) + 'px'
    
                    });
                }

    修改方法二:

    1. 修改ueditor.config.js中自动长高属性autoHeightEnabled:true(默认就是true,没被注释掉的化不用改)有注释的去掉注释,缺少的加上。
    2. 自定义编辑器初始化属性时,加上固定高度和设置自动长高为false:initialFrameHeight:400,autoHeightEnabled:false。
    3. 修改修改ueditor.all.js文件中attachTo中的top;判断me.editor.options.autoHeightEnabled来控制定位。

      

                attachTo: function (targetObj) {
                    var me = this,
                        target = me.target = targetObj,
                        resizer = this.resizer,
                        imgPos = domUtils.getXY(target),
                        iframePos = domUtils.getXY(me.editor.iframe),
                        editorPos = domUtils.getXY(resizer.parentNode);
                    
                    var eh = me.editor.options.autoHeightEnabled ? me.editor.document.body.scrollTop : me.editor.window.scrollY;
                    domUtils.setStyles(resizer, {
                        'width': target.width + 'px',
                        'height': target.height + 'px',
                        'left': iframePos.x + imgPos.x - me.editor.document.body.scrollLeft - editorPos.x - parseInt(resizer.style.borderLeftWidth) + 'px',
                        'top': iframePos.y + imgPos.y - eh - editorPos.y - parseInt(resizer.style.borderTopWidth) + 'px'
    
                    });
                }
                
    imgPos.x
  • 相关阅读:
    Apache 阿帕奇 配置运行环境
    2019年6月多校联训b层——搜索算法 Problem A 宽搜 营救
    西安集训B Day1 test 问题 C: 小明的城堡
    西安集训B层Day1 test 问题 A: 旅行日记
    二分答案—洛谷P1182 数列分段`Section II`
    2019.5.25 Noip模拟测试2 T2题解
    2019.5.25 Noip模拟测试2 T1题解
    DP专题练习 toasting
    2019.5.1 DP专题训练 山峰数(hill)
    React 点击按钮显示div与隐藏div
  • 原文地址:https://www.cnblogs.com/tong2018/p/12567662.html
Copyright © 2011-2022 走看看