Comments (5)
Thanks a lot, works like a charm.
For anyone interested in doing the same, here is my code:
$(".js-modal-link").click(function(e) {
e.preventDefault();
var url = $(this).attr("xlink:href");
Barba.Pjax.goTo(url);
});
Simply apply the .js-modal-link
class to all anchor tags inside your svg container and you're good to go.
from barba.
Hi there, yes, I guess xlink:href is not supported.
You might handle it manually, and use Barba.Pjax.goTo
function.
I'll considering to support it natively on the next version
from barba.
Perfect @joshuabeyer ;
I'll make sure to add support to xlink:href
in the next version.
from barba.
Added support for xlink:href
in the new version.
bff3842
from barba.
This issue seems to be popping up for me again unfortunately. I've done all I can to try and resolve it, but it just doesn't seem to be recognizing clicks inside the SVG at all, so it never even traverses up the dom to find the A tag that has the xlink:href
value in it when the svg is clicked (at least according to breakpoints in developer tools). Relevant code:
HTML:
<div class="profileSvg-wrapper">
<svg id="profile" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 635.29 561.25">
<defs>
<style>[...]</style>
</defs>
<title>success-profile</title>
<a xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/profile/business" href="/profile/business" class="js-modal-link">
<g id="Business">
<polygon id="BG-Business" class="cls-1" points="190.59 449 190.58 449 190.58 449 254.11 561.25 381.17 561.25 444.7 449 190.59 449"></polygon>
<text class="cls-4" transform="translate(249.76 513.08) scale(0.98 1)">B<tspan class="cls-5" x="19.05" y="0">U</tspan><tspan x="38.79" y="0">S</tspan><tspan class="cls-6" x="55.8" y="0">I</tspan><tspan class="cls-7" x="67.65" y="0">N</tspan><tspan class="cls-6" x="88.23" y="0">E</tspan><tspan class="cls-8" x="105.27" y="0">S</tspan><tspan class="cls-9" x="122" y="0">S</tspan></text>
</g>
</a>
[...]
</svg>
</div>
JS:
document.addEventListener("DOMContentLoaded", function() {
var lastElementClicked;
Barba.Pjax.init();
Barba.Dispatcher.on("linkClicked", function(el) {
lastElementClicked = el;
});
var MyTransition = Barba.BaseTransition.extend({
start: function() {
Promise
.all([this.newContainerLoading, this.scrollTop()])
.then(this.cardSlideUp.bind(this));
},
scrollTop: function() {
[...]
return deferred.promise;
},
cardSlideUp: function() {
[...]
}
});
Barba.Pjax.getTransition = function() {
return MyTransition;
};
});
Didn't want this to be a wall of text, but that's kind of what it's become unfortunately. Iet me know if there's more I can do to resolve this.
from barba.
Related Issues (20)
- Compiling error HOT 1
- Disable `prefetch` on specific links HOT 1
- Maintain element on transition HOT 1
- Typescript issue with documentation example HOT 1
- Page content is duplicated when opened HOT 1
- CSP violation from parseFromString HOT 1
- Back button not working as intended after clicking anywhere on the page HOT 7
- Improve Google Analytics guide in the documentation
- Change the wrapper/container on the fly? HOT 3
- Typescript can't find declaration folder because the name is wrong HOT 5
- Remove polyfill.io from documentation HOT 1
- When linking to pages with hashes, hash does not appear in final URL HOT 2
- OWL Carousel doesn't work HOT 1
- Improve documentation on options to barba.init HOT 4
- External links, checkboxes and radio buttons are not working anymore HOT 12
- Checkboxes not working, and external links are not redirected HOT 3
- Form submissions broken since 2.10.2 HOT 3
- Help! All of my a href https link won't open HOT 5
- Barba breaks when route contains colon and number HOT 3
- Firefox scroll to top after transition not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from barba.