IE scrolls top of iframe into view when modal within the iframe is shown
IE scrolls top of iframe into view when modal within the iframe is shown
Created by: danschumann
Hello,
I have an iframe that is like 3000+ pixels in height. The top page scrolls, as the iframe will be whatever size it needs to be, so that it won't have a scrollbar.
There is a problem in IE, caused by this line:
transition ?
that.$element.find('.modal-dialog') // wait for modal to slide in
.one('bsTransitionEnd', function () {
that.$element.trigger('focus').trigger(e) // this line causes the problem!!!
that.$element.trigger(e) // this fixes the problem!!!
})
.emulateTransitionEnd(Modal.TRANSITION_DURATION) :
that.$element.trigger('focus').trigger(e)
At approximately line 998 in 3.3.2
As you can see, removing trigger('focus') fixes it.
The problem in detail is: the top frame's scrollTop becomes the iframes offset().top.
This can be very unwanted. The user may be 2000 pixels into the iframe content, looking at something at the bottom, and when they open a modal, they are way at the top of the page again ( top of the iframe at least ).
Here is a hack I am using to fix:
$modal.on('show.bs.modal', function(){
// IE Fix: bootstrap does a focus, which screws up the iframe by scrolling the parent window
setTimeout(function(){
$modal.find('.modal-dialog').off('bsTransitionEnd');
}, 350);
});