var outerWidth = $(window).width();
var height = this.$element.outerHeight();
var outerHeight = $(window).height();
- var left = parseInt((outerWidth - width) / 2, 10);
- var top;
- if (height > outerHeight) {
- top = parseInt(Math.min(100, outerHeight / 10), 10);
+ var left, top;
+ if (this.options.hOffset === 'auto') {
+ left = parseInt((outerWidth - width) / 2, 10);
} else {
- top = parseInt((outerHeight - height) / 4, 10);
+ left = parseInt(this.options.hOffset, 10);
+ }
+ if (this.options.vOffset === 'auto') {
+ if (height > outerHeight) {
+ top = parseInt(Math.min(100, outerHeight / 10), 10);
+ } else {
+ top = parseInt((outerHeight - height) / 4, 10);
+ }
+ } else {
+ top = parseInt(this.options.vOffset, 10);
}
this.$element.css({top: top + 'px'});
- // only worry about left if we don't have an overlay, otherwise we're perfectly in the middle
- if(!this.$overlay) {
+ // only worry about left if we don't have an overlay or we havea horizontal offset,
+ // otherwise we're perfectly in the middle
+ if(!this.$overlay || (this.options.hOffset !== 'auto')) {
this.$element.css({left: left + 'px'});
+ this.$element.css({margin: '0px'});
}
}
/**
* Distance, in pixels, the modal should push down from the top of the screen.
* @option
- * @example 100
+ * @example auto
*/
- vOffset: 100,
+ vOffset: 'auto',
/**
* Distance, in pixels, the modal should push in from the side of the screen.
* @option
- * @example 0
+ * @example auto
*/
- hOffset: 0,
+ hOffset: 'auto',
/**
* Allows the modal to be fullscreen, completely blocking out the rest of the view. JS checks for this as well.
* @option
<p><a data-close>Close modal</a></p>
</div>
</section>
+
+ <section>
+ <h2>With Offsets</h2>
+ <p>Clicking this link should open a reveal with offset 50, 50 from top/left</p>
+ <p><a data-open="exampleModal4">Open offset modal</a></p>
+ <div class="reveal" id="exampleModal4" data-reveal data-v-offset="50" data-h-offset="50">
+ <p>Am I in the top left?</p>
+ <p><a data-close>Close modal</a></p>
+ </div>
+ </section>
</div>
<script src="../assets/js/vendor.js"></script>