【问题标题】:Highslide not following scroll on pageHighslide 不跟随页面上的滚动
【发布时间】:2015-02-23 13:40:13
【问题描述】:

我有一个位于 iframe 中的父页面。我想调用跟随父页面滚动的 highslide。

我尝试放置代码:Highslide, Auto follow scroll

当父页面不在 iframe 中时,它可以正常工作。 但是当父页面在 iframe 中时,Highslide 无法自动跟随滚动。

请帮忙

【问题讨论】:

    标签: highslide


    【解决方案1】:

    将 Highslide 固定弹窗模组 (http://www.highslide.com/studies/position-fixed.html) 的脚本放在父页面中,并使用 highslide-full.js 代替 highslide-with-gallery.js / highslide-with-html.js

    演示页面:http://roadrash.no/hs-support/inside-iframe-fixed-mod.html

    // Highslide fixed popup mod. Requires the "Events" component.
        if (!hs.ie || hs.uaVersion > 6) hs.extend ( hs.Expander.prototype, {
          fix: function(on) {
            var sign = on ? -1 : 1,
              stl = this.wrapper.style;
    
            if (!on) hs.getPageSize(); // recalculate scroll positions
    
    
            hs.setStyles (this.wrapper, {
              position: on ? 'fixed' : 'absolute',
              zoom: 1, // IE7 hasLayout bug,
              left: (parseInt(stl.left) + sign * hs.page.scrollLeft) +'px',
              top: (parseInt(stl.top) + sign * hs.page.scrollTop) +'px'
            });
    
            if (this.outline) {
              stl = this.outline.table.style;
              hs.setStyles (this.outline.table, {
                position: on ? 'fixed' : 'absolute',
                zoom: 1, // IE7 hasLayout bug,
                left: (parseInt(stl.left) + sign * hs.page.scrollLeft) +'px',
                top: (parseInt(stl.top) + sign * hs.page.scrollTop) +'px'
              });
    
            }
            this.fixed = on; // flag for use on dragging
          },
          onAfterExpand: function() {
              this.fix(true); // fix the popup to viewport coordinates
          },
    
          onBeforeClose: function() {
            this.fix(false); // unfix to get the animation right
          },
    
            onDrop: function() {
              this.fix(true); // fix it again after dragging
          },
    
          onDrag: function(sender, args) {
            //if (this.fixed) { // only unfix it on the first drag event
              this.fix(true);
            //}
          }
    
        });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-17
      • 2011-10-05
      • 1970-01-01
      相关资源
      最近更新 更多