Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better bug fix #78 #80 #81

Merged
merged 3 commits into from
Nov 13, 2015
Merged

Better bug fix #78 #80 #81

merged 3 commits into from
Nov 13, 2015

Conversation

nvartolomei
Copy link
Contributor

This in my opinion is 100 times better than fix in patch-4.0.1 as this does not trigger a window refresh. On example pages maybe it looks more or less good but in real web sites doing a page refresh on every history back button is pretty ugly, especially on iOS.

This does not work with custom elements like overlays however, maybe a better way would be to save somewhere all DOM modifications in out method and in in method to revert them?

As I understand it will work only for elements that have an in animation on the same elements that have an out one, because this will trigger reverting classes.

@blivesta
Copy link
Owner

Nice work! certainly reload is not the better. But a problem occurs when the onLoadEvent: false. So I think that needs to fix.
line 92

$window.on('load.' + namespace, function() {
  if(__.settings.timer) clearTimeout(__.settings.timer);
  __.in.call(_this);
});

$window.on('pageshow.' + namespace, function() {
  if(event.persisted) __.in.call(_this);
});

if(!options.onLoadEvent) $window.off('load.' + namespace);

@nvartolomei
Copy link
Contributor Author

@blivesta here you go with your fix. Actually why not do this instead:

if (options.onLoadEvent) {
  $window.on('load.' + namespace, function() {
    if(__.settings.timer) clearTimeout(__.settings.timer);
    __.in.call(_this);
  });
}

$window.on('pageshow.' + namespace, function() {
  if(event.persisted) __.in.call(_this);
});

Why attach event handler and then remove it, why not check onloadevent property from the beginning?

@blivesta
Copy link
Owner

I don't remember, but your proposal is good. 'pageshow' event is also unnecessary in addTimer method. Can you please fix it?

if(options.onLoadEvent) {
  $window.on('load.' + namespace, function() {
    if(__.settings.timer) clearTimeout(__.settings.timer);
    __.in.call(_this);
  });
}

$window.on('pageshow.' + namespace, function(event) {
  // Safari back button issue #78 #80
  if(event.originalEvent.persisted) __.in.call(_this);
});


//remove
//if(!options.onLoadEvent) $window.off('load.' + namespace);

addTimermethod

addTimer: function(){
  var _this = this;
  var $this = $(this);
  var options = $this.data(namespace).options;

  __.settings.timer = setTimeout(function(){
    __.in.call(_this);
    $(window).off('load.' + namespace);
  }, options.timeoutCountdown);
},

@nvartolomei
Copy link
Contributor Author

:shipit:

blivesta added a commit that referenced this pull request Nov 13, 2015
@blivesta blivesta merged commit 79dca6b into blivesta:master Nov 13, 2015
@blivesta
Copy link
Owner

Thanks!

@nvartolomei
Copy link
Contributor Author

I still have more thoughts for this. So more to come. :)

On Friday, November 13, 2015, B L I V E S T A [email protected]
wrote:

Thanks!


Reply to this email directly or view it on GitHub
#81 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants