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
Barba.js v2? Open discussion #41
Comments
Hi. Barba is cool )
It is cool, but I really can't use different Transition based on the current link because I can't access it from there. About limits — impossibility to have several updatable containers |
Hello @terion-name !
Many thanks for your feedbacks, I really appreciate it. |
|
also:
|
Hello again @terion-name
|
|
Oh, and redirects handling |
Redirects are easily handled if use And about forms, here is a demo how I handle forms now (this is a bad code, but I've needed to make it work VERY quick), it also handles redirects: handleForms(e) {
e.preventDefault();
const url = e.target.getAttribute('action');
const method = e.target.method || 'get';
const formData = new FormData(e.target);
fetch(url, {
method: method,
body: formData
}).then(function (response) {
response.text().then(function(data) {
var newContainer = new Promise(function(resolve, reject) {
var container = Barba.Pjax.Dom.parseResponse(data);
Barba.Pjax.Dom.putContainer(container);
Barba.Pjax.History.add(response.url);
window.history.pushState({}, '', response.url);
setTimeout(resolve(container), 1);
});
var transition = Object.create(Barba.Pjax.getTransition());
Barba.Pjax.transitionProgress = true;
Barba.Dispatcher.trigger('initStateChange',
Barba.Pjax.History.currentStatus(),
Barba.Pjax.History.prevStatus()
);
var transitionInstance = transition.init(
Barba.Pjax.Dom.getContainer(),
newContainer
);
newContainer.then(
Barba.Pjax.onNewContainerLoaded.bind(Barba.Pjax)
);
transitionInstance.then(
Barba.Pjax.onTransitionEnd.bind(Barba.Pjax)
);
});
});
} |
Thanks @terion-name for your inputs! Let me explain better: Then, at the form submit the user will see the page fade out and the same page fading in, but with a different scroll position. For a better UX should be your site to manually handle the submission of your form and not Barba.js responsibility. For example, you may want to just hide the form, display a progress loading and then show the feedback (and maybe scroll to the feedback message to make sure the user will see it). Making the transition on the whole container at the form submit it looks too much for me. Even if we let the user disable / enable functionality I wonder how many people will actually use it. For "redirects handling", you meant related to the form submission? |
nope. I can use custom (or predefined in package) transition for this:
Moreover, I'm using such thing now, for simulating tabs: links get Of course, manual form handling is ideal, but It can be said the same for async page changing :) And purpose of this lib is to make this as simple a possible, so handling forms is logical.
not only. backend can return redirects. xhr resolves them, barba — not. so if I click on |
Sorry for the late reply @terion-name , I've been quite busy recently. About the redirect handing, thanks! Cheers |
@luruke Barba is great! One pattern that it does not accommodate out of the box is if you want to return the user to the same scroll position. For example, if there is a long feed with links to individual posts and a 'back to feed' link, that when clicked returns them to the feed page at the same scroll position as when they left. There is a likely a way to accomplish this within the current API, so perhaps it is just a matter of putting together another code example in the docs. |
first of all, i really enjoy working with barba.js, thank you for your great effort @luruke
i know you could do something like this easily with conditions, but i think it would make working with barbe.js even nicer if its build in, theres probably also plenty of room to take the idea further. |
Thanks for the suggestion @max-schu . Cheers |
Hi @luruke, Thanks for your work, I was about to create the same kind of library, but then I found yours and it seems to work really well! :) My initial reactions (some may be my mistakes)
|
Thank you for your precious advices @tipsy! FormsUsually, when I have forms on my websites using barba.js I prefer to handle them manually via ajax. But could be an idea. CSS transitionsIt's quite easy if you want to use CSS transitions, you just need to create a basic transition that adds specific CSS classes during the different states of transition. Prefetchyes, nice idea. PolyfillStrange, I'm including this https://github.com/taylorhakes/promise-polyfill https://github.com/luruke/barba.js/blob/master/src/index.js#L3 Generally I'd like to not add hundreds of features into barba.js, I would like to keep it simple as possible, but still very flexible. Also one thing that scary me most is to keep the documentation very light without complicating it. |
I guess it depends on what you're making. I'm making a native-looking application with user settings (imagine it like android/iphone settings), so posts should feel the same as gets when the user navigates around. I can solve it like @terion-name did, but it would be nice if it worked out of the box. (I realize I'm probably not your target demographic though). |
Just my two cents: add an auto html head update feature. And good job for the library. I've just started to enjoy it. |
Hi again @luruke, After playing with Barba some more, I ended up with the classes
Maybe it's useful for you. Thanks again for your work on Barba! |
Hi! Maybe the possibility to add the |
Hi.
I hope you find this useful |
Thank you @oscarotero for your inputs! |
This weekend I finally started working on this on the branch v2-dev 💪 I mostly worked on the build system / CI:
To have a view of a build process: Next steps:
If anyone wants to contribute, will be great if you could try the build process on your machine or help me to write more tests! 🙏🏻 |
Edit: Here's the gist showing what I mean: https://gist.github.com/nicooprat/ea184d51ba3c9ab131bf1d3400ef0ef0 I played a bit with Barba yesterday, and here are the features I'd dream of, and so the structure I'd need. Overall, I think Barba should behave and look more like a router. Features
Actually all of this is already kinda doable with Structure
So internally, Barba would do the following when a link is clicked (speaking of transitions, the rest of the library works fine), pretty similar to the fade transition in the docs does:
The move to ES6 is great of course, although I'm not sure including the Promise polyfill is a good idea (in my build tools I already have one, and I don't want to have it included twice): could just declare it as a dep? Speaking of this, I think webpack and others shouldn't be defined in Hopefully I can spend some time on v2 in the next few weeks to help. I'll also try to make a quick gist to show what I'd like in a more concrete way. Anyway, I looked at a bunch of other librairies, and I think Barba is the closest to what I need, although the current code structure doesn't really fit for what I'm trying to do. (Hope I'm clear and thanks for reading me :)) |
Love the framework! Couple things I'd like added..
|
Offline-Support for the Barba Cache would be also nice for Barba.js v2 |
One of my favorite aspects of Barba is that it does not behave like a typical router in that you do not need to define routes. This makes it incredibly simple to drop into a project. Having used a framework like Bigwheel from Jam3 on many projects, I've realized how limiting the need to define routes can be for a large site with many dynamic routes (like a WordPress site). Hoping V2 keeps the simplicity of V1. |
@lsbyerley What's your use-case for detecting a back/forward button press and where do you want to know this? Using the existing API and some listeners it is possible to differentiate between the user following a link or navigating the browser history. The latter is caused by a popstate event. Barba starts listening to this event when you call var popping = false;
window.addEventListener('popstate', function () {
popping = true;
});
Barba.Pjax.start();
Barba.Dispatcher.on('initStateChange', function() {
popping = false;
});
Barba.Pjax.getTransition = function() {
return popping ? HideShowTransition : FadeTransition;
}; Disabling animations on transitions triggered by |
@bramcordie Thanks for the explanation. I'm adding an |
Hey @lsbyerley, our use-case are completely different but I think I can help you out. Instead of listening to Below is some example code. You might need to change the Barba.Dispatcher.on('initStateChange', function(currentStatus) {
$('nav').find('a').each(function() {
$(this).toggleClass('is-active', $(this).href === currentStatus.url);
});
}); @luruke I don't think the source of the official docs are public so I can't send a pull request to add this example? I'm not sure where it belongs but you might consider adding it under http://barbajs.org/faq.html? |
Hey @bramcordie thanks man this works great and solves the back/forward issue! |
@bramcordie thanks this is great. How can I trigger the transitions on page load? |
@terion-name regarding your form click handlers when using Barba.. do you ever have an issue with the submit click handler firing? For me, on page load, the handler works fine and makes an ajax request, however, if i navigate to another page with the same form, the click handler doesn't get applied and the action url is loaded in the browser when submitting the form |
Hello I seem to have a issues were whenever I transition from a page that is using a css media query to one that is not on load the page either does not utilize the media query or if i'm coming from a page with with a media query it keeps the media query even though it should not be there. After I refresh the page the page works fine I think I placed this question in the wrong area. Where should I post this please? |
Hello @luruke :) When will v2 come out ? |
Mine supports in Firefox but Google docent? |
Just a quick update saying that something is (slowly) moving... 🐌 @thierrymichel and @epicagency are helping me with the development – hopefully new infos coming soon! |
@luruke Thanks for this phenomenal library. Maybe after the launch of V2 it may be worth while to open up a forum of some sort so people can post specific problems they're having that aren't actual issues with barba.js. I've noticed a lot of issues being opened up that aren't specific problems with barba, but instead are troubleshooting basic HTML, CSS and JS stuff and this could help keep the issues on topic and related to barba itself. Just a thought! Thanks again :) |
Just to say - - thanks for your work, keeping eager eyes open for v2 :) |
If you're interested in testing the v2… 👋me! 😊 |
ping @theamnesic @Djules @gfnool @19h47 |
Avec plaisir ! |
Would love to test it 👋 |
I'm glad to help you! |
::wave emoji:: I’d love to check it out! |
Oh yeah, I would love too ✌🏼 |
I’d love to test it! 👋 |
I'd also love to test it!!! 👋 |
Hi here. Thanks for using BarbaJS. |
Hi All!
I am really happy to see more and more people using Barba.js.
It's really nice to be able to give something back to the open source community.
I am also proud that in ~20 issues opened from users, there is not a single bug that has been encountered.
The library has been initially used just from myself, but now we should look ahead and see how the library could be improved in a eventually major release.
I think the design and the concept behind the library seems working very well, it's flexible and it's easily adaptable to the user's need.
What I think could really be improved are how the API methods are exposed, and the naming in general.
Can you help me?
I would like to have an open discussion and see what are your ideas about it:
Thank you! 🎉
The text was updated successfully, but these errors were encountered: