miguel-perez / smoothState.js

Unobtrusive page transitions with jQuery.
MIT License
4.43k stars 506 forks source link

API Enhancements #78

Open rolandschuetz opened 10 years ago

rolandschuetz commented 10 years ago

Hello,

SmoothState should provide methods for enabling and disabling the behavior during run time.

Best regards, Roland

miguel-perez commented 9 years ago

@rolandschuetz do you mean, like, having an init and destroy method?

rolandschuetz commented 9 years ago

I can't really think of the use case anymore.

The idea behind was that some kind of user interaction and resulting dom transformation is hard to revert back and therefore it would be easier if the next page change would just reload the whole screen.

var smoothState = $('#main').smoothState({...});

...

var onSomething = function() {
    $('#main').animate({
        width: '400px'
    }).html('crazy animation, which is hard to revert');
    smoothState.disable(); // next link should just reload the whole page
};
miguel-perez commented 9 years ago

I think it's good practice to offer a destroy method $main.data('smoothstate').destroy(), it would be pretty easy too. I'm not so sure an init method is needed since that happens automatically when you run $.fn.smoothState().

There are some other API improvements that could be made, too, like being able to get/set options. And making sure smoothState works with things like RequireJS and the AMD module format.Some really great patterns have already been defined. I would be interested to see how smoothState could be improved to match these best practices.

@rolandschuetz do you think you could do a little research in this area? Figure out how smoothState compares and make suggestions for improving the API?