Skip to content

Commit

Permalink
Fix iOS 10.3 resize bug, #1315
Browse files Browse the repository at this point in the history
  • Loading branch information
dimsemenov committed Apr 5, 2017
1 parent c7b9bcd commit d876209
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ var _isOpen,
_features,
_windowVisibleSize = {},
_renderMaxResolution = false,
_orientationChangeTimeout,


// Registers PhotoSWipe module (History, Controller ...)
_registerModule = function(name, module) {
Expand Down Expand Up @@ -246,13 +248,13 @@ var _isOpen,
framework.bind(document, 'mousemove', _onFirstMouseMove);
}

framework.bind(window, 'resize scroll', self);
framework.bind(window, 'resize scroll orientationchange', self);

_shout('bindEvents');
},

_unbindEvents = function() {
framework.unbind(window, 'resize', self);
framework.unbind(window, 'resize scroll orientationchange', self);
framework.unbind(window, 'scroll', _globalEventHandlers.scroll);
framework.unbind(document, 'keydown', self);
framework.unbind(document, 'mousemove', _onFirstMouseMove);
Expand All @@ -265,6 +267,8 @@ var _isOpen,
framework.unbind(window, _upMoveEvents, self);
}

clearTimeout(_orientationChangeTimeout);

_shout('unbindEvents');
},

Expand Down Expand Up @@ -543,6 +547,18 @@ var publicMethods = {
// Setup global events
_globalEventHandlers = {
resize: self.updateSize,

// Fixes: iOS 10.3 resize event
// does not update scrollWrap.clientWidth instantly after resize
// https://github.com/dimsemenov/PhotoSwipe/issues/1315
orientationchange: function() {
clearTimeout(_orientationChangeTimeout);
_orientationChangeTimeout = setTimeout(function() {
if(_viewportSize.x !== self.scrollWrap.clientWidth) {
self.updateSize();
}
}, 500);
},
scroll: _updatePageScrollOffset,
keydown: _onKeyDown,
click: _onGlobalClick
Expand Down

1 comment on commit d876209

@emufan
Copy link

@emufan emufan commented on d876209 Jun 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only working from Portrait to landscape Change, but not from landscape to Portrait in iphone

Please sign in to comment.