Highslide, Auto follow scroll

≡放荡痞女 提交于 2019-12-06 15:43:00

The below code is what you need. Live demo: http://www.highslide.com/studies/position-fixed.html
Note: requires highslide-full.js

    // 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);
        //}
      }

    });
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!