Comments (5)
Hi @RoyVeldman,
Can you give us a more solid description by including pieces of code so we can have an idea about how you deal with your links ?
Best regards,
Anthodpnt
from highway.
Yes sorry,
These are the links
<div class="indicators">
{% for item in craft.entries.section('products').all() %}
<a href="{{ item.url }}" class="cool-btn" data-transition="productPage">
<span>{{ loop.index }}</span>
<span>{{ item.title }}</span>
</a>
{% endfor %}
</div>
My app.js
const H = new Highway.Core({
renderers: {
},
transitions: {
default: Fade,
contextual: {
productPage: productPageTransition
}
}
});
For the nav active class I use your code, I only changed the querySelector
// Get all menu links
const links = document.querySelectorAll('.indicators a');
// Listen the `NAVIGATE_IN` event
// This event is sent everytime a `data-router-view` is added to the DOM Tree
H.on('NAVIGATE_IN', ({ to, location }) => {
// Check Active Link
for (let i = 0; i < links.length; i++) {
const link = links[i];
// Clean class
link.classList.remove('is-active');
// Active link
if (link.href === location.href) {
link.classList.add('is-active');
}
}
});
from highway.
Hi @RoyVeldman,
The only issue I could see would be that your links might be in the data-router-view
meaning that you have to select them inside the NAVIGATE_IN
event to make sure that you get the right links from the right data-router-view
.
In the documentation the example is based on a list of links outside the data-router-wrapper
meaning that they stay the same during navigation and so they can be selected once outside the NAVIGATE_IN
event. But if the links are located inside the data-router-view
elements that are swapped during navigation you have to get them back every time the DOM change using the events.
It's hard to be more precise but I suppose this is that kind of issue you get here since the documentation has been tested multiple times and is even running on the documentation website without any problem. Unfortunately this is more a problem related to your code than a problem coming for Highway.
Keep me in touch if I spotted the issue or if you find it yourself.
Best regards,
Anthodpnt
from highway.
@Anthodpnt Thanks for replying so quick, but yes I guess that was the issue indeed, my links are inside my data-router-view
. I am switching the active class now with adding and removing the classes based on to
and from
querySelector
in my contextual
transition file.
from highway.
@RoyVeldman So I assume that your problem is resolved and that I can close this issue.
from highway.
Related Issues (20)
- Javascript functions doesn't works on the second time HOT 1
- Locomotive scroll not updating after page transition HOT 3
- I can't get the HIGHWAY.redirect() to work HOT 1
- Updating CSS for incoming page – (Highway maintains the outgoing page's CSS) HOT 5
- data-transition attribute no longer works in 2.2.2 HOT 2
- Update /refresh/bind links dynamically created with javascript HOT 1
- New href with highway HOT 13
- Adding additional headers to page requests
- Add index.d.ts file for better IDE typehinting
- back/forward buttons pressed during transition break the website
- Facebook Pixel Tracking HOT 3
- Fatal error on transition to mismatching URL scheme, while remaining on the same domain
- Can't work with CDN
- Improper use of DOM events
- Highway not working with DOM elements rendered by javascript HOT 1
- H.redirect always refresh page HOT 1
- Help
- H is undefined HOT 1
- Navigation with parameters and anchor not working
- Javascript not working after page transition HOT 2
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 highway.