简体   繁体   English

在方形空间(YUI)上重绘元素的问题

[英]Issue with redrawing elements on squarespace (YUI)

This is a very, very peculiar case. 这是一个非常非常特殊的案例。 The title before getting a solution was " Extreme force redraw element on jQuery ". 获得解决方案之前的标题是“ jQuery上的Extreme force redraw元素 ”。 All the rest below is unmodified. 以下所有其他内容未经修改。

Using Squarespace (has many YUI elements), I set the footer as display: none on Custom CSS. 使用Squarespace(有许多YUI元素),我在自定义CSS上将页脚设置为display: none The footer has a gallery block (lots of scripts there). 页脚有一个画廊块(那里有很多脚本)。

Then I move the footer into another page element using prepend . 然后我使用prepend将页脚移动到另一个页面元素。 All together is something on those lines: 所有这些都是这样的:

 $yo = $('#yo'); $yo.parent().remove(); $('#here').prepend($yo); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <footer style="display: none"> delme <div id="yo">oi</div> </footer> <div id="here"> move here </div> 

That, of course, works with no problem here. 当然,这在这里没有问题。 But in my use case, it doesn't. 但在我的用例中,它没有。 If I remove the Custom CSS, it kind of works. 如果我删除自定义CSS,它有点工作。 There's still a bug in which it doesn't properly resize, and keeps the same size as the first parent, not the second as it should. 还有一个错误,它没有正确调整大小,并保持与第一个父级相同的大小,而不是它应该的第二个大小。 So, the gallery is still not properly redraw! 所以,画廊仍然没有正确重绘! In fact, it's also not the CSS display 's fault. 事实上,它也不是CSS display的错。

The remove there is not the problem and makes no difference to be removed. remove没有问题,没有任何区别被删除。 I left it there just to give a glimpse of all the noise I'm trying to handle. 我把它留在那里只是为了一瞥我正在努力处理的所有噪音。

Even more, if I add this to the onLoad script: 更重要的是,如果我将它添加到onLoad脚本:

$('footer').hide()

It works the same as expected. 它的工作原理与预期相同。 In fact, the later I leave to hide it, the better it will work, but never as perfect as it should. 事实上,我后来隐藏它,它会越好,但它永远不会像它应该的那样完美。 If I hide it on DOMready it will be half broken. 如果我将它隐藏在DOMready ,它将被破坏一半。 And if I hide it on CSS, as I said earlier, it won't even show up ever. 如果我把它隐藏在CSS上,正如我之前所说,它甚至都不会出现。 That is... 那是...

In all cases simply opening up the Console Window or manually resizing the window with the mouse, the gallery will show up exactly as it should, all fixed up properly, no issues whatsoever! 所有情况下,只需打开控制台窗口或用鼠标手动调整窗口大小,图库就会完全按照预期显示,所有内容都正确固定,没有任何问题!

So, I supposed trying to force a redraw should make things work. 所以,我认为试图强制重绘应该让事情有效。 Well, it doesn't. 嗯,事实并非如此。 offsetHeight doesn't work and fiddling with css also do nothing. offsetHeight不起作用,摆弄css也什么都不做。 Of course I also tried trigger('resize') but no luck there! 当然我也试过trigger('resize')但没有运气! :( Tried for hours, nothing seem to work, even in the console! :(试了好几个小时,似乎没什么用,即使在控制台!

I'll keep the bug here for a while. 我会在这里保留一段时间的bug。 Right now, it shows the problem with hiding it at $(document).ready : 现在,它显示了将其隐藏在$(document).ready

http://www.cregox.com/bugs/bannerify/ http://www.cregox.com/bugs/bannerify/

Is there a way to "simply" force that redraw so I won't have to keep digging up what in the bleep squarespace is doing with the CSS that does all this mess? 有没有办法“简单地”强制重绘,所以我不必继续挖掘哔哔的方形空间正在做的所有这些混乱的CSS做什么? I actually bet sqsp does a good job there, but at least in my head it is a big mess. 我实际上打赌sqsp在那里做得很好,但至少在我脑海里这是一个很大的混乱。

It seems I was right: Squarespaces' gallery component needs a heads-up that you have moved it into new quarters. 看起来我是对的:Squarespaces的画廊组件需要一个单挑,你已经把它搬到了新的地方。

After your call to $('#here').prepend($yo) , add this line: 在你打电话给$('#here').prepend($yo) ,添加这一行:

Y.one( $yo.get(0) ).simulate('resize');

如果手动调整大小有效,那么您可以尝试:

$(window).trigger('resize');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM