Coder Social home page Coder Social logo

Comments (10)

gmrchk avatar gmrchk commented on May 3, 2024

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.

Ehmo6152 avatar Ehmo6152 commented on May 3, 2024

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.

Ehmo6152 avatar Ehmo6152 commented on May 3, 2024

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.

Ehmo6152 avatar Ehmo6152 commented on May 3, 2024

Also, when im on the home page, swup doesnt load any links I click and the console reads
capture
:

from swup.

gmrchk avatar gmrchk commented on May 3, 2024

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.

Ehmo6152 avatar Ehmo6152 commented on May 3, 2024

@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.

gmrchk avatar gmrchk commented on May 3, 2024

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.

Ehmo6152 avatar Ehmo6152 commented on May 3, 2024

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/

I also get this error
capture

from swup.

gmrchk avatar gmrchk commented on May 3, 2024

Those errors have nothing to do with swup really, but...

  1. 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.
  2. 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, variable Chart is not defined in your code. Maybe using window.Chart could help?

from swup.

gmrchk avatar gmrchk commented on May 3, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.