Comments (10)
If I understand correctly, you were running your code after load before implementing swup, but now you moved it into a swup event handler.
The issue you are mentioning (#2) was only about reloading the script after page transition, so it was once run at load by the developer elsewhere.
But don't worry, swup has lots of events you can use. Your problem should be solved by by changing the event to swup:pageView
, which is the same as swup:contentReplaced
, but is also once triggered on load.
The debugMode might help you in such situations in the future.
from swup.
oh perfect! swup:pageView
worked perfectly for me. Thank you very much, but now some pages randomly only show the pageInAnimation and not the PageOutAnimation, even though they are both being loaded in the console. Its not a huge deal, but it does make things seem a tad choppy
from swup.
Ok so what I thought was working, was actually some old cached version of my site. I dont know what happened, but I still am having the same issue as before with all my scripts. For example:
If you navigate to this page directly, it works great ->http://futsoc.co/about/other/by-the-numbers/
But if you go to the link of the same page in the nav bar (About>By The Numbers) it doesnt work.
I really want this so badly to work!
from swup.
Also, when im on the home page, swup doesnt load any links I click and the console reads
:
from swup.
I'm guessing the scripts you have in mind on page http://futsoc.co/about/other/by-the-numbers/ are the graphs. Those are initialized in the script
tag in your HTML. swup replaces the content, but that doesn't mean it runs the code in script
tags in that HTML, like swupMergeHeadPlugin can. You could, of course, use the same approach as the plugin does and run the scripts in the replaced content.
I don't really like combining HTML with scripts tho, so I would recommend moving that code for graphs to whatever you are running on swup:contentReplaced
, and wrapping it in some if statement which would check if the canvas with that ID is on the page or not.
The problem you are facing on the homepage is different. The element that you use to cover up the page is not working on the homepage because it doesn't have any styles defined there, but does have on other pages... so swup is waiting on that element to finish animating, but it never even starts. Move that element outside of the #swup
container and make the styles for it global.
You've done a good job of putting it all together, don't get discouraged by these little things... those just happen.
from swup.
@gmrchk Ok thank you! I got the home page to work. I forgot to link the stylesheet, whoops.
As for the graphs, I moved them to a separate JS file as recommended and placed them inside the event listener swup:contentReplaced. It works great, but only if I access the page from the website, if I go directly to that page they dont load. I assume its because swup isnt replacing anything, but rather loading the page for the first time. I also tried swup:pageView, but that didnt work either.
I really appreciate all your help!
from swup.
Sorry, I meant swup:pageView
, that is once triggered on load as well.
You are first enabling swup, which triggers the event, and after that, you are registering the event listener. Change the order of the scripts included in your page so the swup is enabled after the register of the event listener.
No worries, at least we can refer to your questions in the future.
from swup.
so reordering the pages seemed to work for a little bit, but i'm back to the same problem.
✔️ Go directly to http://futsoc.co/about/other/by-the-numbers/
❌ Go to http://futsoc.co/ > then navigating to to /by-the-numbers/
from swup.
Those errors have nothing to do with swup really, but...
- You are running the script for charts even when it's not on the page. Wrap it in some code that would check that the element with that id (or whatever) exists.
- I am guessing you were running the script for the charts (executed on
swup:pageView
event) before loading the library used in those Charts, or for any reason, variableChart
is not defined in your code. Maybe usingwindow.Chart
could help?
from swup.
I will go ahead and close this as there is most likely nothing wrong with swup, but feel free to ask in case you're still having trouble implementing.
from swup.
Related Issues (20)
- Think about chances for optimizations when clicking a link during a visit HOT 9
- Suggest changes to this page links from the Documentation result in a 404 on GitHub HOT 1
- Rethink tests setup for official plugins HOT 5
- pageA goto pageB; but,with diffrent link style; when back to PageA,the links style is losted
- [Bug]: Undefined link href on Safari 13.1 and lower HOT 10
- [Feature Request]: Add way to easily listen to ALL hook events HOT 3
- [Feature Request]: Expose AbortController to be able abort request programmatically HOT 20
- Feature: Allow aborting running visits HOT 1
- Ignore errors in user hooks HOT 1
- Importing helpers from CDN module HOT 2
- History navigation ignored when using custom link selector HOT 5
- [Bug]: URL in `visit:start` inconsistent between normal and history visits HOT 4
- Feature: Store parsed html document in visit object HOT 11
- [Solved]: New values in <head> are not updated HOT 2
- [Bug]: [data-swup-ignore-script] issue with Contact Form 7 in Wordpress HOT 4
- Implement tests for official plugins
- [Feature Request]: Add drop-in attribute to swap/replace content of elements outside the swup container HOT 4
- Slim down core
- [Idea]: New plugin for all route-related stuff HOT 1
- [Idea]: Put core plugins inside swup's main repo HOT 4
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 swup.